aboutsummaryrefslogtreecommitdiffstats
path: root/include/attach.php
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-06-23 22:46:39 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-06-23 22:46:39 -0700
commit86588bdd6cf765d2f334168da5e056923c440aba (patch)
tree313cde1a1d577856cdc5a8a90479c7aa968ca85d /include/attach.php
parent1a0655f34ea9979c7a08d21344d3e0eb9eb3246d (diff)
downloadvolse-hubzilla-86588bdd6cf765d2f334168da5e056923c440aba.tar.gz
volse-hubzilla-86588bdd6cf765d2f334168da5e056923c440aba.tar.bz2
volse-hubzilla-86588bdd6cf765d2f334168da5e056923c440aba.zip
more work on photos, including os_storage for the size '0' photo and numbering duplicate filenames
Diffstat (limited to 'include/attach.php')
-rw-r--r--include/attach.php45
1 files changed, 37 insertions, 8 deletions
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);