Commit fa5115b3 authored by Zot's avatar Zot Committed by Mario
Browse files

add os_path and display_path to photos, fix some issues with multiple path...

add os_path and display_path to photos, fix some issues with multiple path separators after cloud/nickname in the content field of attach and photos
parent ec5e1067
......@@ -702,11 +702,10 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$os_relpath .= $folder_hash . '/';
}
$os_relpath .= $hash;
// not yet used
$os_path = ltrim($os_relpath,'/');
$os_relpath .= $hash;
$os_relpath = ltrim($os_relpath,'/');
$os_path = $os_relpath;
$display_path = $pathname . '/' . $filename;
if($src)
......@@ -811,7 +810,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
if($is_photo) {
$args = array( 'source' => $source, 'visible' => $visible, 'resource_id' => $hash, 'album' => basename($pathname), 'os_path' => $os_basepath . $os_relpath, 'filename' => $filename, 'getimagesize' => $gis, 'directory' => $direct, 'options' => $options );
$args = array( 'source' => $source, 'visible' => $visible, 'resource_id' => $hash, 'album' => basename($pathname), 'os_syspath' => $os_basepath . $os_relpath, 'os_path' => $os_path, 'display_path' => $display_path, 'filename' => $filename, 'getimagesize' => $gis, 'directory' => $direct, 'options' => $options );
if($arr['contact_allow'])
$args['contact_allow'] = $arr['contact_allow'];
if($arr['group_allow'])
......
......@@ -380,7 +380,7 @@ abstract class photo_driver {
dbesc($p['album']),
intval($this->getHeight()),
intval($this->getWidth()),
(intval($p['os_storage']) ? dbescbin($p['os_path']) : dbescbin($this->imageString())),
(intval($p['os_storage']) ? dbescbin($p['os_syspath']) : dbescbin($this->imageString())),
intval($p['os_storage']),
intval(strlen($this->imageString())),
intval($p['imgscale']),
......@@ -411,7 +411,7 @@ abstract class photo_driver {
dbesc($p['album']),
intval($this->getHeight()),
intval($this->getWidth()),
(intval($p['os_storage']) ? dbescbin($p['os_path']) : dbescbin($this->imageString())),
(intval($p['os_storage']) ? dbescbin($p['os_syspath']) : dbescbin($this->imageString())),
intval($p['os_storage']),
intval(strlen($this->imageString())),
intval($p['imgscale']),
......@@ -429,90 +429,6 @@ abstract class photo_driver {
return $r;
}
// should be obsolete now
public function store($aid, $uid, $xchan, $rid, $filename, $album, $scale, $usage = PHOTO_NORMAL, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') {
$x = q("select id from photo where resource_id = '%s' and uid = %d and xchan = '%s' and imgscale = %d limit 1",
dbesc($rid),
intval($uid),
dbesc($xchan),
intval($scale)
);
if(count($x)) {
$r = q("UPDATE photo
set aid = %d,
uid = %d,
xchan = '%s',
resource_id = '%s',
created = '%s',
edited = '%s',
filename = '%s',
mimetype = '%s',
album = '%s',
height = %d,
width = %d,
content = '%s',
filesize = %d,
imgscale = %d,
photo_usage = %d,
allow_cid = '%s',
allow_gid = '%s',
deny_cid = '%s',
deny_gid = '%s'
where id = %d",
intval($aid),
intval($uid),
dbesc($xchan),
dbesc($rid),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc(basename($filename)),
dbesc($this->getType()),
dbesc($album),
intval($this->getHeight()),
intval($this->getWidth()),
dbescbin($this->imageString()),
intval(strlen($this->imageString())),
intval($scale),
intval($photo_usage),
dbesc($allow_cid),
dbesc($allow_gid),
dbesc($deny_cid),
dbesc($deny_gid),
intval($x[0]['id'])
);
}
else {
$r = q("INSERT INTO photo
( aid, uid, xchan, resource_id, created, edited, filename, mimetype, album, height, width, content, filesize, imgscale, photo_usage, 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' )",
intval($aid),
intval($uid),
dbesc($xchan),
dbesc($rid),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc(basename($filename)),
dbesc($this->getType()),
dbesc($album),
intval($this->getHeight()),
intval($this->getWidth()),
dbescbin($this->imageString()),
intval(strlen($this->imageString())),
intval($scale),
intval($photo_usage),
dbesc($allow_cid),
dbesc($allow_gid),
dbesc($deny_cid),
dbesc($deny_gid)
);
}
return $r;
}
}
......
......@@ -67,8 +67,8 @@ function photo_upload($channel, $observer, $args) {
$os_storage = 0;
if($args['os_path'] && $args['getimagesize']) {
$imagedata = @file_get_contents($args['os_path']);
if($args['os_syspath'] && $args['getimagesize']) {
$imagedata = @file_get_contents($args['os_syspath']);
$filename = $args['filename'];
$filesize = strlen($imagedata);
// this is going to be deleted if it exists
......@@ -153,7 +153,7 @@ function photo_upload($channel, $observer, $args) {
return $ret;
}
$exif = $ph->orient(($args['os_path']) ? $args['os_path'] : $src);
$exif = $ph->orient(($args['os_syspath']) ? $args['os_syspath'] : $src);
@unlink($src);
......@@ -180,7 +180,8 @@ function photo_upload($channel, $observer, $args) {
'filename' => $filename, 'album' => $album, 'imgscale' => 0, 'photo_usage' => PHOTO_NORMAL,
'allow_cid' => $ac['allow_cid'], 'allow_gid' => $ac['allow_gid'],
'deny_cid' => $ac['deny_cid'], 'deny_gid' => $ac['deny_gid'],
'os_storage' => $os_storage, 'os_path' => $args['os_path']
'os_storage' => $os_storage, 'os_syspath' => $args['os_syspath'],
'os_path' => $args['os_path'], 'display_path' => $args['display_path']
);
if($args['created'])
$p['created'] = $args['created'];
......@@ -205,7 +206,7 @@ function photo_upload($channel, $observer, $args) {
$errors = true;
unset($p['os_storage']);
unset($p['os_path']);
unset($p['os_syspath']);
if(($width > 1024 || $height > 1024) && (! $errors))
$ph->scaleImage(1024);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment