diff --git a/ChangeLog b/ChangeLog
index 0516ecc9b34..f3e3bb08194 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,9 +9,8 @@ For users:
---------------
NEW: Minimal PHP version is now PHP 7.0 instead of PHP 5.6
-NEW: #21750 Added "Get lines and Post lines from BOM" at the REST Service
NEW: #21780 Add pid field to Cronjob class and store PID on job execution
-NEW: #19680 Add option PRODUCT_ALLOW_EXTERNAL_DOWNLOAD
+NEW: #19680 Add option PRODUCT_ALLOW_EXTERNAL_DOWNLOAD to automatically have uploaded files shared publicly by a link
NEW: #20650 can move the checkbox column on left (experimental option)
NEW: #21000 Added columns 'alias_name' on poject, supplier invoice, supplier order, supplier proposals and taks list
NEW: #21395 Added option for dark theme mode in display - color and theme
@@ -19,11 +18,9 @@ NEW: #21397 added option to auto define barcode numbers for third-parties in bar
NEW: #21399
NEW: #21442 Enhancement of module builder init
NEW: #21654 add bank account number used on invoices for debit
-NEW: #21775 Template 03 manages send mails
NEW: #22048 Added notes to productlot module
-NEW: #22298 Bank - Add salaries & vat in tab planned entries
+NEW: #22298 Bank - Add salaries & vat in the tab of planned entries of a bank account
NEW: #22328
-NEW: #22370 Modulebuilder supports 'alwayseditable' (like extrafields)
NEW: #22424
NEW: #22500 member module set up made easier
NEW: #22527 projects and thirdparties can be viewed as conversation ("Message" view), like events/agenda.
@@ -57,7 +54,6 @@ NEW: Add hidden option MAIN_EMAIL_SUPPORT_ACK to restore Email ack checkbox (fea
NEW: Add IMAP port setting on email collector module
NEW: Adding JAPAN Chart-of-Account and regions/departments
NEW: Adding NIF verification for Algeria
-NEW: Add 4 other templates in website module
NEW: Add link to create an element from the category page
NEW: add margin infos to takepos invoice lines
NEW: Add max size send for "backup and link to mail" option
@@ -98,6 +94,7 @@ NEW: Website Can remove a website template
NEW: Website can set header "Strict-Transport-Security" in web sites.
NEW: Website Can switch status of website and page from the website toolbar
NEW: Website Templates of websites are now directories and not zip into core repo
+NEW: Website Add 4 other templates in website module
NEW: Can use products categories to make inventory
NEW: Change filter type on tickets list into a multiselect combo
NEW: conf TIMESPENT_ALWAYS_UPDATE_THM, when it's on we always check current thm of user to update it in task time line
@@ -129,7 +126,6 @@ NEW: manage no email with thirdparties (better for GDPR)
NEW: Manage Position (Rank) on Contract Lines
NEW: Manage VAT on all lines on purchases cycle
NEW: manage virtual stock at a future date
-NEW: ModuleBuilder can generate code of class from an existing SQL table
NEW: On a bank reconciled line, we can modify the bank receipt
NEW: On a form to send an email, we show all emails of all contacts of object
NEW: Option PRODUCTBATCH_SHOW_WAREHOUSE_ON_SHIPMENT showing wh on PDF
@@ -163,7 +159,6 @@ NEW: SMTP using oauth2 authentication
NEW: can substitue project title in mail template
NEW: Supplier order list - Add column private and public note
NEW: Support IP type in extrafields
-NEW: support multilang in Civilities API
NEW: Table of membership types
NEW: The purge of files can purge only if older than a number of seconds
NEW: Update ActionComm type_code on email message ticket
@@ -174,8 +169,11 @@ NEW: expand/collapse permissions on user permission page
For developers or integrators:
------------------------------
+NEW: ModuleBuilder can generate code of class from an existing SQL table
+NEW: #22370 Modulebuilder supports 'alwayseditable' (like extrafields)
NEW: #20912 Add trigger to record the event of sending an email from a project
-NEW: Removed completely the need for library adodbtime
+NEW: #21750 Added "Get lines and Post lines from BOM" at the REST Service
+NEW: Removed completely the need for the library adodbtime
NEW: hook on agenda pages
NEW: hook to complete payment in TakePOS
NEW: hook "changeHelpURL" to modify target of the help button
@@ -186,6 +184,7 @@ NEW: Add new hooks for actioncomm
NEW: conf->global->SYSLOG_FILE_ONEPERSESSION accept a string
NEW: translate for contact type API, setup/ticket API, shipping method API
NEW: All ajax pages have now a top_httphead()
+NEW: support multilang in Civilities API
NEW: Add API for the partnership module
NEW: Add "Get lines and Post lines from BOM" in the API
NEW: Replace fk_categories_product with categories_product in inventory
diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php
index c7373fd02db..8f76f9a7b2b 100644
--- a/htdocs/admin/geoipmaxmind.php
+++ b/htdocs/admin/geoipmaxmind.php
@@ -53,27 +53,20 @@ if ($action == 'set') {
$error++;
}
- if (!$error && $gimcdf && !file_exists($gimcdf)) {
- setEventMessages($langs->trans("ErrorFileNotFound", $gimcdf), null, 'errors');
+ $res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity);
+ if (!($res1 > 0)) {
+ $error++;
+ }
+
+ $res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity);
+ if (!($res2 > 0)) {
$error++;
}
if (!$error) {
- $res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity);
- if (!($res1 > 0)) {
- $error++;
- }
-
- $res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity);
- if (!($res2 > 0)) {
- $error++;
- }
-
- if (!$error) {
- setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
- } else {
- setEventMessages($langs->trans("Error"), null, 'errors');
- }
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ } else {
+ //setEventMessages($langs->trans("Error"), null, 'errors');
}
}
@@ -112,8 +105,8 @@ print '
';
diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php
index 1ea81cd5dd3..62b012858b5 100644
--- a/htdocs/admin/system/security.php
+++ b/htdocs/admin/system/security.php
@@ -542,13 +542,13 @@ print ' ';
print 'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL = '.(empty($conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL) ? ''.$langs->trans("Undefined").' ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)' : $conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL)." ";
print ' ';
-print 'MAIN_SECURITY_FORCECSP = '.(empty($conf->global->MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCECSP).' ('.$langs->trans("Example").": \"default-src 'self'; img-src *;\") ";
+print 'MAIN_SECURITY_FORCECSP = '.(empty($conf->global->MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCECSP).' ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; img-src *;\") ";
print ' ';
-print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).' ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\") ";
+print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).' ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\" so browser doesn't send any referrer when going into another web site domain) ";
print ' ';
-print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).' ('.$langs->trans("Example").": \"default-src 'self'; style-src: https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src: https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src: *;\") ";
+print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).' ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\") ";
print ' ';
print 'WEBSITE_MAIN_SECURITY_FORCERP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCERP).' ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\") ";
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index 2bfdf9d1f66..062d041c81a 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -567,16 +567,17 @@ if (isModEnabled('socialnetworks')) {
if ($value['active'] && strlen($search_[$key])) {
$searchkeyinjsonformat = preg_replace('/"$/', '', preg_replace('/^"/', '', json_encode($search_[$key])));
if (in_array($db->type, array('mysql', 'mysqli'))) {
- $sql .= " AND p.socialnetworks REGEXP '\"".$db->escapeforlike($db->escape($key))."\":\"[^\"]*".$db->escapeforlike($db->escape($searchkeyinjsonformat))."'";
+ $sql .= " AND p.socialnetworks REGEXP '\"".$db->escape($db->escapeforlike($key))."\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat))."'";
} elseif ($db->type == 'pgsql') {
- $sql .= " AND p.socialnetworks ~ '\"".$db->escapeforlike($db->escape($key))."\":\"[^\"]*".$db->escapeforlike($db->escape($searchkeyinjsonformat))."'";
+ $sql .= " AND p.socialnetworks ~ '\"".$db->escape($db->escapeforlike($key))."\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat))."'";
} else {
// Works with all database but not reliable because search only for social network code starting with earched value
- $sql .= " AND p.socialnetworks LIKE '%\"".$db->escapeforlike($db->escape($key))."\":\"".$db->escapeforlike($db->escape($searchkeyinjsonformat))."%'";
+ $sql .= " AND p.socialnetworks LIKE '%\"".$db->escape($db->escapeforlike($key))."\":\"".$db->escape($db->escapeforlike($searchkeyinjsonformat))."%'";
}
}
}
}
+//print $sql;
if (strlen($search_email)) {
$sql .= natural_search('p.email', $search_email);
}
diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index 4b43230adda..c258e3198ce 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -936,7 +936,7 @@ function getSocialNetworkSharingLinks()
* @param string $langcode Language code ('' or 'en', 'fr', 'es', ...)
* @param array $otherfilters Other filters
* @param int $status 0 or 1, or -1 for both
- * @return string HTML content
+ * @return array Array with results of search
*/
function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $sortfield = 'date_creation', $sortorder = 'DESC', $langcode = '', $otherfilters = 'null', $status = 1)
{
@@ -974,6 +974,8 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
$found = 0;
if (!$error && (empty($max) || ($found < $max)) && (preg_match('/meta/', $algo) || preg_match('/content/', $algo))) {
+ include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
+
$sql = 'SELECT wp.rowid FROM '.MAIN_DB_PREFIX.'website_page as wp';
if (is_array($otherfilters) && !empty($otherfilters['category'])) {
$sql .= ', '.MAIN_DB_PREFIX.'categorie_website_page as cwp';
@@ -983,7 +985,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
$sql .= " AND wp.status = ".((int) $status);
}
if ($langcode) {
- $sql .= " AND wp.lang ='".$db->escape($langcode)."'";
+ $sql .= " AND wp.lang = '".$db->escape($langcode)."'";
}
if ($type) {
$tmparrayoftype = explode(',', $type);
@@ -996,11 +998,11 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
$sql .= " AND (";
$searchalgo = '';
if (preg_match('/meta/', $algo)) {
- $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.title LIKE '%".$db->escapeforlike($db->escape($searchstring))."%' OR wp.description LIKE '%".$db->escapeforlike($db->escape($searchstring))."%'";
- $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.keywords LIKE '".$db->escapeforlike($db->escape($searchstring)).",%' OR wp.keywords LIKE '% ".$db->escapeforlike($db->escape($searchstring))."%'"; // TODO Use a better way to scan keywords
+ $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.title LIKE '%".$db->escape($db->escapeforlike($searchstring))."%' OR wp.description LIKE '%".$db->escape($db->escapeforlike($searchstring))."%'";
+ $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.keywords LIKE '".$db->escape($db->escapeforlike($searchstring)).",%' OR wp.keywords LIKE '% ".$db->escape($db->escapeforlike($searchstring))."%'"; // TODO Use a better way to scan keywords
}
if (preg_match('/content/', $algo)) {
- $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escapeforlike($db->escape($searchstring))."%'";
+ $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escape($db->escapeforlike($searchstring))."%'";
}
$sql .= $searchalgo;
if (is_array($otherfilters) && !empty($otherfilters['category'])) {
@@ -1012,6 +1014,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
//print $sql;
$resql = $db->query($sql);
+
if ($resql) {
$i = 0;
while (($obj = $db->fetch_object($resql)) && ($i < $max || $max == 0)) {
diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php
index 09f93a436ea..22c12024c2b 100644
--- a/htdocs/core/modules/import/import_csv.modules.php
+++ b/htdocs/core/modules/import/import_csv.modules.php
@@ -862,8 +862,8 @@ class ImportCsv extends ModeleImports
$stringtosearch = json_encode($socialnetwork).':'.json_encode($json->$socialnetwork);
//var_dump($stringtosearch);
//var_dump($this->db->escape($stringtosearch)); // This provide a value for sql string (but not for a like)
- $where[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'";
- $filters[] = $col." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'";
+ $where[] = $key." LIKE '%".$this->db->escape($this->db->escapeforlike($stringtosearch))."%'";
+ $filters[] = $col." LIKE '%".$this->db->escape($this->db->escapeforlike($stringtosearch))."%'";
//var_dump($where[1]); // This provide a value for sql string inside a like
} else {
$where[] = $key.' = '.$data[$key];
diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php
index ecf7d8b4a77..35adc4476a0 100644
--- a/htdocs/core/modules/import/import_xlsx.modules.php
+++ b/htdocs/core/modules/import/import_xlsx.modules.php
@@ -908,8 +908,8 @@ class ImportXlsx extends ModeleImports
$stringtosearch = json_encode($socialnetwork).':'.json_encode($json->$socialnetwork);
//var_dump($stringtosearch);
//var_dump($this->db->escape($stringtosearch)); // This provide a value for sql string (but not for a like)
- $where[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'";
- $filters[] = $col." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'";
+ $where[] = $key." LIKE '%".$this->db->escape($this->db->escapeforlike($stringtosearch))."%'";
+ $filters[] = $col." LIKE '%".$this->db->escape($this->db->escapeforlike($stringtosearch))."%'";
//var_dump($where[1]); // This provide a value for sql string inside a like
} else {
$where[] = $key.' = '.$data[$key];
diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php
index 1ce6d859266..9a33bd25c05 100644
--- a/htdocs/imports/import.php
+++ b/htdocs/imports/import.php
@@ -1068,6 +1068,7 @@ if ($step == 4 && $datatoimport) {
print '
'."\n";
// List of source fields
+
$var = false;
$lefti = 1;
foreach ($fieldssource as $key => $val) {
@@ -1090,6 +1091,7 @@ if ($step == 4 && $datatoimport) {
print '
';
// Set the list of all possible target fields in Dolibarr.
+
$optionsall = array();
foreach ($fieldstarget as $code => $line) {
//var_dump($line);
@@ -1141,8 +1143,7 @@ if ($step == 4 && $datatoimport) {
$entityicon = !empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ...
$entitylang = $entitytolang[$entity] ? $entitytolang[$entity] : $objimport->array_import_label[0]; // $entitylang must be a translation key to describe object the field is related to, like 'Company', 'Contact', 'MyModyle', ...
- //print '
';
if (empty($obj->fk_user)) {
print $langs->trans("Everybody");
} else {
@@ -2338,7 +2339,7 @@ $db->close();
*/
function show_elem($fieldssource, $pos, $key, $var, $nostyle = '')
{
- global $langs;
+ global $conf, $langs;
$height = '32px';
@@ -2384,7 +2385,7 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '')
if (isset($fieldssource[$pos]['imported']) && $fieldssource[$pos]['imported'] == false) {
print '
';
} else {
- print '
';
+ print '
';
}
print $langs->trans("Column").' '.num2Alpha($pos - 1).' (#'.$pos.')';
if (empty($fieldssource[$pos]['example1'])) {
@@ -2396,7 +2397,12 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '')
if (!utf8_check($example)) {
$example = utf8_encode($example);
}
- print ' - ';
+ if (!empty($conf->dol_optimize_smallscreen)) {
+ //print ' ';
+ print ' - ';
+ } else {
+ print ' - ';
+ }
//print ''.$langs->trans("ExampleOnFirstLine").': ';
print ''.$example.'';
}
diff --git a/htdocs/includes/adodbtime/README.txt b/htdocs/includes/adodbtime/README.txt
deleted file mode 100644
index 3e2969a2868..00000000000
--- a/htdocs/includes/adodbtime/README.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-README
-======
-
-ADOdb Date Library, part of the ADOdb abstraction library
-
-See Wiki: https://adodb.org/dokuwiki/doku.php?id=v5:datetime:datetime_index
-Download: https://github.com/ADOdb/ADOdb/blob/master/adodb-time.inc.php
diff --git a/htdocs/includes/adodbtime/adodb-time.inc.php b/htdocs/includes/adodbtime/adodb-time.inc.php
deleted file mode 100644
index 1dfa97929a2..00000000000
--- a/htdocs/includes/adodbtime/adodb-time.inc.php
+++ /dev/null
@@ -1,1459 +0,0 @@
- 4 digit year conversion. The maximum is billions of years in the
-future, but this is a theoretical limit as the computation of that year
-would take too long with the current implementation of adodb_mktime().
-
-This library replaces native functions as follows:
-
-
- getdate() with adodb_getdate()
- date() with adodb_date()
- gmdate() with adodb_gmdate()
- mktime() with adodb_mktime()
- gmmktime() with adodb_gmmktime()
- strftime() with adodb_strftime()
- strftime() with adodb_gmstrftime()
-
-
-The parameters are identical, except that adodb_date() accepts a subset
-of date()'s field formats. Mktime() will convert from local time to GMT,
-and date() will convert from GMT to local time, but daylight savings is
-not handled currently.
-
-This library is independant of the rest of ADOdb, and can be used
-as standalone code.
-
-PERFORMANCE
-
-For high speed, this library uses the native date functions where
-possible, and only switches to PHP code when the dates fall outside
-the 32-bit signed integer range.
-
-GREGORIAN CORRECTION
-
-Pope Gregory shortened October of A.D. 1582 by ten days. Thursday,
-October 4, 1582 (Julian) was followed immediately by Friday, October 15,
-1582 (Gregorian).
-
-Since 0.06, we handle this correctly, so:
-
-adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582)
- == 24 * 3600 (1 day)
-
-=============================================================================
-
-COPYRIGHT
-
-(c) 2003-2014 John Lim and released under BSD-style license except for code by
-jackbbs, which includes adodb_mktime, adodb_get_gmt_diff, adodb_is_leap_year
-and originally found at http://www.php.net/manual/en/function.mktime.php
-
-=============================================================================
-
-BUG REPORTS
-
-These should be posted to the ADOdb forums at
-
- http://phplens.com/lens/lensforum/topics.php?id=4
-
-=============================================================================
-
-FUNCTION DESCRIPTIONS
-
-** FUNCTION adodb_time()
-
-Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) as an unsigned integer.
-
-** FUNCTION adodb_getdate($date=false)
-
-Returns an array containing date information, as getdate(), but supports
-dates greater than 1901 to 2038. The local date/time format is derived from a
-heuristic the first time adodb_getdate is called.
-
-
-** FUNCTION adodb_date($fmt, $timestamp = false)
-
-Convert a timestamp to a formatted local date. If $timestamp is not defined, the
-current timestamp is used. Unlike the function date(), it supports dates
-outside the 1901 to 2038 range.
-
-The format fields that adodb_date supports:
-
-
- a - "am" or "pm"
- A - "AM" or "PM"
- d - day of the month, 2 digits with leading zeros; i.e. "01" to "31"
- D - day of the week, textual, 3 letters; e.g. "Fri"
- F - month, textual, long; e.g. "January"
- g - hour, 12-hour format without leading zeros; i.e. "1" to "12"
- G - hour, 24-hour format without leading zeros; i.e. "0" to "23"
- h - hour, 12-hour format; i.e. "01" to "12"
- H - hour, 24-hour format; i.e. "00" to "23"
- i - minutes; i.e. "00" to "59"
- j - day of the month without leading zeros; i.e. "1" to "31"
- l (lowercase 'L') - day of the week, textual, long; e.g. "Friday"
- L - boolean for whether it is a leap year; i.e. "0" or "1"
- m - month; i.e. "01" to "12"
- M - month, textual, 3 letters; e.g. "Jan"
- n - month without leading zeros; i.e. "1" to "12"
- O - Difference to Greenwich time in hours; e.g. "+0200"
- Q - Quarter, as in 1, 2, 3, 4
- r - RFC 2822 formatted date; e.g. "Thu, 21 Dec 2000 16:01:07 +0200"
- s - seconds; i.e. "00" to "59"
- S - English ordinal suffix for the day of the month, 2 characters;
- i.e. "st", "nd", "rd" or "th"
- t - number of days in the given month; i.e. "28" to "31"
- T - Timezone setting of this machine; e.g. "EST" or "MDT"
- U - seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
- w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday)
- Y - year, 4 digits; e.g. "1999"
- y - year, 2 digits; e.g. "99"
- z - day of the year; i.e. "0" to "365"
- Z - timezone offset in seconds (i.e. "-43200" to "43200").
- The offset for timezones west of UTC is always negative,
- and for those east of UTC is always positive.
-
-
-Unsupported:
-
- B - Swatch Internet time
- I (capital i) - "1" if Daylight Savings Time, "0" otherwise.
- W - ISO-8601 week number of year, weeks starting on Monday
-
-
-
-
-** FUNCTION adodb_date2($fmt, $isoDateString = false)
-Same as adodb_date, but 2nd parameter accepts iso date, eg.
-
- adodb_date2('d-M-Y H:i','2003-12-25 13:01:34');
-
-
-** FUNCTION adodb_gmdate($fmt, $timestamp = false)
-
-Convert a timestamp to a formatted GMT date. If $timestamp is not defined, the
-current timestamp is used. Unlike the function date(), it supports dates
-outside the 1901 to 2038 range.
-
-
-** FUNCTION adodb_mktime($hr, $min, $sec[, $month, $day, $year])
-
-Converts a local date to a unix timestamp. Unlike the function mktime(), it supports
-dates outside the 1901 to 2038 range. All parameters are optional.
-
-
-** FUNCTION adodb_gmmktime($hr, $min, $sec [, $month, $day, $year])
-
-Converts a gmt date to a unix timestamp. Unlike the function gmmktime(), it supports
-dates outside the 1901 to 2038 range. Differs from gmmktime() in that all parameters
-are currently compulsory.
-
-** FUNCTION adodb_gmstrftime($fmt, $timestamp = false)
-Convert a timestamp to a formatted GMT date.
-
-** FUNCTION adodb_strftime($fmt, $timestamp = false)
-
-Convert a timestamp to a formatted local date. Internally converts $fmt into
-adodb_date format, then echo result.
-
-For best results, you can define the local date format yourself. Define a global
-variable $ADODB_DATE_LOCALE which is an array, 1st element is date format using
-adodb_date syntax, and 2nd element is the time format, also in adodb_date syntax.
-
- eg. $ADODB_DATE_LOCALE = array('d/m/Y','H:i:s');
-
- Supported format codes:
-
-
- %a - abbreviated weekday name according to the current locale
- %A - full weekday name according to the current locale
- %b - abbreviated month name according to the current locale
- %B - full month name according to the current locale
- %c - preferred date and time representation for the current locale
- %d - day of the month as a decimal number (range 01 to 31)
- %D - same as %m/%d/%y
- %e - day of the month as a decimal number, a single digit is preceded by a space (range ' 1' to '31')
- %h - same as %b
- %H - hour as a decimal number using a 24-hour clock (range 00 to 23)
- %I - hour as a decimal number using a 12-hour clock (range 01 to 12)
- %m - month as a decimal number (range 01 to 12)
- %M - minute as a decimal number
- %n - newline character
- %p - either `am' or `pm' according to the given time value, or the corresponding strings for the current locale
- %r - time in a.m. and p.m. notation
- %R - time in 24 hour notation
- %S - second as a decimal number
- %t - tab character
- %T - current time, equal to %H:%M:%S
- %x - preferred date representation for the current locale without the time
- %X - preferred time representation for the current locale without the date
- %y - year as a decimal number without a century (range 00 to 99)
- %Y - year as a decimal number including the century
- %Z - time zone or name or abbreviation
- %% - a literal `%' character
-
-
- Unsupported codes:
-
- %C - century number (the year divided by 100 and truncated to an integer, range 00 to 99)
- %g - like %G, but without the century.
- %G - The 4-digit year corresponding to the ISO week number (see %V).
- This has the same format and value as %Y, except that if the ISO week number belongs
- to the previous or next year, that year is used instead.
- %j - day of the year as a decimal number (range 001 to 366)
- %u - weekday as a decimal number [1,7], with 1 representing Monday
- %U - week number of the current year as a decimal number, starting
- with the first Sunday as the first day of the first week
- %V - The ISO 8601:1988 week number of the current year as a decimal number,
- range 01 to 53, where week 1 is the first week that has at least 4 days in the
- current year, and with Monday as the first day of the week. (Use %G or %g for
- the year component that corresponds to the week number for the specified timestamp.)
- %w - day of the week as a decimal, Sunday being 0
- %W - week number of the current year as a decimal number, starting with the
- first Monday as the first day of the first week
-
-
-=============================================================================
-
-NOTES
-
-Useful url for generating test timestamps:
- http://www.4webhelp.net/us/timestamp.php
-
-Possible future optimizations include
-
-a. Using an algorithm similar to Plauger's in "The Standard C Library"
-(page 428, xttotm.c _Ttotm() function). Plauger's algorithm will not
-work outside 32-bit signed range, so i decided not to implement it.
-
-b. Implement daylight savings, which looks awfully complicated, see
- http://webexhibits.org/daylightsaving/
-
-
-CHANGELOG
-- 16 Jan 2011 0.36
-Added adodb_time() which returns current time. If > 2038, will return as float
-
-- 7 Feb 2011 0.35
-Changed adodb_date to be symmetric with adodb_mktime. See $jan1_71. fix for bc.
-
-- 13 July 2010 0.34
-Changed adodb_get_gm_diff to use DateTimeZone().
-
-- 11 Feb 2008 0.33
-* Bug in 0.32 fix for hour handling. Fixed.
-
-- 1 Feb 2008 0.32
-* Now adodb_mktime(0,0,0,12+$m,20,2040) works properly.
-
-- 10 Jan 2008 0.31
-* Now adodb_mktime(0,0,0,24,1,2037) works correctly.
-
-- 15 July 2007 0.30
-Added PHP 5.2.0 compatability fixes.
- * gmtime behaviour for 1970 has changed. We use the actual date if it is between 1970 to 2038 to get the
- * timezone, otherwise we use the current year as the baseline to retrieve the timezone.
- * Also the timezone's in php 5.2.* support historical data better, eg. if timezone today was +8, but
- in 1970 it was +7:30, then php 5.2 return +7:30, while this library will use +8.
- *
-
-- 19 March 2006 0.24
-Changed strftime() locale detection, because some locales prepend the day of week to the date when %c is used.
-
-- 10 Feb 2006 0.23
-PHP5 compat: when we detect PHP5, the RFC2822 format for gmt 0000hrs is changed from -0000 to +0000.
- In PHP4, we will still use -0000 for 100% compat with PHP4.
-
-- 08 Sept 2005 0.22
-In adodb_date2(), $is_gmt not supported properly. Fixed.
-
-- 18 July 2005 0.21
-In PHP 4.3.11, the 'r' format has changed. Leading 0 in day is added. Changed for compat.
-Added support for negative months in adodb_mktime().
-
-- 24 Feb 2005 0.20
-Added limited strftime/gmstrftime support. x10 improvement in performance of adodb_date().
-
-- 21 Dec 2004 0.17
-In adodb_getdate(), the timestamp was accidentally converted to gmt when $is_gmt is false.
-Also adodb_mktime(0,0,0) did not work properly. Both fixed thx Mauro.
-
-- 17 Nov 2004 0.16
-Removed intval typecast in adodb_mktime() for secs, allowing:
- adodb_mktime(0,0,0 + 2236672153,1,1,1934);
-Suggested by Ryan.
-
-- 18 July 2004 0.15
-All params in adodb_mktime were formerly compulsory. Now only the hour, min, secs is compulsory.
-This brings it more in line with mktime (still not identical).
-
-- 23 June 2004 0.14
-
-Allow you to define your own daylights savings function, adodb_daylight_sv.
-If the function is defined (somewhere in an include), then you can correct for daylights savings.
-
-In this example, we apply daylights savings in June or July, adding one hour. This is extremely
-unrealistic as it does not take into account time-zone, geographic location, current year.
-
-function adodb_daylight_sv(&$arr, $is_gmt)
-{
- if ($is_gmt) return;
- $m = $arr['mon'];
- if ($m == 6 || $m == 7) $arr['hours'] += 1;
-}
-
-This is only called by adodb_date() and not by adodb_mktime().
-
-The format of $arr is
-Array (
- [seconds] => 0
- [minutes] => 0
- [hours] => 0
- [mday] => 1 # day of month, eg 1st day of the month
- [mon] => 2 # month (eg. Feb)
- [year] => 2102
- [yday] => 31 # days in current year
- [leap] => # true if leap year
- [ndays] => 28 # no of days in current month
- )
-
-
-- 28 Apr 2004 0.13
-Fixed adodb_date to properly support $is_gmt. Thx to Dimitar Angelov.
-
-- 20 Mar 2004 0.12
-Fixed month calculation error in adodb_date. 2102-June-01 appeared as 2102-May-32.
-
-- 26 Oct 2003 0.11
-Because of daylight savings problems (some systems apply daylight savings to
-January!!!), changed adodb_get_gmt_diff() to ignore daylight savings.
-
-- 9 Aug 2003 0.10
-Fixed bug with dates after 2038.
-See http://phplens.com/lens/lensforum/msgs.php?id=6980
-
-- 1 July 2003 0.09
-Added support for Q (Quarter).
-Added adodb_date2(), which accepts ISO date in 2nd param
-
-- 3 March 2003 0.08
-Added support for 'S' adodb_date() format char. Added constant ADODB_ALLOW_NEGATIVE_TS
-if you want PHP to handle negative timestamps between 1901 to 1969.
-
-- 27 Feb 2003 0.07
-All negative numbers handled by adodb now because of RH 7.3+ problems.
-See http://bugs.php.net/bug.php?id=20048&edit=2
-
-- 4 Feb 2003 0.06
-Fixed a typo, 1852 changed to 1582! This means that pre-1852 dates
-are now correctly handled.
-
-- 29 Jan 2003 0.05
-
-Leap year checking differs under Julian calendar (pre 1582). Also
-leap year code optimized by checking for most common case first.
-
-We also handle month overflow correctly in mktime (eg month set to 13).
-
-Day overflow for less than one month's days is supported.
-
-- 28 Jan 2003 0.04
-
-Gregorian correction handled. In PHP5, we might throw an error if
-mktime uses invalid dates around 5-14 Oct 1582. Released with ADOdb 3.10.
-Added limbo 5-14 Oct 1582 check, when we set to 15 Oct 1582.
-
-- 27 Jan 2003 0.03
-
-Fixed some more month problems due to gmt issues. Added constant ADODB_DATE_VERSION.
-Fixed calculation of days since start of year for <1970.
-
-- 27 Jan 2003 0.02
-
-Changed _adodb_getdate() to inline leap year checking for better performance.
-Fixed problem with time-zones west of GMT +0000.
-
-- 24 Jan 2003 0.01
-
-First implementation.
-*/
-
-
-/* Initialization */
-
-/*
- Version Number
-*/
-define('ADODB_DATE_VERSION',0.35);
-
-$ADODB_DATETIME_CLASS = (PHP_VERSION >= 5.2);
-
-/*
- This code was originally for windows. But apparently this problem happens
- also with Linux, RH 7.3 and later!
-
- glibc-2.2.5-34 and greater has been changed to return -1 for dates <
- 1970. This used to work. The problem exists with RedHat 7.3 and 8.0
- echo (mktime(0, 0, 0, 1, 1, 1960)); // prints -1
-
- References:
- http://bugs.php.net/bug.php?id=20048&edit=2
- http://lists.debian.org/debian-glibc/2002/debian-glibc-200205/msg00010.html
-*/
-
-if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1);
-
-function adodb_date_test_date($y1,$m,$d=13)
-{
- $h = round(rand()% 24);
- $t = adodb_mktime($h,0,0,$m,$d,$y1);
- $rez = adodb_date('Y-n-j H:i:s',$t);
- if ($h == 0) $h = '00';
- else if ($h < 10) $h = '0'.$h;
- if ("$y1-$m-$d $h:00:00" != $rez) {
- print "$y1 error, expected=$y1-$m-$d $h:00:00, adodb=$rez ";
- return false;
- }
- return true;
-}
-
-function adodb_date_test_strftime($fmt)
-{
- $s1 = strftime($fmt);
- $s2 = adodb_strftime($fmt);
-
- if ($s1 == $s2) return true;
-
- echo "error for $fmt, strftime=$s1, adodb=$s2 ";
- return false;
-}
-
-/**
- Test Suite
-*/
-function adodb_date_test()
-{
-
- for ($m=-24; $m<=24; $m++)
- echo "$m :",adodb_date('d-m-Y',adodb_mktime(0,0,0,1+$m,20,2040))," ";
-
- error_reporting(E_ALL);
- print "
Testing adodb_date and adodb_mktime. version=".ADODB_DATE_VERSION.' PHP='.PHP_VERSION."
";
- @set_time_limit(0);
- $fail = false;
-
- // This flag disables calling of PHP native functions, so we can properly test the code
- if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1);
-
- $t = time();
-
-
- $fmt = 'Y-m-d H:i:s';
- echo '
";
- $t = adodb_mktime(0,0,0,10,11,1492);
- //http://www.holidayorigins.com/html/columbus_day.html - Friday check
- if (!(adodb_date('D Y-m-d',$t) == 'Fri 1492-10-11')) print 'Error in Columbus landing ';
-
- $t = adodb_mktime(0,0,0,2,29,1500);
- if (!(adodb_date('Y-m-d',$t) == '1500-02-29')) print 'Error in julian leap years ';
-
- $t = adodb_mktime(0,0,0,2,29,1700);
- if (!(adodb_date('Y-m-d',$t) == '1700-03-01')) print 'Error in gregorian leap years ';
-
- print adodb_mktime(0,0,0,10,4,1582).' ';
- print adodb_mktime(0,0,0,10,15,1582);
- $diff = (adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582));
- if ($diff != 3600*24) print " Error in gregorian correction = ".($diff/3600/24)." days ";
-
- print " 15 Oct 1582, Fri=".(adodb_dow(1582,10,15) == 5 ? 'Fri' : 'Error')." ";
- print " 4 Oct 1582, Thu=".(adodb_dow(1582,10,4) == 4 ? 'Thu' : 'Error')." ";
-
- print "
Testing overflow
";
-
- $t = adodb_mktime(0,0,0,3,33,1965);
- if (!(adodb_date('Y-m-d',$t) == '1965-04-02')) print 'Error in day overflow 1 ';
- $t = adodb_mktime(0,0,0,4,33,1971);
- if (!(adodb_date('Y-m-d',$t) == '1971-05-03')) print 'Error in day overflow 2 ';
- $t = adodb_mktime(0,0,0,1,60,1965);
- if (!(adodb_date('Y-m-d',$t) == '1965-03-01')) print 'Error in day overflow 3 '.adodb_date('Y-m-d',$t).' ';
- $t = adodb_mktime(0,0,0,12,32,1965);
- if (!(adodb_date('Y-m-d',$t) == '1966-01-01')) print 'Error in day overflow 4 '.adodb_date('Y-m-d',$t).' ';
- $t = adodb_mktime(0,0,0,12,63,1965);
- if (!(adodb_date('Y-m-d',$t) == '1966-02-01')) print 'Error in day overflow 5 '.adodb_date('Y-m-d',$t).' ';
- $t = adodb_mktime(0,0,0,13,3,1965);
- if (!(adodb_date('Y-m-d',$t) == '1966-01-03')) print 'Error in mth overflow 1 ';
-
- print "Testing 2-digit => 4-digit year conversion
";
- if (adodb_year_digit_check(00) != 2000) print "Err 2-digit 2000 ";
- if (adodb_year_digit_check(10) != 2010) print "Err 2-digit 2010 ";
- if (adodb_year_digit_check(20) != 2020) print "Err 2-digit 2020 ";
- if (adodb_year_digit_check(30) != 2030) print "Err 2-digit 2030 ";
- if (adodb_year_digit_check(40) != 1940) print "Err 2-digit 1940 ";
- if (adodb_year_digit_check(50) != 1950) print "Err 2-digit 1950 ";
- if (adodb_year_digit_check(90) != 1990) print "Err 2-digit 1990 ";
-
- // Test string formating
- print "
Testing date formating
";
-
- $fmt = '\d\a\t\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \R\F\C2822 r s t U w y Y z Z 2003';
- $s1 = date($fmt,0);
- $s2 = adodb_date($fmt,0);
- if ($s1 != $s2) {
- print " date() 0 failed $s1 $s2 ";
- }
- flush();
- for ($i=100; --$i > 0; ) {
-
- $ts = 3600.0*((rand()%60000)+(rand()%60000))+(rand()%60000);
- $s1 = date($fmt,$ts);
- $s2 = adodb_date($fmt,$ts);
- //print "$s1 $s2