aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xboot.php4
-rw-r--r--include/attach.php45
-rw-r--r--include/photo/photo_driver.php17
-rw-r--r--include/photos.php20
4 files changed, 69 insertions, 17 deletions
diff --git a/boot.php b/boot.php
index a42c82609..d3ca6ffcc 100755
--- a/boot.php
+++ b/boot.php
@@ -80,9 +80,9 @@ $DIRECTORY_FALLBACK_SERVERS = array(
'https://zothub.com',
'https://zotid.net',
'https://red.zottel.red',
- 'https://hubzilla.info',
+ 'https://redmatrix.info',
'https://my.federated.social',
- 'https://hubzilla.nl'
+ 'https://redmatrix.nl'
);
diff --git a/include/attach.php b/include/attach.php
index c78ae41fc..dd4f174dd 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -391,10 +391,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$hash = (($arr && $arr['hash']) ? $arr['hash'] : null);
$upload_path = (($arr && $arr['directory']) ? $arr['directory'] : '');
- logger('arr: ' . print_r($arr,true));
-
- // This is currently used only in mod/wall_attach
-
+ // logger('arr: ' . print_r($arr,true));
if(! perm_is_allowed($channel_id,get_observer_hash(), 'write_storage')) {
$ret['message'] = t('Permission denied.');
@@ -417,6 +414,14 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$src = $_FILES['userfile']['tmp_name'];
$filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']);
+
+
+
+
+
+
+
+
}
$existing_size = 0;
@@ -482,9 +487,9 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$is_photo = 0;
- $x = @getimagesize($src);
- logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
- if(($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
+ $gis = @getimagesize($src);
+ logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA);
+ if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) {
$is_photo = 1;
}
@@ -519,6 +524,30 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$folder_hash = '';
}
+ $r = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' ",
+ dbesc($filename),
+ dbesc($filename . '(%)'),
+ dbesc($folder_hash)
+ );
+
+ if($r) {
+ $x = 1;
+
+ do {
+ $found = false;
+ foreach($r as $rr) {
+ if($rr['filename'] === $filename . '(' . $x . ')') {
+ $found = true;
+ break;
+ }
+ }
+ if($found)
+ $x++;
+ }
+ while($found);
+ $filename = $filename . '(' . $x . ')';
+ }
+
$os_basepath = 'store/' . $channel['channel_address'] . '/' ;
$os_relpath = '';
@@ -614,7 +643,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
}
if($is_photo) {
- $args = array( 'source' => $source, 'visible' => 0, 'resource_id' => $hash, 'album' => basename($pathname), 'data' => @file_get_contents($src));
+ $args = array( 'source' => $source, 'visible' => 0, 'resource_id' => $hash, 'album' => basename($pathname), 'os_path' => $os_basepath . $os_relpath, 'filename' => $filename, 'getimagesize' => $gis);
if($arr['contact_allow'])
$args['contact_allow'] = $arr['contact_allow'];
$p = photo_upload($channel,get_app()->get_observer(),$args);
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 1ec031a1a..1501e6712 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -311,7 +311,11 @@ abstract class photo_driver {
$p['title'] = (($arr['title']) ? $arr['title'] : '');
$p['description'] = (($arr['description']) ? $arr['description'] : '');
$p['photo_usage'] = intval($arr['photo_usage']);
-
+ $p['os_storage'] = intval($arr['os_storage']);
+ $p['os_path'] = $arr['os_path'];
+
+ if(! intval($p['scale']))
+ logger('save: ' . print_r($arr,true));
$x = q("select id from photo where resource_id = '%s' and uid = %d and xchan = '%s' and `scale` = %d limit 1",
dbesc($p['resource_id']),
@@ -333,6 +337,7 @@ abstract class photo_driver {
`height` = %d,
`width` = %d,
`data` = '%s',
+ `os_storage` = %d,
`size` = %d,
`scale` = %d,
`photo_usage` = %d,
@@ -355,7 +360,8 @@ abstract class photo_driver {
dbesc($p['album']),
intval($this->getHeight()),
intval($this->getWidth()),
- dbescbin($this->imageString()),
+ (intval($p['os_storage']) ? dbesc($p['os_path']) : dbescbin($this->imageString())),
+ intval($p['os_storage']),
intval(strlen($this->imageString())),
intval($p['scale']),
intval($p['photo_usage']),
@@ -370,8 +376,8 @@ abstract class photo_driver {
}
else {
$r = q("INSERT INTO `photo`
- ( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `size`, `scale`, `photo_usage`, `title`, `description`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s' )",
+ ( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `os_storage`, `size`, `scale`, `photo_usage`, `title`, `description`, `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' )",
intval($p['aid']),
intval($p['uid']),
dbesc($p['xchan']),
@@ -383,7 +389,8 @@ abstract class photo_driver {
dbesc($p['album']),
intval($this->getHeight()),
intval($this->getWidth()),
- dbescbin($this->imageString()),
+ (intval($p['os_storage']) ? dbesc($p['os_path']) : dbescbin($this->imageString())),
+ intval($p['os_storage']),
intval(strlen($this->imageString())),
intval($p['scale']),
intval($p['photo_usage']),
diff --git a/include/photos.php b/include/photos.php
index bc6d1a758..867571f8f 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -55,7 +55,18 @@ function photo_upload($channel, $observer, $args) {
$str_group_deny = perms2str(((is_array($args['group_deny'])) ? $args['group_deny'] : explode(',',$args['group_deny'])));
$str_contact_deny = perms2str(((is_array($args['contact_deny'])) ? $args['contact_deny'] : explode(',',$args['contact_deny'])));
- if ($args['data']) {
+ $os_storage = 0;
+
+ if($args['os_path'] && $args['getimagesize']) {
+ $imagedata = @file_get_contents($args['os_path']);
+ $filename = $args['filename'];
+ $filesize = strlen($imagedata);
+ // this is going to be deleted if it exists
+ $src = '/tmp/deletemenow';
+ $type = $args['getimagesize']['mime'];
+ $os_storage = 1;
+ }
+ elseif ($args['data']) {
// allow an import from a binary string representing the image.
// This bypasses the upload step and max size limit checking
@@ -158,7 +169,8 @@ function photo_upload($channel, $observer, $args) {
$p = array('aid' => $account_id, 'uid' => $channel_id, 'xchan' => $visitor, 'resource_id' => $photo_hash,
'filename' => $filename, 'album' => $album, 'scale' => 0, 'photo_usage' => PHOTO_NORMAL,
'allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
- 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny
+ 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny,
+ 'os_storage' => $os_storage, 'os_path' => $args['os_path']
);
if($args['created'])
$p['created'] = $args['created'];
@@ -173,6 +185,10 @@ function photo_upload($channel, $observer, $args) {
if(! $r1)
$errors = true;
+
+ unset($p['os_storage']);
+ unset($p['os_path']);
+
if(($width > 640 || $height > 640) && (! $errors)) {
$ph->scaleImage(640);
$p['scale'] = 1;