define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_CODENAME', 'Asparagus');
- define ( 'FRIENDICA_VERSION', '3.5.1-rc' );
+ define ( 'FRIENDICA_VERSION', '3.5.2-dev' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
- define ( 'DB_UPDATE_VERSION', 1214 );
+ define ( 'DB_UPDATE_VERSION', 1215 );
/**
* @brief Constant with a HTML line break.
define('SR_SCOPE_TAGS', 'tags');
/* @}*/
+/**
+ * Lowest possible date time value
+ */
+
+//define ('NULL_DATE', '0001-01-01 00:00:00');
+define ('NULL_DATE', '0000-00-00 00:00:00');
+
+
// Normally this constant is defined - but not if "pcntl" isn't installed
if (!defined("SIGTERM"))
define("SIGTERM", 15);
}
// Checking number of workers
- $workers = q("SELECT COUNT(*) AS `workers` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'");
+ $workers = q("SELECT COUNT(*) AS `workers` FROM `workerqueue` WHERE `executed` > '%s'", dbesc(NULL_DATE));
// Get number of allowed number of worker threads
$queues = intval(get_config("system", "worker_queues"));
<?php
- require_once('include/Probe.php');
-
// Included here for completeness, but this is a very dangerous operation.
// It is the caller's responsibility to confirm the requestor's intent and
// authorisation to do this.
if($contact['archive'])
return;
- if($contact['term-date'] == '0000-00-00 00:00:00') {
+ if($contact['term-date'] <= NULL_DATE) {
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()),
intval($contact['id'])
// It's a miracle. Our dead contact has inexplicably come back to life.
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d",
- dbesc('0000-00-00 00:00:00'),
+ dbesc(NULL_DATE),
intval($contact['id'])
);
if ($contact['url'] != '') {
q("UPDATE `contact` SET `term-date` = '%s' WHERE `nurl` = '%s'",
- dbesc('0000-00-00 00:00:00'),
+ dbesc(NULL_DATE),
dbesc(normalise_link($contact['url']))
);
}
// "bd" always contains the upcoming birthday of a contact.
// "birthday" might contain the birthday including the year of birth.
- if ($profile["birthday"] != "0000-00-00") {
+ if ($profile["birthday"] >= "0001-01-01") {
$bd_timestamp = strtotime($profile["birthday"]);
$month = date("m", $bd_timestamp);
$day = date("d", $bd_timestamp);
$profile["bd"] = (++$current_year)."-".$month."-".$day;
}
} else {
- $profile["bd"] = "0000-00-00";
+ $profile["bd"] = "0001-01-01";
}
} else {
$profile = $default;
$profile["location"] = "";
$profile["about"] = "";
$profile["gender"] = "";
- $profile["birthday"] = "0000-00-00";
+ $profile["birthday"] = "0001-01-01";
}
$cache[$url][$uid] = $profile;
dbesc($addr));
if (!dbm::is_result($r)) {
+ require_once('include/Probe.php');
$data = Probe::uri($addr);
$profile = get_contact_details_by_url($data['url'], $uid);
/**
* @brief Fetch the contact id for a given url and user
*
+ * First lookup in the contact table to find a record matching either `url`, `nurl`,
+ * `addr` or `alias`.
+ *
+ * If there's no record and we aren't looking for a public contact, we quit.
+ * If there's one, we check that it isn't time to update the picture else we
+ * directly return the found contact id.
+ *
+ * Second, we probe the provided $url wether it's http://server.tld/profile or
+ * nick@server.tld. We quit if we can't get any info back.
+ *
+ * Third, we create the contact record if it doesn't exist
+ *
+ * Fourth, we update the existing record with the new data (avatar, alias, nick)
+ * if there's any updates
+ *
* @param string $url Contact URL
- * @param integer $uid The user id for the contact
+ * @param integer $uid The user id for the contact (0 = public contact)
* @param boolean $no_update Don't update the contact
*
* @return integer Contact ID
*/
function get_contact($url, $uid = 0, $no_update = false) {
- require_once("include/Scrape.php");
-
logger("Get contact data for url ".$url." and user ".$uid." - ".App::callstack(), LOGGER_DEBUG);;
$data = array();
- $contactid = 0;
-
- // is it an address in the format user@server.tld?
- /// @todo use gcontact and/or the addr field for a lookup
- if (!strstr($url, "http") OR strstr($url, "@")) {
- $data = probe_url($url);
- $url = $data["url"];
- if ($url == "")
- return 0;
- }
+ $contact_id = 0;
- $contact = q("SELECT `id`, `avatar-date` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d ORDER BY `id` LIMIT 2",
+ // We first try the nurl (http://server.tld/nick), most common case
+ $contacts = q("SELECT `id`, `avatar-date` FROM `contact`
+ WHERE `nurl` = '%s'
+ AND `uid` = %d",
dbesc(normalise_link($url)),
intval($uid));
- if (!$contact)
- $contact = q("SELECT `id`, `avatar-date` FROM `contact` WHERE `alias` IN ('%s', '%s') AND `uid` = %d ORDER BY `id` LIMIT 1",
- dbesc($url),
- dbesc(normalise_link($url)),
- intval($uid));
- if ($contact) {
- $contactid = $contact[0]["id"];
+ // Then the addr (nick@server.tld)
+ if (! dbm::is_result($contacts)) {
+ $contacts = q("SELECT `id`, `avatar-date` FROM `contact`
+ WHERE `addr` = '%s'
+ AND `uid` = %d",
+ dbesc($url),
+ intval($uid));
+ }
+
+ // Then the alias (which could be anything)
+ if (! dbm::is_result($contacts)) {
+ $contacts = q("SELECT `id`, `avatar-date` FROM `contact`
+ WHERE `alias` IN ('%s', '%s')
+ AND `uid` = %d",
+ dbesc($url),
+ dbesc(normalise_link($url)),
+ intval($uid));
+ }
+
+ if (dbm::is_result($contacts)) {
+ $contact_id = $contacts[0]["id"];
// Update the contact every 7 days
- $update_photo = ($contact[0]['avatar-date'] < datetime_convert('','','now -7 days'));
- //$update_photo = ($contact[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
+ $update_photo = ($contacts[0]['avatar-date'] < datetime_convert('','','now -7 days'));
if (!$update_photo OR $no_update) {
- return($contactid);
+ return $contact_id;
}
- } elseif ($uid != 0)
+ } elseif ($uid != 0) {
+ // Non-existing user-specific contact, exiting
return 0;
+ }
- if (!count($data))
- $data = probe_url($url);
+ require_once('include/Probe.php');
+ $data = Probe::uri($url);
- // Does this address belongs to a valid network?
- if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) {
- if ($uid != 0)
+ // Last try in gcontact for unsupported networks
+ if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_PUMPIO))) {
+ if ($uid != 0) {
return 0;
+ }
// Get data from the gcontact table
- $r = q("SELECT `name`, `nick`, `url`, `photo`, `addr`, `alias`, `network` FROM `gcontact` WHERE `nurl` = '%s'",
+ $gcontacts = q("SELECT `name`, `nick`, `url`, `photo`, `addr`, `alias`, `network` FROM `gcontact` WHERE `nurl` = '%s'",
dbesc(normalise_link($url)));
- if (!$r)
+ if (!$gcontacts) {
return 0;
+ }
- $data = $r[0];
+ $data = $gcontacts[0];
}
$url = $data["url"];
- if ($contactid == 0) {
+ if (!$contact_id) {
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
`name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`,
`batch`, `request`, `confirm`, `poco`, `name-date`, `uri-date`,
dbesc(datetime_convert())
);
- $contact = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d ORDER BY `id` LIMIT 2",
+ $contacts = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d ORDER BY `id` LIMIT 2",
dbesc(normalise_link($data["url"])),
intval($uid));
- if (!$contact)
+ if (!dbm::is_result($contacts)) {
return 0;
+ }
- $contactid = $contact[0]["id"];
+ $contact_id = $contacts[0]["id"];
// Update the newly created contact from data in the gcontact table
- $r = q("SELECT `location`, `about`, `keywords`, `gender` FROM `gcontact` WHERE `nurl` = '%s'",
+ $gcontacts = q("SELECT `location`, `about`, `keywords`, `gender` FROM `gcontact` WHERE `nurl` = '%s'",
dbesc(normalise_link($data["url"])));
- if ($r) {
- logger("Update contact ".$data["url"]);
+ if (dbm::is_result($gcontacts)) {
+ logger("Update contact " . $data["url"] . ' from gcontact');
q("UPDATE `contact` SET `location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `id` = %d",
- dbesc($r["location"]), dbesc($r["about"]), dbesc($r["keywords"]),
- dbesc($r["gender"]), intval($contactid));
+ dbesc($gcontacts[0]["location"]), dbesc($gcontacts[0]["about"]), dbesc($gcontacts[0]["keywords"]),
+ dbesc($gcontacts[0]["gender"]), intval($contact_id));
}
}
- if ((count($contact) > 1) AND ($uid == 0) AND ($contactid != 0) AND ($url != ""))
+ if (count($contacts) > 1 AND $uid == 0 AND $contact_id != 0 AND $url != "") {
q("DELETE FROM `contact` WHERE `nurl` = '%s' AND `id` != %d AND NOT `self`",
dbesc(normalise_link($url)),
- intval($contactid));
+ intval($contact_id));
+ }
- require_once("Photo.php");
+ require_once "Photo.php";
- update_contact_avatar($data["photo"],$uid,$contactid);
+ update_contact_avatar($data["photo"], $uid, $contact_id);
- $r = q("SELECT `addr`, `alias`, `name`, `nick` FROM `contact` WHERE `id` = %d", intval($contactid));
+ $contacts = q("SELECT `addr`, `alias`, `name`, `nick` FROM `contact` WHERE `id` = %d", intval($contact_id));
// This condition should always be true
- if (!dbm::is_result($r))
- return $contactid;
+ if (!dbm::is_result($contacts)) {
+ return $contact_id;
+ }
// Only update if there had something been changed
- if (($data["addr"] != $r[0]["addr"]) OR
- ($data["alias"] != $r[0]["alias"]) OR
- ($data["name"] != $r[0]["name"]) OR
- ($data["nick"] != $r[0]["nick"]))
+ if ($data["addr"] != $contacts[0]["addr"] OR
+ $data["alias"] != $contacts[0]["alias"] OR
+ $data["name"] != $contacts[0]["name"] OR
+ $data["nick"] != $contacts[0]["nick"]) {
q("UPDATE `contact` SET `addr` = '%s', `alias` = '%s', `name` = '%s', `nick` = '%s',
`name-date` = '%s', `uri-date` = '%s' WHERE `id` = %d",
dbesc($data["addr"]),
dbesc($data["nick"]),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
- intval($contactid)
+ intval($contact_id)
);
+ }
- return $contactid;
+ return $contact_id;
}
/**
"filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
"filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"data" => array("type" => "longblob", "not null" => "1"),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"allow_cid" => array("type" => "mediumtext"),
"allow_gid" => array("type" => "mediumtext"),
"deny_cid" => array("type" => "mediumtext"),
"k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
"v" => array("type" => "mediumtext"),
"expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
- "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("k"),
"fields" => array(
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "failure_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
"blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
"readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"recips" => array("type" => "text"),
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"subject" => array("type" => "text"),
),
"indexes" => array(
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"summary" => array("type" => "text"),
"desc" => array("type" => "text"),
"location" => array("type" => "text"),
"network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
"alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"pubkey" => array("type" => "text"),
- "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("id"),
"request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"note" => array("type" => "text"),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("id"),
"nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
- "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
- "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "updated" => array("type" => "datetime", "default" => NULL_DATE),
+ "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
+ "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
"location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"about" => array("type" => "text"),
"keywords" => array("type" => "text"),
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
- "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("id"),
"noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
"platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
- "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
- "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
+ "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
+ "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("id"),
"duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"note" => array("type" => "text"),
"hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
"ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
),
"parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
"locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
- "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("id"),
"unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("id"),
"action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
- "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("id"),
"name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"msg" => array("type" => "mediumtext"),
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"fields" => array(
"url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
"content" => array("type" => "mediumtext"),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("url"),
"guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
"oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
"content" => array("type" => "mediumtext"),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("url", "guessing", "oembed"),
"contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
"guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
"resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"desc" => array("type" => "text"),
"album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"fields" => array(
"pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
"command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("pid"),
"gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
"marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"with" => array("type" => "text"),
- "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
- "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
),
"indexes" => array(
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"content" => array("type" => "mediumtext"),
"batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
),
"fields" => array(
"id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
"password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
"spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("id"),
"term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
"gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
"owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
"author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"uid_contactid_created" => array("uid","contact-id","created"),
"uid_created" => array("uid","created"),
"uid_commented" => array("uid","commented"),
+ "uid_wall_created" => array("uid","wall","created"),
)
);
$database["tokens"] = array(
"openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
"language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
- "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
"account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
- "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
- "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
"def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"allow_cid" => array("type" => "mediumtext"),
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"parameter" => array("type" => "text"),
"priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
- "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
- "executed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
),
"indexes" => array(
"PRIMARY" => array("id"),
function onepoll_run(&$argv, &$argc){
global $a, $db;
- if(is_null($a)) {
+ if (is_null($a)) {
$a = new App;
}
- if(is_null($db)) {
+ if (is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
$force = false;
$restart = false;
- if(($argc > 1) && (intval($argv[1])))
+ if (($argc > 1) && (intval($argv[1]))) {
$contact_id = intval($argv[1]);
+ }
- if(($argc > 2) && ($argv[2] == "force"))
+ if (($argc > 2) && ($argv[2] == "force")) {
$force = true;
+ }
- if(! $contact_id) {
+ if (! $contact_id) {
logger('onepoll: no contact');
return;
}
// Don't check this stuff if the function is called by the poller
- if (App::callstack() != "poller_run")
- if (App::is_already_running('onepoll'.$contact_id, '', 540))
+ if (App::callstack() != "poller_run") {
+ if (App::is_already_running('onepoll'.$contact_id, '', 540)) {
return;
+ }
+ }
$d = datetime_convert();
intval($contact_id)
);
- if(! count($contacts))
+ if (! count($contacts)) {
return;
+ }
$contact = $contacts[0];
where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
intval($contact['id'])
);
- if (dbm::is_result($r))
- if (!$r[0]['total'])
+ if (dbm::is_result($r)) {
+ if (!$r[0]['total']) {
poco_load($contact['id'],$importer_uid,0,$contact['poco']);
+ }
+ }
}
/// @TODO Check why we don't poll the Diaspora feed at the moment (some guid problem in the items?)
$t = $contact['last-update'];
- if($contact['subhub']) {
+ if ($contact['subhub']) {
$poll_interval = get_config('system','pushpoll_frequency');
$contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
$hub_update = false;
- if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day"))
- $hub_update = true;
- }
- else
+ if (datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) {
+ $hub_update = true;
+ }
+ } else {
$hub_update = false;
-
+ }
$importer_uid = $contact['uid'];
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
intval($importer_uid)
);
- if (! dbm::is_result($r)) {
+ if (!dbm::is_result($r)) {
return;
}
logger("onepoll: poll: ({$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}");
- $last_update = (($contact['last-update'] === '0000-00-00 00:00:00')
+ $last_update = (($contact['last-update'] <= NULL_DATE)
? datetime_convert('UTC','UTC','now - 7 days', ATOM_TIME)
: datetime_convert('UTC','UTC',$contact['last-update'], ATOM_TIME)
);
// Update the contact entry
- if(($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_DFRN)) {
+ if (($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_DFRN)) {
if (!poco_reachable($contact['url'])) {
logger("Skipping probably dead contact ".$contact['url']);
return;
if (!update_contact($contact["id"])) {
mark_for_death($contact);
return;
- } else
+ } else {
unmark_for_death($contact);
+ }
}
- if($contact['network'] === NETWORK_DFRN) {
+ if ($contact['network'] === NETWORK_DFRN) {
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
- if(intval($contact['duplex']) && $contact['dfrn-id'])
+ if (intval($contact['duplex']) && $contact['dfrn-id']) {
$idtosend = '0:' . $orig_id;
- if(intval($contact['duplex']) && $contact['issued-id'])
+ }
+ if (intval($contact['duplex']) && $contact['issued-id']) {
$idtosend = '1:' . $orig_id;
+ }
// they have permission to write to us. We already filtered this in the contact query.
$perm = 'rw';
// But this may be our first communication, so set the writable flag if it isn't set already.
- if(! intval($contact['writable']))
+ if (! intval($contact['writable'])) {
q("update contact set writable = 1 where id = %d", intval($contact['id']));
-
+ }
$url = $contact['poll'] . '?dfrn_id=' . $idtosend
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION
. '&type=data&last_update=' . $last_update
. '&perm=' . $perm ;
- $handshake_xml = fetch_url($url);
+ $ret = z_fetch_url($url);
+
+ if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
+ return;
+ }
+
+ $handshake_xml = $ret['body'];
+
$html_code = $a->get_curl_code();
logger('onepoll: handshake with url ' . $url . ' returns xml: ' . $handshake_xml, LOGGER_DATA);
- if((! strlen($handshake_xml)) || ($html_code >= 400) || (! $html_code)) {
+ if ((! strlen($handshake_xml)) || ($html_code >= 400) || (! $html_code)) {
logger("poller: $url appears to be dead - marking for death ");
// dead connection - might be a transient event, or this might
return;
}
- if(! strstr($handshake_xml,'<')) {
+ if (! strstr($handshake_xml,'<')) {
logger('poller: response from ' . $url . ' did not contain XML.');
mark_for_death($contact);
$res = parse_xml_string($handshake_xml);
- if(intval($res->status) == 1) {
+ if (intval($res->status) == 1) {
logger("poller: $url replied status 1 - marking for death ");
// we may not be friends anymore. Will keep trying for one month.
intval($contact['id'])
);
mark_for_death($contact);
- }
- else {
- if ($contact['term-date'] > NULL_DATE) {
- logger("poller: $url back from the dead - removing mark for death");
- unmark_for_death($contact);
- }
- } elseif ($contact['term-date'] != '0000-00-00 00:00:00') {
++ } elseif ($contact['term-date'] > NULL_DATE) {
+ logger("poller: $url back from the dead - removing mark for death");
+ unmark_for_death($contact);
}
- if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id)))
+ if ((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id))) {
return;
+ }
- if(((float) $res->dfrn_version > 2.21) && ($contact['poco'] == '')) {
+ if (((float) $res->dfrn_version > 2.21) && ($contact['poco'] == '')) {
q("update contact set poco = '%s' where id = %d",
dbesc(str_replace('/profile/','/poco/', $contact['url'])),
intval($contact['id'])
$final_dfrn_id = '';
- if(($contact['duplex']) && strlen($contact['prvkey'])) {
+ if (($contact['duplex']) && strlen($contact['prvkey'])) {
openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']);
openssl_private_decrypt($challenge,$postvars['challenge'],$contact['prvkey']);
- }
- else {
+ } else {
openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']);
openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']);
}
$final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
- if(strpos($final_dfrn_id,':') == 1)
+ if (strpos($final_dfrn_id,':') == 1) {
$final_dfrn_id = substr($final_dfrn_id,2);
+ }
- if($final_dfrn_id != $orig_id) {
+ if ($final_dfrn_id != $orig_id) {
logger('poller: ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
// did not decode properly - cannot trust this site
return;
$xml = post_url($contact['poll'],$postvars);
- }
- elseif(($contact['network'] === NETWORK_OSTATUS)
+ } elseif (($contact['network'] === NETWORK_OSTATUS)
|| ($contact['network'] === NETWORK_DIASPORA)
- || ($contact['network'] === NETWORK_FEED) ) {
+ || ($contact['network'] === NETWORK_FEED)) {
// Upgrading DB fields from an older Friendica version
// Will only do this once per notify-enabled OStatus contact
$stat_writeable = ((($contact['notify']) && ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['rel'] == CONTACT_IS_FRIEND)) ? 1 : 0);
// Contacts from OStatus are always writable
- if($contact['network'] === NETWORK_OSTATUS)
+ if ($contact['network'] === NETWORK_OSTATUS) {
$stat_writeable = 1;
+ }
- if($stat_writeable != $contact['writable']) {
+ if ($stat_writeable != $contact['writable']) {
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d",
intval($stat_writeable),
intval($contact['id'])
// Are we allowed to import from this person?
- if($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly'])
+ if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly']) {
return;
+ }
$cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
- $xml = fetch_url($contact['poll'], false, $redirects, 0, Null, $cookiejar);
+ $ret = z_fetch_url($contact['poll'], false, $redirects, array('cookiejar' => $cookiejar));
+
+ if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
+ return;
+ }
+
+ $xml = $ret['body'];
+
unlink($cookiejar);
- }
- elseif($contact['network'] === NETWORK_MAIL || $contact['network'] === NETWORK_MAIL2) {
+ } elseif ($contact['network'] === NETWORK_MAIL || $contact['network'] === NETWORK_MAIL2) {
logger("Mail: Fetching", LOGGER_DEBUG);
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
- if($mail_disabled)
+ if ($mail_disabled)
return;
logger("Mail: Enabled", LOGGER_DEBUG);
$mailconf = q("SELECT * FROM `mailacct` WHERE `server` != '' AND `uid` = %d LIMIT 1",
intval($importer_uid)
);
- if(count($x) && count($mailconf)) {
+ if (count($x) && count($mailconf)) {
$mailbox = construct_mailbox_name($mailconf[0]);
$password = '';
openssl_private_decrypt(hex2bin($mailconf[0]['pass']),$password,$x[0]['prvkey']);
$mbox = email_connect($mailbox,$mailconf[0]['user'],$password);
unset($password);
logger("Mail: Connect to " . $mailconf[0]['user']);
- if($mbox) {
+ if ($mbox) {
q("UPDATE `mailacct` SET `last_check` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc(datetime_convert()),
intval($mailconf[0]['id']),
intval($importer_uid)
);
logger("Mail: Connected to " . $mailconf[0]['user']);
- } else
+ } else {
logger("Mail: Connection error ".$mailconf[0]['user']." ".print_r(imap_errors(), true));
+ }
}
- if($mbox) {
+ if ($mbox) {
$msgs = email_poll($mbox,$contact['addr']);
- if(count($msgs)) {
+ if (count($msgs)) {
logger("Mail: Parsing ".count($msgs)." mails for ".$mailconf[0]['user'], LOGGER_DEBUG);
$metas = email_msg_meta($mbox,implode(',',$msgs));
- if(count($metas) != count($msgs)) {
+ if (count($metas) != count($msgs)) {
logger("onepoll: for " . $mailconf[0]['user'] . " there are ". count($msgs) . " messages but received " . count($metas) . " metas", LOGGER_DEBUG);
- }
- else {
+ } else {
$msgs = array_combine($msgs, $metas);
- foreach($msgs as $msg_uid => $meta) {
+ foreach ($msgs as $msg_uid => $meta) {
logger("Mail: Parsing mail ".$msg_uid, LOGGER_DATA);
$datarray = array();
// Only delete when mails aren't automatically moved or deleted
if (($mailconf[0]['action'] != 1) AND ($mailconf[0]['action'] != 3))
- if($meta->deleted && ! $r[0]['deleted']) {
+ if ($meta->deleted && ! $r[0]['deleted']) {
q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()),
intval($r[0]['id'])
// $raw_refs = ((x($headers,'references')) ? str_replace("\t",'',$headers['references']) : '');
$raw_refs = ((property_exists($meta,'references')) ? str_replace("\t",'',$meta->references) : '');
- if(! trim($raw_refs))
+ if (! trim($raw_refs))
$raw_refs = ((property_exists($meta,'in_reply_to')) ? str_replace("\t",'',$meta->in_reply_to) : '');
$raw_refs = trim($raw_refs); // Don't allow a blank reference in $refs_arr
- if($raw_refs) {
+ if ($raw_refs) {
$refs_arr = explode(' ', $raw_refs);
- if(count($refs_arr)) {
+ if (count($refs_arr)) {
for($x = 0; $x < count($refs_arr); $x ++)
$refs_arr[$x] = "'" . msgid2iri(str_replace(array('<','>',' '),array('','',''),dbesc($refs_arr[$x]))) . "'";
}
// Decoding the header
$subject = imap_mime_header_decode($meta->subject);
$datarray['title'] = "";
- foreach($subject as $subpart)
- if ($subpart->charset != "default")
+ foreach ($subject as $subpart) {
+ if ($subpart->charset != "default") {
$datarray['title'] .= iconv($subpart->charset, 'UTF-8//IGNORE', $subpart->text);
- else
+ } else {
$datarray['title'] .= $subpart->text;
-
+ }
+ }
$datarray['title'] = notags(trim($datarray['title']));
//$datarray['title'] = notags(trim($meta->subject));
$datarray['title'] = RemoveReply($datarray['title']);
// If it seems to be a reply but a header couldn't be found take the last message with matching subject
- if(!x($datarray,'parent-uri') and $reply) {
+ if (!x($datarray,'parent-uri') and $reply) {
$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `title` = \"%s\" AND `uid` = %d AND `network` = '%s' ORDER BY `created` DESC LIMIT 1",
dbesc(protect_sprintf($datarray['title'])),
intval($importer_uid),
$datarray['parent-uri'] = $r[0]['parent-uri'];
}
- if(! x($datarray,'parent-uri'))
+ if (! x($datarray,'parent-uri'))
$datarray['parent-uri'] = $datarray['uri'];
$r = email_get_msg($mbox,$msg_uid, $reply);
- if(! $r) {
+ if (! $r) {
logger("Mail: can't fetch msg ".$msg_uid." for ".$mailconf[0]['user']);
continue;
}
// some mailing lists have the original author as 'from' - add this sender info to msg body.
/// @TODO Adding a gravatar for the original author would be cool
- if(! stristr($meta->from,$contact['addr'])) {
+ if (! stristr($meta->from,$contact['addr'])) {
$from = imap_mime_header_decode($meta->from);
$fromdecoded = "";
- foreach($from as $frompart)
- if ($frompart->charset != "default")
+ foreach ($from as $frompart) {
+ if ($frompart->charset != "default") {
$fromdecoded .= iconv($frompart->charset, 'UTF-8//IGNORE', $frompart->text);
- else
+ } else {
$fromdecoded .= $frompart->text;
+ }
+ }
$fromarr = imap_rfc822_parse_adrlist($fromdecoded, $a->get_hostname());
$frommail = $fromarr[0]->mailbox."@".$fromarr[0]->host;
- if (isset($fromarr[0]->personal))
+ if (isset($fromarr[0]->personal)) {
$fromname = $fromarr[0]->personal;
- else
+ } else {
$fromname = $frommail;
+ }
//$datarray['body'] = "[b]".t('From: ') . escape_tags($fromdecoded) . "[/b]\n\n" . $datarray['body'];
$datarray['uid'] = $importer_uid;
$datarray['contact-id'] = $contact['id'];
- if($datarray['parent-uri'] === $datarray['uri'])
+ if ($datarray['parent-uri'] === $datarray['uri'])
$datarray['private'] = 1;
- if(($contact['network'] === NETWORK_MAIL) && (! get_pconfig($importer_uid,'system','allow_public_email_replies'))) {
+ if (($contact['network'] === NETWORK_MAIL) && (! get_pconfig($importer_uid,'system','allow_public_email_replies'))) {
$datarray['private'] = 1;
$datarray['allow_cid'] = '<' . $contact['id'] . '>';
}
}
}
}
- } else
+ } else {
logger("Mail: no mails for ".$mailconf[0]['user']);
+ }
logger("Mail: closing connection for ".$mailconf[0]['user']);
imap_close($mbox);
}
- }
- elseif($contact['network'] === NETWORK_FACEBOOK) {
+ } elseif ($contact['network'] === NETWORK_FACEBOOK) {
// This is picked up by the Facebook plugin on a cron hook.
// Ignored here.
- } elseif($contact['network'] === NETWORK_PUMPIO) {
+ } elseif ($contact['network'] === NETWORK_PUMPIO) {
// This is picked up by the pump.io plugin on a cron hook.
// Ignored here.
}
- if($xml) {
+ if ($xml) {
logger('poller: received xml : ' . $xml, LOGGER_DATA);
- if(! strstr($xml,'<')) {
+ if (! strstr($xml,'<')) {
logger('poller: post_handshake: response from ' . $url . ' did not contain XML.');
$r = q("UPDATE `contact` SET `last-update` = '%s', `failure_update` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()),
consume_feed($xml,$importer,$contact,$hub,1,2);
$hubmode = 'subscribe';
- if($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly'])
+ if ($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly'])
$hubmode = 'unsubscribe';
- if(($contact['network'] === NETWORK_OSTATUS || $contact['network'] == NETWORK_FEED) && (! $contact['hub-verify']))
+ if (($contact['network'] === NETWORK_OSTATUS || $contact['network'] == NETWORK_FEED) && (! $contact['hub-verify']))
$hub_update = true;
if ($force)
logger("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update);
- if((strlen($hub)) && ($hub_update) && (($contact['rel'] != CONTACT_IS_FOLLOWER) || $contact['network'] == NETWORK_FEED) ) {
+ if ((strlen($hub)) && ($hub_update) && (($contact['rel'] != CONTACT_IS_FOLLOWER) || $contact['network'] == NETWORK_FEED) ) {
logger('poller: hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
$hubs = explode(',', $hub);
- if(count($hubs)) {
- foreach($hubs as $h) {
+ if (count($hubs)) {
+ foreach ($hubs as $h) {
$h = trim($h);
- if(! strlen($h))
+ if (! strlen($h)) {
continue;
+ }
subscribe_to_hub($h,$importer,$contact,$hubmode);
}
}
return;
}
- if (array_search(__file__,get_included_files())===0){
+ if (array_search(__file__,get_included_files())===0) {
onepoll_run($_SERVER["argv"],$_SERVER["argc"]);
killme();
}
$duration = number_format(microtime(true) - $stamp, 3);
+ if ($duration > 3600) {
+ logger("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 1 hour (".round($duration/60, 3).")", LOGGER_DEBUG);
+ } elseif ($duration > 600) {
+ logger("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 10 minutes (".round($duration/60, 3).")", LOGGER_DEBUG);
+ } elseif ($duration > 300) {
+ logger("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 5 minutes (".round($duration/60, 3).")", LOGGER_DEBUG);
+ } elseif ($duration > 120) {
+ logger("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 2 minutes (".round($duration/60, 3).")", LOGGER_DEBUG);
+ }
+
logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - done in ".$duration." seconds.");
// Write down the performance values into the log
*
*/
function poller_kill_stale_workers() {
- $r = q("SELECT `pid`, `executed`, `priority`, `parameter` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'");
+ $r = q("SELECT `pid`, `executed`, `priority`, `parameter` FROM `workerqueue` WHERE `executed` > '%s'", dbesc(NULL_DATE));
if (!dbm::is_result($r)) {
// No processing here needed
foreach($r AS $pid)
if (!posix_kill($pid["pid"], 0))
- q("UPDATE `workerqueue` SET `executed` = '0000-00-00 00:00:00', `pid` = 0 WHERE `pid` = %d",
- intval($pid["pid"]));
+ q("UPDATE `workerqueue` SET `executed` = '%s', `pid` = 0 WHERE `pid` = %d",
+ dbesc(NULL_DATE), intval($pid["pid"]));
else {
// Kill long running processes
// We killed the stale process.
// To avoid a blocking situation we reschedule the process at the beginning of the queue.
// Additionally we are lowering the priority.
- q("UPDATE `workerqueue` SET `executed` = '0000-00-00 00:00:00', `created` = '%s',
+ q("UPDATE `workerqueue` SET `executed` = '%s', `created` = '%s',
`priority` = %d, `pid` = 0 WHERE `pid` = %d",
+ dbesc(NULL_DATE),
dbesc(datetime_convert()),
intval(PRIORITY_NEGLIGIBLE),
intval($pid["pid"]));
$slope = $maxworkers / pow($maxsysload, $exponent);
$queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
- $s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00'");
+ $s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` <= '%s'", dbesc(NULL_DATE));
$entries = $s[0]["total"];
if (Config::get("system", "worker_fastlane", false) AND ($queues > 0) AND ($entries > 0) AND ($active >= $queues)) {
- $s = q("SELECT `priority` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `priority` LIMIT 1");
+ $s = q("SELECT `priority` FROM `workerqueue` WHERE `executed` <= '%s' ORDER BY `priority` LIMIT 1", dbesc(NULL_DATE));
$top_priority = $s[0]["priority"];
- $s = q("SELECT `id` FROM `workerqueue` WHERE `priority` <= %d AND `executed` != '0000-00-00 00:00:00' LIMIT 1",
- intval($top_priority));
+ $s = q("SELECT `id` FROM `workerqueue` WHERE `priority` <= %d AND `executed` > '%s' LIMIT 1",
+ intval($top_priority), dbesc(NULL_DATE));
$high_running = dbm::is_result($s);
if (!$high_running AND ($top_priority > PRIORITY_UNDEFINED) AND ($top_priority < PRIORITY_NEGLIGIBLE)) {
if (poller_passing_slow($highest_priority)) {
// Are there waiting processes with a higher priority than the currently highest?
$r = q("SELECT * FROM `workerqueue`
- WHERE `executed` = '0000-00-00 00:00:00' AND `priority` < %d
- ORDER BY `priority`, `created` LIMIT 1", dbesc($highest_priority));
+ WHERE `executed` <= '%s' AND `priority` < %d
+ ORDER BY `priority`, `created` LIMIT 1",
+ dbesc(NULL_DATE),
+ intval($highest_priority));
if (dbm::is_result($r))
return $r;
// Give slower processes some processing time
$r = q("SELECT * FROM `workerqueue`
- WHERE `executed` = '0000-00-00 00:00:00' AND `priority` > %d
- ORDER BY `priority`, `created` LIMIT 1", dbesc($highest_priority));
+ WHERE `executed` <= '%s' AND `priority` > %d
+ ORDER BY `priority`, `created` LIMIT 1",
+ dbesc(NULL_DATE),
+ intval($highest_priority));
}
// If there is no result (or we shouldn't pass lower processes) we check without priority limit
if (($highest_priority == 0) OR !dbm::is_result($r))
- $r = q("SELECT * FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `priority`, `created` LIMIT 1");
+ $r = q("SELECT * FROM `workerqueue` WHERE `executed` <= '%s' ORDER BY `priority`, `created` LIMIT 1", dbesc(NULL_DATE));
return $r;
}
$connect_url = '';
$name = '';
$network = '';
- $updated = '0000-00-00 00:00:00';
+ $updated = NULL_DATE;
$location = '';
$about = '';
$keywords = '';
if (($network == "") AND ($x[0]["network"] != NETWORK_STATUSNET))
$network = $x[0]["network"];
- if ($updated == "0000-00-00 00:00:00")
+ if ($updated <= NULL_DATE)
$updated = $x[0]["updated"];
$created = $x[0]["created"];
$alias = $x[0]["alias"];
$notify = $x[0]["notify"];
} else {
- $created = "0000-00-00 00:00:00";
+ $created = NULL_DATE;
$server_url = "";
$urlparts = parse_url($profile_url);
$gcontacts = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s'",
dbesc(normalise_link($profile)));
- if ($gcontacts[0]["created"] == "0000-00-00 00:00:00")
+ if ($gcontacts[0]["created"] <= NULL_DATE)
q("UPDATE `gcontact` SET `created` = '%s' WHERE `nurl` = '%s'",
dbesc(datetime_convert()), dbesc(normalise_link($profile)));
// Maybe there aren't any entries. Then check if it is a valid feed
if ($last_updated == "")
if ($xpath->query('/atom:feed')->length > 0)
- $last_updated = "0000-00-00 00:00:00";
+ $last_updated = NULL_DATE;
q("UPDATE `gcontact` SET `updated` = '%s', `last_contact` = '%s' WHERE `nurl` = '%s'",
dbesc(dbm::date($last_updated)), dbesc(dbm::date()), dbesc(normalise_link($profile)));
return false;
$servers = q("SELECT * FROM `gserver` WHERE `nurl` = '%s'", dbesc(normalise_link($server_url)));
- if ($servers) {
+ if (dbm::is_result($servers)) {
- if ($servers[0]["created"] == "0000-00-00 00:00:00")
+ if ($servers[0]["created"] <= NULL_DATE)
q("UPDATE `gserver` SET `created` = '%s' WHERE `nurl` = '%s'",
dbesc(datetime_convert()), dbesc(normalise_link($server_url)));
$info = "";
$register_policy = -1;
- $last_contact = "0000-00-00 00:00:00";
- $last_failure = "0000-00-00 00:00:00";
+ $last_contact = NULL_DATE;
+ $last_failure = NULL_DATE;
}
logger("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$servers[0]["created"]." Failure: ".$last_failure." Contact: ".$last_contact, LOGGER_DEBUG);
$orig_last_failure = $last_failure;
// Check if the page is accessible via SSL.
+ $orig_server_url = $server_url;
$server_url = str_replace("http://", "https://", $server_url);
- $serverret = z_fetch_url($server_url."/.well-known/host-meta");
+
+ // We set the timeout to 20 seconds since this operation should be done in no time if the server was vital
+ $serverret = z_fetch_url($server_url."/.well-known/host-meta", false, $redirects, array('timeout' => 20));
+
+ // Quit if there is a timeout.
+ // But we want to make sure to only quit if we are mostly sure that this server url fits.
+ if (dbm::is_result($servers) AND ($orig_server_url == $server_url) AND
+ ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
+ logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
+ return false;
+ }
// Maybe the page is unencrypted only?
$xmlobj = @simplexml_load_string($serverret["body"],'SimpleXMLElement',0, "http://docs.oasis-open.org/ns/xri/xrd-1.0");
if (!$serverret["success"] OR ($serverret["body"] == "") OR (@sizeof($xmlobj) == 0) OR !is_object($xmlobj)) {
$server_url = str_replace("https://", "http://", $server_url);
- $serverret = z_fetch_url($server_url."/.well-known/host-meta");
+
+ // We set the timeout to 20 seconds since this operation should be done in no time if the server was vital
+ $serverret = z_fetch_url($server_url."/.well-known/host-meta", false, $redirects, array('timeout' => 20));
+
+ // Quit if there is a timeout
+ if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
+ logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
+ return false;
+ }
$xmlobj = @simplexml_load_string($serverret["body"],'SimpleXMLElement',0, "http://docs.oasis-open.org/ns/xri/xrd-1.0");
}
if (!$serverret["success"] OR ($serverret["body"] == "") OR (sizeof($xmlobj) == 0) OR !is_object($xmlobj)) {
// Workaround for bad configured servers (known nginx problem)
- if ($serverret["debug"]["http_code"] != "403") {
+ if (!in_array($serverret["debug"]["http_code"], array("403", "404"))) {
$last_failure = datetime_convert();
$failure = true;
}
where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d )
AND NOT `gcontact`.`name` IN (SELECT `name` FROM `contact` WHERE `uid` = %d)
AND NOT `gcontact`.`id` IN (SELECT `gcid` FROM `gcign` WHERE `uid` = %d)
- AND `gcontact`.`updated` != '0000-00-00 00:00:00'
+ AND `gcontact`.`updated` >= '%s'
AND `gcontact`.`last_contact` >= `gcontact`.`last_failure`
AND `gcontact`.`network` IN (%s)
GROUP BY `glink`.`gcid` ORDER BY `gcontact`.`updated` DESC,`total` DESC LIMIT %d, %d",
intval($uid),
intval($uid),
intval($uid),
+ dbesc(NULL_DATE),
$sql_network,
intval($start),
intval($limit)
WHERE `glink`.`uid` = 0 AND `glink`.`cid` = 0 AND `glink`.`zcid` = 0 AND NOT `gcontact`.`nurl` IN (SELECT `nurl` FROM `contact` WHERE `uid` = %d)
AND NOT `gcontact`.`name` IN (SELECT `name` FROM `contact` WHERE `uid` = %d)
AND NOT `gcontact`.`id` IN (SELECT `gcid` FROM `gcign` WHERE `uid` = %d)
- AND `gcontact`.`updated` != '0000-00-00 00:00:00'
+ AND `gcontact`.`updated` >= '%s'
AND `gcontact`.`last_contact` >= `gcontact`.`last_failure`
AND `gcontact`.`network` IN (%s)
ORDER BY rand() LIMIT %d, %d",
intval($uid),
intval($uid),
intval($uid),
+ dbesc(NULL_DATE),
$sql_network,
intval($start),
intval($limit)
$connect_url = '';
$name = '';
$network = '';
- $updated = '0000-00-00 00:00:00';
+ $updated = NULL_DATE;
$location = '';
$about = '';
$keywords = '';
<?php
- define('UPDATE_VERSION' , 1214);
+ define('UPDATE_VERSION' , 1215);
/**
*
q("ALTER TABLE `intro` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `knowyou` ");
q("ALTER TABLE `contact` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `rel` ");
- q("ALTER TABLE `contact` CHANGE `issued-pubkey` `issued-pubkey` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
- q("ALTER TABLE `contact` ADD `term-date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `avatar-date`");
+ q("ALTER TABLE `contact` CHANGE `issued-pubkey` `issued-pubkey` TEXTCHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
+ q("ALTER TABLE `contact` ADD `term-date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `avatar-date`");
}
function update_1001() {
}
function update_1023() {
- q("ALTER TABLE `user` ADD `register_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `timezone` ,
- ADD `login_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `register_date` ");
+ q("ALTER TABLE `user` ADD `register_date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `timezone` ,
+ ADD `login_date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `register_date` ");
}
function update_1024() {
function update_1035() {
- q("ALTER TABLE `contact` ADD `success_update` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `last-update` ");
+ q("ALTER TABLE `contact` ADD `success_update` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `last-update` ");
}
`user` CHAR( 255 ) NOT NULL ,
`pass` CHAR( 255 ) NOT NULL ,
`reply_to` CHAR( 255 ) NOT NULL ,
- `last_check` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
+ `last_check` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00'
) ENGINE = MYISAM ");
}
`filetype` CHAR( 64 ) NOT NULL ,
`filesize` INT NOT NULL ,
`data` LONGBLOB NOT NULL ,
- `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
- `edited` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00',
+ `edited` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00',
`allow_cid` MEDIUMTEXT NOT NULL ,
`allow_gid` MEDIUMTEXT NOT NULL ,
`deny_cid` MEDIUMTEXT NOT NULL ,
}
function update_1066() {
- $r = q("ALTER TABLE `item` ADD `received` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `edited` ");
+ $r = q("ALTER TABLE `item` ADD `received` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `edited` ");
if($r)
q("ALTER TABLE `item` ADD INDEX ( `received` ) ");
}
function update_1080() {
- q("ALTER TABLE `fcontact` ADD `updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'");
+ q("ALTER TABLE `fcontact` ADD `updated` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00'");
}
function update_1081() {
}
function update_1087() {
- q("ALTER TABLE `item` ADD `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `edited` ");
+ q("ALTER TABLE `item` ADD `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `edited` ");
$r = q("SELECT `id` FROM `item` WHERE `parent` = `id` ");
if (dbm::is_result($r)) {
function update_1088() {
q("ALTER TABLE `user` ADD `account_expired` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `expire` ,
- ADD `account_expires_on` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `account_expired` ,
- ADD `expire_notification_sent` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `account_expires_on` ");
+ ADD `account_expires_on` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `account_expired` ,
+ ADD `expire_notification_sent` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `account_expires_on` ");
}
function update_1089() {
function update_1109() {
q("ALTER TABLE `conv` ADD `creator` CHAR( 255 ) NOT NULL ,
- ADD `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
- ADD `updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ ADD `created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00',
+ ADD `updated` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00',
ADD `subject` MEDIUMTEXT NOT NULL,
ADD INDEX ( `created` ), ADD INDEX ( `updated` ) ");
}
function update_1128() {
- q("alter table spam add `date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `term` ");
+ q("alter table spam add `date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `term` ");
}
function update_1129() {
}
function update_1145() {
- $r = q("alter table profile add howlong datetime not null default '0000-00-00 00:00:00' after `with`");
+ $r = q("alter table profile add howlong datetime not null default '0001-01-01 00:00:00' after `with`");
if(! $r)
return UPDATE_FAILED ;
return UPDATE_SUCCESS ;
`iid` int(10) unsigned NOT NULL DEFAULT '0',
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`contact-id` int(11) unsigned NOT NULL DEFAULT '0',
- `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
- `edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
- `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
- `received` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
- `changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
+ `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
+ `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
+ `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
+ `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
`wall` tinyint(1) NOT NULL DEFAULT '0',
`private` tinyint(1) NOT NULL DEFAULT '0',
`pubmail` tinyint(1) NOT NULL DEFAULT '0',