And again ...

This commit is contained in:
Michael Vogel 2016-10-22 10:33:18 +00:00
parent 66da84d1a9
commit 561f45b83b
2 changed files with 22 additions and 22 deletions

View File

@ -100,8 +100,7 @@ class Config {
$a->config[$family][$key] = $val; $a->config[$family][$key] = $val;
return $val; return $val;
} } else {
else {
$a->config[$family][$key] = '!<unset>!'; $a->config[$family][$key] = '!<unset>!';
} }
return $default_value; return $default_value;
@ -126,19 +125,19 @@ class Config {
public static function set($family, $key, $value) { public static function set($family, $key, $value) {
global $a; global $a;
$stored = self::get($family, $key);
if ($stored == $value) {
return true;
}
$a->config[$family][$key] = $value; $a->config[$family][$key] = $value;
// manage array value // manage array value
$dbvalue = (is_array($value) ? serialize($value):$value); $dbvalue = (is_array($value) ? serialize($value):$value);
$dbvalue = (is_bool($dbvalue) ? intval($dbvalue) : $dbvalue); $dbvalue = (is_bool($dbvalue) ? intval($dbvalue) : $dbvalue);
// The "INSERT" command is very cost intense. It saves performance to do it this way. if (is_null($stored)) {
$ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s' ORDER BY `id` DESC LIMIT 1",
dbesc($family),
dbesc($key)
);
if (!$ret) {
$ret = q("INSERT INTO `config` (`cat`, `k`, `v`) VALUES ('%s', '%s', '%s') ON DUPLICATE KEY UPDATE `v` = '%s'", $ret = q("INSERT INTO `config` (`cat`, `k`, `v`) VALUES ('%s', '%s', '%s') ON DUPLICATE KEY UPDATE `v` = '%s'",
dbesc($family), dbesc($family),
dbesc($key), dbesc($key),
@ -152,9 +151,9 @@ class Config {
dbesc($key) dbesc($key)
); );
} }
if ($ret) if ($ret) {
return $value; return $value;
}
return $ret; return $ret;
} }
@ -173,8 +172,9 @@ class Config {
public static function delete($family, $key) { public static function delete($family, $key) {
global $a; global $a;
if (x($a->config[$family],$key)) if (x($a->config[$family],$key)) {
unset($a->config[$family][$key]); unset($a->config[$family][$key]);
}
$ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s'", $ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s'",
dbesc($family), dbesc($family),
dbesc($key) dbesc($key)

View File

@ -19,7 +19,7 @@ function display_init(&$a) {
$r = qu("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item` $r = qu("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated` WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user()); AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
if (dbm::isresult($r)) { if (dbm::is_result($r)) {
$nick = $a->user["nickname"]; $nick = $a->user["nickname"];
$itemuid = local_user(); $itemuid = local_user();
} }
@ -35,7 +35,7 @@ function display_init(&$a) {
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND NOT `item`.`private` AND NOT `user`.`hidewall` AND NOT `item`.`private` AND NOT `user`.`hidewall`
AND `item`.`guid` = '%s'", dbesc($a->argv[1])); AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
if (dbm::isresult($r)) { if (dbm::is_result($r)) {
$nick = $r[0]["nickname"]; $nick = $r[0]["nickname"];
$itemuid = $r[0]["uid"]; $itemuid = $r[0]["uid"];
} }
@ -51,7 +51,7 @@ function display_init(&$a) {
AND NOT `item`.`private` AND `item`.`uid` = 0 AND NOT `item`.`private` AND `item`.`uid` = 0
AND `item`.`guid` = '%s'", dbesc($a->argv[1])); AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
} }
if (dbm::isresult($r)) { if (dbm::is_result($r)) {
if ($r[0]["id"] != $r[0]["parent"]) { if ($r[0]["id"] != $r[0]["parent"]) {
$r = qu("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item` $r = qu("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated` WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
@ -90,7 +90,7 @@ function display_init(&$a) {
WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` AND `contact`.`self` LIMIT 1", WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` AND `contact`.`self` LIMIT 1",
dbesc($nickname) dbesc($nickname)
); );
if (dbm::isresult($r)) { if (dbm::is_result($r)) {
$profiledata = $r[0]; $profiledata = $r[0];
} }
$profiledata["network"] = NETWORK_DFRN; $profiledata["network"] = NETWORK_DFRN;
@ -128,7 +128,7 @@ function display_fetchauthor($a, $item) {
// Skip if it isn't a pure repeated messages // Skip if it isn't a pure repeated messages
// Does it start with a share? // Does it start with a share?
if (!$skip AND strpos($body, "[share") > 0) } if (!$skip AND strpos($body, "[share") > 0) {
$skip = true; $skip = true;
} }
// Does it end with a share? // Does it end with a share?
@ -230,7 +230,7 @@ function display_content(&$a, $update = 0) {
$r = qu("SELECT `id` FROM `item` $r = qu("SELECT `id` FROM `item`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated` WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user()); AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
if (dbm::isresult($r)) { if (dbm::is_result($r)) {
$item_id = $r[0]["id"]; $item_id = $r[0]["id"];
$nick = $a->user["nickname"]; $nick = $a->user["nickname"];
} }
@ -244,7 +244,7 @@ function display_content(&$a, $update = 0) {
AND NOT `item`.`private` AND NOT `user`.`hidewall` AND NOT `item`.`private` AND NOT `user`.`hidewall`
AND `item`.`guid` = '%s'", dbesc($a->argv[1])); AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND NOT `item`.`private` AND `item`.`wall` // AND NOT `item`.`private` AND `item`.`wall`
if (dbm::isresult($r)) { if (dbm::is_result($r)) {
$item_id = $r[0]["id"]; $item_id = $r[0]["id"];
$nick = $r[0]["nickname"]; $nick = $r[0]["nickname"];
} }
@ -257,7 +257,7 @@ function display_content(&$a, $update = 0) {
AND NOT `item`.`private` AND `item`.`uid` = 0 AND NOT `item`.`private` AND `item`.`uid` = 0
AND `item`.`guid` = '%s'", dbesc($a->argv[1])); AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND NOT `item`.`private` AND `item`.`wall` // AND NOT `item`.`private` AND `item`.`wall`
if (dbm::isresult($r)) { if (dbm::is_result($r)) {
$item_id = $r[0]["id"]; $item_id = $r[0]["id"];
} }
} }
@ -303,7 +303,7 @@ function display_content(&$a, $update = 0) {
intval($contact_id), intval($contact_id),
intval($a->profile['uid']) intval($a->profile['uid'])
); );
if (dbm::isresult($r)) { if (dbm::is_result($r)) {
$contact = $r[0]; $contact = $r[0];
$remote_contact = true; $remote_contact = true;
} }
@ -319,7 +319,7 @@ function display_content(&$a, $update = 0) {
$r = qu("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", $r = qu("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval($a->profile['uid']) intval($a->profile['uid'])
); );
if (dbm::isresult($r)) { if (dbm::is_result($r)) {
$a->page_contact = $r[0]; $a->page_contact = $r[0];
} }
$is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false); $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);