aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/bbcode.php12
-rw-r--r--include/config.php4
-rwxr-xr-xinclude/dba/dba_driver.php18
-rw-r--r--include/network.php2
-rw-r--r--include/photo/photo_driver.php305
-rw-r--r--include/photos.php20
-rw-r--r--include/text.php21
-rw-r--r--include/xchan.php130
-rw-r--r--include/zot.php37
9 files changed, 329 insertions, 220 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index 137e25a9c..c5d6ef998 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -1198,24 +1198,24 @@ function bbcode($Text, $options = []) {
// Images
// [img]pathtoimage[/img]
if (strpos($Text,'[/img]') !== false) {
- $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img style="max-width=100%;" src="$1" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img style="max-width: 100%;" src="$1" alt="' . t('Image/photo') . '" />', $Text);
}
if (strpos($Text,'[/zmg]') !== false) {
- $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img class="zrl" style="max-width=100%;" src="$1" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img class="zrl" style="max-width: 100%;" src="$1" alt="' . t('Image/photo') . '" />', $Text);
}
// [img float={left, right}]pathtoimage[/img]
if (strpos($Text,'[/img]') !== false) {
- $Text = preg_replace("/\[img float=left\](.*?)\[\/img\]/ism", '<img style="max-width=100%;" src="$1" style="float: left;" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[img float=left\](.*?)\[\/img\]/ism", '<img src="$1" style="max-width: 100%; float: left;" alt="' . t('Image/photo') . '" />', $Text);
}
if (strpos($Text,'[/img]') !== false) {
- $Text = preg_replace("/\[img float=right\](.*?)\[\/img\]/ism", '<img style="max-width=100%;" src="$1" style="float: right;" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[img float=right\](.*?)\[\/img\]/ism", '<img src="$1" style="max-width: 100%; float: right;" alt="' . t('Image/photo') . '" />', $Text);
}
if (strpos($Text,'[/zmg]') !== false) {
- $Text = preg_replace("/\[zmg float=left\](.*?)\[\/zmg\]/ism", '<img style="max-width=100%;" class="zrl" src="$1" style="float: left;" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[zmg float=left\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" style="max-width: 100%; float: left;" alt="' . t('Image/photo') . '" />', $Text);
}
if (strpos($Text,'[/zmg]') !== false) {
- $Text = preg_replace("/\[zmg float=right\](.*?)\[\/zmg\]/ism", '<img style="max-width=100%;" class="zrl" src="$1" style="float: right;" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[zmg float=right\](.*?)\[\/zmg\]/ism", '<img class="zrl" src="$1" style="max-width: 100%; float: right;" alt="' . t('Image/photo') . '" />', $Text);
}
// [img=widthxheight]pathtoimage[/img]
diff --git a/include/config.php b/include/config.php
index 0be791715..ec3547a82 100644
--- a/include/config.php
+++ b/include/config.php
@@ -59,8 +59,8 @@ function set_pconfig($uid, $family, $key, $value) {
return Zlib\PConfig::Set($uid,$family,$key,$value);
}
-function del_pconfig($uid, $family, $key) {
- return Zlib\PConfig::Delete($uid,$family,$key);
+function del_pconfig($uid, $family, $key, $updated = NULL) {
+ return Zlib\PConfig::Delete($uid,$family,$key,$updated);
}
function load_xconfig($xchan) {
diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php
index 9533acc7f..ee0e06a91 100755
--- a/include/dba/dba_driver.php
+++ b/include/dba/dba_driver.php
@@ -173,14 +173,14 @@ abstract class dba_driver {
return false;
}
- if(strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1') && (! strpbrk($server,':;'))) {
- if(! z_dns_check($server)) {
- $this->error = sprintf( t('Cannot locate DNS info for database server \'%s\''), $server);
- $this->connected = false;
- $this->db = null;
- return false;
- }
- }
+ // if(strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1') && (! strpbrk($server,':;'))) {
+ // if(! z_dns_check($server)) {
+ // $this->error = sprintf( t('Cannot locate DNS info for database server \'%s\''), $server);
+ // $this->connected = false;
+ // $this->db = null;
+ // return false;
+ // }
+ // }
return true;
}
@@ -468,7 +468,7 @@ function db_columns($table) {
if(ACTIVE_DBTYPE === DBTYPE_POSTGRES) {
$r = q("SELECT column_name as field FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '%s'",
dbesc($table)
- );
+ );
if($r) {
return ids_to_array($r,'field');
}
diff --git a/include/network.php b/include/network.php
index f976dcc35..d37da05f7 100644
--- a/include/network.php
+++ b/include/network.php
@@ -233,7 +233,7 @@ function z_post_url($url, $params, $redirects = 0, $opts = array()) {
return $ret;
if(! array_key_exists('request_target',$opts)) {
- $opts['request_target'] = 'get ' . get_request_string($url);
+ $opts['request_target'] = 'post ' . get_request_string($url);
}
@curl_setopt($ch, CURLOPT_HEADER, true);
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 2e2f5a758..4173d727e 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -350,8 +350,7 @@ abstract class photo_driver {
$p['allow_gid'] = (($arr['allow_gid']) ? $arr['allow_gid'] : '');
$p['deny_cid'] = (($arr['deny_cid']) ? $arr['deny_cid'] : '');
$p['deny_gid'] = (($arr['deny_gid']) ? $arr['deny_gid'] : '');
- $p['created'] = (($arr['created']) ? $arr['created'] : datetime_convert());
- $p['edited'] = (($arr['edited']) ? $arr['edited'] : $p['created']);
+ $p['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert());
$p['title'] = (($arr['title']) ? $arr['title'] : '');
$p['description'] = (($arr['description']) ? $arr['description'] : '');
$p['photo_usage'] = intval($arr['photo_usage']);
@@ -365,13 +364,15 @@ abstract class photo_driver {
if(! intval($p['imgscale']))
logger('save: ' . print_r($arr,true), LOGGER_DATA);
- $x = q("select id from photo where resource_id = '%s' and uid = %d and xchan = '%s' and imgscale = %d limit 1",
+ $x = q("select id, created from photo where resource_id = '%s' and uid = %d and xchan = '%s' and imgscale = %d limit 1",
dbesc($p['resource_id']),
intval($p['uid']),
dbesc($p['xchan']),
intval($p['imgscale'])
);
+
if($x) {
+ $p['created'] = (($x['created']) ? $x['created'] : $p['edited']);
$r = q("UPDATE photo set
aid = %d,
uid = %d,
@@ -427,6 +428,7 @@ abstract class photo_driver {
);
}
else {
+ $p['created'] = (($arr['created']) ? $arr['created'] : $p['edited']);
$r = q("INSERT INTO photo
( aid, uid, xchan, resource_id, created, edited, filename, mimetype, album, height, width, content, os_storage, filesize, imgscale, photo_usage, title, description, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
@@ -464,11 +466,6 @@ abstract class photo_driver {
-
-
-
-
-
/**
* Guess image mimetype from filename or from Content-Type header
*
@@ -485,11 +482,11 @@ function guess_image_type($filename, $headers = '') {
$h = explode("\n",$headers);
foreach ($h as $l) {
list($k,$v) = array_map("trim", explode(":", trim($l), 2));
- $hdrs[$k] = $v;
+ $hdrs[strtolower($k)] = $v;
}
logger('Curl headers: '.var_export($hdrs, true), LOGGER_DEBUG);
- if (array_key_exists('Content-Type', $hdrs))
- $type = $hdrs['Content-Type'];
+ if (array_key_exists('content-type', $hdrs))
+ $type = $hdrs['content-type'];
}
if (is_null($type)){
@@ -570,122 +567,166 @@ function delete_thing_photo($url,$ob_hash) {
-function import_xchan_photo($photo,$xchan,$thing = false) {
-
- $flags = (($thing) ? PHOTO_THING : PHOTO_XCHAN);
- $album = (($thing) ? 'Things' : 'Contact Photos');
-
- logger('import_xchan_photo: updating channel photo from ' . $photo . ' for ' . $xchan, LOGGER_DEBUG);
-
- if($thing)
- $hash = photo_new_resource();
- else {
- $r = q("select resource_id from photo where xchan = '%s' and photo_usage = %d and imgscale = 4 limit 1",
- dbesc($xchan),
- intval(PHOTO_XCHAN)
- );
- if($r) {
- $hash = $r[0]['resource_id'];
- }
- else {
- $hash = photo_new_resource();
- }
- }
-
- $photo_failure = false;
- $img_str = '';
-
- if($photo) {
- $filename = basename($photo);
-
- $result = z_fetch_url($photo,true);
-
- if($result['success']) {
- $img_str = $result['body'];
- $type = guess_image_type($photo, $result['header']);
-
- $h = explode("\n",$result['header']);
- if($h) {
- foreach($h as $hl) {
- if(stristr($hl,'content-type:')) {
- if(! stristr($hl,'image/')) {
- $photo_failure = true;
- }
- }
- }
- }
- }
- }
- else {
- $photo_failure = true;
- }
-
- if(! $photo_failure) {
- $img = photo_factory($img_str, $type);
- if($img->is_valid()) {
- $width = $img->getWidth();
- $height = $img->getHeight();
-
- if($width && $height) {
- if(($width / $height) > 1.2) {
- // crop out the sides
- $margin = $width - $height;
- $img->cropImage(300,($margin / 2),0,$height,$height);
- }
- elseif(($height / $width) > 1.2) {
- // crop out the bottom
- $margin = $height - $width;
- $img->cropImage(300,0,0,$width,$width);
-
- }
- else {
- $img->scaleImageSquare(300);
- }
-
- }
- else
- $photo_failure = true;
-
- $p = array('xchan' => $xchan,'resource_id' => $hash, 'filename' => basename($photo), 'album' => $album, 'photo_usage' => $flags, 'imgscale' => 4);
-
- $r = $img->save($p);
-
- if($r === false)
- $photo_failure = true;
-
- $img->scaleImage(80);
- $p['imgscale'] = 5;
-
- $r = $img->save($p);
-
- if($r === false)
- $photo_failure = true;
-
- $img->scaleImage(48);
- $p['imgscale'] = 6;
-
- $r = $img->save($p);
-
- if($r === false)
- $photo_failure = true;
-
- $photo = z_root() . '/photo/' . $hash . '-4';
- $thumb = z_root() . '/photo/' . $hash . '-5';
- $micro = z_root() . '/photo/' . $hash . '-6';
- }
- else {
- logger('import_xchan_photo: invalid image from ' . $photo);
- $photo_failure = true;
- }
- }
- if($photo_failure) {
- $photo = z_root() . '/' . get_default_profile_photo();
- $thumb = z_root() . '/' . get_default_profile_photo(80);
- $micro = z_root() . '/' . get_default_profile_photo(48);
- $type = 'image/png';
- }
+/**
+ * @brief fetches an photo from external site and prepares its miniatures.
+ *
+ * @param string $photo
+ * external URL to fetch base image
+ * @param string $xchan
+ * channel unique hash
+ * @param boolean $thing
+ * TRUE if this is a thing URL
+ * @param boolean $force
+ * TRUE if ignore image modification date check (force fetch)
+ *
+ * @return array of results
+ * * \e string \b 0 => local URL to full image
+ * * \e string \b 1 => local URL to standard thumbnail
+ * * \e string \b 2 => local URL to micro thumbnail
+ * * \e string \b 3 => image type
+ * * \e boolean \b 4 => TRUE if fetch failure
+ * * \e string \b 5 => modification date
+ */
- return(array($photo,$thumb,$micro,$type,$photo_failure));
+function import_xchan_photo($photo,$xchan,$thing = false,$force = false) {
+
+ $modified = '';
+
+ $flags = (($thing) ? PHOTO_THING : PHOTO_XCHAN);
+ $album = (($thing) ? 'Things' : 'Contact Photos');
+
+ logger('import_xchan_photo: updating channel photo from ' . $photo . ' for ' . $xchan, LOGGER_DEBUG);
+
+ if($thing) {
+ $hash = photo_new_resource();
+ }
+ else {
+ $r = q("select resource_id, edited, mimetype from photo where xchan = '%s' and photo_usage = %d and imgscale = 4 limit 1",
+ dbesc($xchan),
+ intval(PHOTO_XCHAN)
+ );
+ if($r) {
+ $hash = $r[0]['resource_id'];
+ $modified = $r[0]['edited'];
+ $type = $r[0]['mimetype'];
+ }
+ else {
+ $hash = photo_new_resource();
+ }
+ }
+
+ $photo_failure = false;
+ $img_str = '';
+
+ if($photo) {
+ $filename = basename($photo);
+
+ if($force || $modified == '') {
+ $result = z_fetch_url($photo,true);
+ }
+ else {
+ $h = array('headers' => array("If-Modified-Since: " . gmdate("D, d M Y H:i:s", strtotime($modified . "Z")) . " GMT"));
+ $result = z_fetch_url($photo,true,0,$h);
+ }
+
+ if($result['success']) {
+ $img_str = $result['body'];
+ $type = guess_image_type($photo, $result['header']);
+ $modified = gmdate('Y-m-d H:i:s', (preg_match('/last-modified: (.+) \S+/i', $result['header'], $o) ? strtotime($o[1] . 'Z') : time()));
+
+ if(is_null($type))
+ $photo_failure = true;
+ }
+ elseif($result['return_code'] == 304) {
+ $photo = z_root() . '/photo/' . $hash . '-4';
+ $thumb = z_root() . '/photo/' . $hash . '-5';
+ $micro = z_root() . '/photo/' . $hash . '-6';
+ }
+ else {
+ $photo_failure = true;
+ }
+
+ }
+ else
+ $photo_failure = true;
+
+ if(! $photo_failure && $result['return_code'] != 304) {
+ $img = photo_factory($img_str, $type);
+ if($img->is_valid()) {
+ $width = $img->getWidth();
+ $height = $img->getHeight();
+
+ if($width && $height) {
+ if(($width / $height) > 1.2) {
+ // crop out the sides
+ $margin = $width - $height;
+ $img->cropImage(300,($margin / 2),0,$height,$height);
+ }
+ elseif(($height / $width) > 1.2) {
+ // crop out the bottom
+ $margin = $height - $width;
+ $img->cropImage(300,0,0,$width,$width);
+
+ }
+ else {
+ $img->scaleImageSquare(300);
+ }
+
+ }
+ else
+ $photo_failure = true;
+
+ $p = array(
+ 'xchan' => $xchan,
+ 'resource_id' => $hash,
+ 'filename' => basename($photo),
+ 'album' => $album,
+ 'photo_usage' => $flags,
+ 'imgscale' => 4,
+ 'edited' => $modified
+ );
+
+ $r = $img->save($p);
+
+ if($r === false)
+ $photo_failure = true;
+
+ $img->scaleImage(80);
+ $p['imgscale'] = 5;
+
+ $r = $img->save($p);
+
+ if($r === false)
+ $photo_failure = true;
+
+ $img->scaleImage(48);
+ $p['imgscale'] = 6;
+
+ $r = $img->save($p);
+
+ if($r === false)
+ $photo_failure = true;
+
+ $photo = z_root() . '/photo/' . $hash . '-4';
+ $thumb = z_root() . '/photo/' . $hash . '-5';
+ $micro = z_root() . '/photo/' . $hash . '-6';
+ }
+ else {
+ logger('import_xchan_photo: invalid image from ' . $photo);
+ $photo_failure = true;
+ }
+ }
+ if($photo_failure) {
+ $default = get_default_profile_photo();
+ $photo = z_root() . '/' . $default;
+ $thumb = z_root() . '/' . get_default_profile_photo(80);
+ $micro = z_root() . '/' . get_default_profile_photo(48);
+ $type = 'image/png';
+ $modified = gmdate('Y-m-d H:i:s', filemtime($default));
+ }
+
+ logger('HTTP code: ' . $result['return_code'] . '; modified: ' . $modified . '; failure: ' . ($photo_failure ? 'yes' : 'no') . '; URL: ' . $photo, LOGGER_DEBUG);
+ return(array($photo,$thumb,$micro,$type,$photo_failure,$modified));
}
@@ -700,16 +741,8 @@ function import_channel_photo_from_url($photo,$aid,$uid) {
$img_str = $result['body'];
$type = guess_image_type($photo, $result['header']);
- $h = explode("\n",$result['header']);
- if($h) {
- foreach($h as $hl) {
- if(stristr($hl,'content-type:')) {
- if(! stristr($hl,'image/')) {
- $photo_failure = true;
- }
- }
- }
- }
+ if(is_null($type))
+ $photo_failure = true;
}
}
else {
diff --git a/include/photos.php b/include/photos.php
index d0c5f77fc..d5553b495 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -1011,23 +1011,3 @@ function profile_photo_set_profile_perms($uid, $profileid = 0) {
}
}
}
-
-function fetch_image_from_url($url,&$mimetype) {
-
- $redirects = 0;
- $x = z_fetch_url($url,true,$redirects,[ 'novalidate' => true ]);
- if($x['success']) {
- $hdrs = [];
- $h = explode("\n",$x['header']);
- foreach ($h as $l) {
- list($k,$v) = array_map("trim", explode(":", trim($l), 2));
- $hdrs[strtolower($k)] = $v;
- }
- if (array_key_exists('content-type', $hdrs))
- $mimetype = $hdrs['content-type'];
-
- return $x['body'];
- }
-
- return EMPTY_STR;
-} \ No newline at end of file
diff --git a/include/text.php b/include/text.php
index 1d884593f..076c98407 100644
--- a/include/text.php
+++ b/include/text.php
@@ -634,6 +634,19 @@ function attribute_contains($attr, $s) {
}
/**
+ * @brief Log to syslog
+ *
+ * @param string $msg Message to log
+ * @param int $priority - compatible with syslog
+ */
+function hz_syslog($msg, $priority = LOG_INFO) {
+ openlog("hz-log", LOG_PID | LOG_PERROR, LOG_LOCAL0);
+ syslog($priority, $msg);
+ closelog();
+}
+
+
+/**
* @brief Logging function for Hubzilla.
*
* Logging output is configured through Hubzilla's system config. The log file
@@ -3219,8 +3232,16 @@ function create_table_from_array($table, $arr, $binary_fields = []) {
if(! ($arr && $table))
return false;
+ $columns = db_columns($table);
+
$clean = [];
foreach($arr as $k => $v) {
+
+ if(! in_array($k,$columns)) {
+ continue;
+ }
+
+
$matches = false;
if(preg_match('/([^a-zA-Z0-9\-\_\.])/',$k,$matches)) {
return false;
diff --git a/include/xchan.php b/include/xchan.php
index aad56063f..eb5f1b4a3 100644
--- a/include/xchan.php
+++ b/include/xchan.php
@@ -1,5 +1,7 @@
<?php
+use Zotlabs\Zot6\HTTPSig;
+
function xchan_store_lowlevel($arr) {
@@ -39,6 +41,13 @@ function xchan_store_lowlevel($arr) {
function xchan_store($arr) {
+ $update_photo = false;
+ $update_name = false;
+
+ if(! ($arr['guid'] || $arr['hash'])) {
+ $arr = json_decode(file_get_contents('php://input'),true);
+ }
+
logger('xchan_store: ' . print_r($arr,true));
if(! $arr['hash'])
@@ -49,57 +58,90 @@ function xchan_store($arr) {
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($arr['hash'])
);
- if($r)
- return true;
-
- if(! $arr['network'])
- $arr['network'] = 'unknown';
- if(! $arr['name'])
- $arr['name'] = 'unknown';
- if(! $arr['url'])
- $arr['url'] = z_root();
- if(! $arr['photo'])
- $arr['photo'] = z_root() . '/' . get_default_profile_photo();
-
-
- if($arr['network'] === 'zot') {
- if((! $arr['key']) || (! rsa_verify($arr['guid'],base64url_decode($arr['guid_sig']),$arr['key']))) {
- logger('Unable to verify signature for ' . $arr['hash']);
- return false;
+ if(! $r) {
+
+ $update_photo = true;
+
+ if(! $arr['network'])
+ $arr['network'] = 'unknown';
+ if(! $arr['name'])
+ $arr['name'] = 'unknown';
+ if(! $arr['url'])
+ $arr['url'] = z_root();
+ if(! $arr['photo'])
+ $arr['photo'] = z_root() . '/' . get_default_profile_photo();
+
+ if($arr['network'] === 'zot6') {
+ if((! $arr['key']) || (! Libzot::verify($arr['id'],$arr['id_sig'],$arr['key']))) {
+ logger('Unable to verify signature for ' . $arr['hash']);
+ return false;
+ }
}
- }
- $x = [];
- foreach($arr as $k => $v) {
- if($k === 'key') {
- $x['xchan_pubkey'] = $v;
- continue;
- }
- if($k === 'photo') {
- continue;
+ if($arr['network'] === 'zot') {
+ if((! $arr['key']) || (! rsa_verify($arr['guid'],base64url_decode($arr['guid_sig']),$arr['key']))) {
+ logger('Unable to verify signature for ' . $arr['hash']);
+ return false;
+ }
}
-
- $x['xchan_' . $k] = $v;
- }
- $x['xchan_name_date'] = datetime_convert();
+ $columns = db_columns('xchan');
+
+ $x = [];
+ foreach($arr as $k => $v) {
+ if($k === 'key') {
+ $x['xchan_pubkey'] = HTTPSig::convertKey(escape_tags($v));;
+ continue;
+ }
+ if($k === 'photo') {
+ continue;
+ }
+
+ if(in_array($columns,'xchan_' . $k))
+ $x['xchan_' . $k] = escape_tags($v);
+ }
- $r = xchan_store_lowlevel($x);
+ $x['xchan_name_date'] = datetime_convert();
+ $x['xchan_photo_date'] = datetime_convert();
+ $x['xchan_system'] = false;
- if(! $r)
- return $r;
-
- $photos = import_xchan_photo($arr['photo'],$arr['hash']);
- $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'",
- dbesc(datetime_convert()),
- dbesc($photos[0]),
- dbesc($photos[1]),
- dbesc($photos[2]),
- dbesc($photos[3]),
- dbesc($arr['hash'])
- );
- return $r;
+ $result = xchan_store_lowlevel($x);
+
+ if(! $result)
+ return $result;
+ }
+ else {
+ if($r[0]['network'] === 'zot6') {
+ return true;
+ }
+ if($r[0]['xchan_photo_date'] < datetime_convert('UTC','UTC',$arr['photo_date'])) {
+ $update_photo = true;
+ }
+ if($r[0]['xchan_name_date'] < datetime_convert('UTC','UTC',$arr['name_date'])) {
+ $update_name = true;
+ }
+ }
+
+ if($update_photo && $arr['photo']) {
+ $photos = import_xchan_photo($arr['photo'],$arr['hash']);
+ $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'",
+ dbesc(datetime_convert()),
+ dbesc($photos[0]),
+ dbesc($photos[1]),
+ dbesc($photos[2]),
+ dbesc($photos[3]),
+ dbesc($arr['hash'])
+ );
+ }
+ if($update_name && $arr['name']) {
+ $x = q("update xchan set xchan_name = '%s', xchan_name_date = '%s' where xchan_hash = '%s'",
+ dbesc(escape_tags($arr['name'])),
+ dbesc(datetime_convert()),
+ dbesc($arr['hash'])
+ );
+ }
+ return true;
}
diff --git a/include/zot.php b/include/zot.php
index 1a632cf87..49fc89e33 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -3507,8 +3507,41 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
if(array_key_exists('config',$arr) && is_array($arr['config']) && count($arr['config'])) {
foreach($arr['config'] as $cat => $k) {
- foreach($arr['config'][$cat] as $k => $v)
- set_pconfig($channel['channel_id'],$cat,$k,$v);
+
+ $pconfig_updated = [];
+ $pconfig_del = [];
+
+ foreach($arr['config'][$cat] as $k => $v) {
+
+ if (strpos($k,'pcfgud:')===0) {
+
+ $realk = substr($k,7);
+ $pconfig_updated[$realk] = $v;
+ unset($arr['config'][$cat][$k]);
+
+ }
+
+ if (strpos($k,'pcfgdel:')===0) {
+ $realk = substr($k,8);
+ $pconfig_del[$realk] = datetime_convert();
+ unset($arr['config'][$cat][$k]);
+ }
+ }
+
+ foreach($arr['config'][$cat] as $k => $v) {
+
+ if (!isset($pconfig_updated[$k])) {
+ $pconfig_updated[$k] = NULL;
+ }
+
+ set_pconfig($channel['channel_id'],$cat,$k,$v,$pconfig_updated[$k]);
+
+ }
+
+ foreach($pconfig_del as $k => $updated) {
+ del_pconfig($channel['channel_id'],$cat,$k,$updated);
+ }
+
}
}