abstractify items, check photos for birthday paradox
This commit is contained in:
parent
38fde6672e
commit
c5031139eb
17
boot.php
17
boot.php
|
@ -776,6 +776,23 @@ function item_new_uri($hostname,$uid) {
|
||||||
return $uri;
|
return $uri;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
if(! function_exists('photo_new_resource')) {
|
||||||
|
function photo_new_resource() {
|
||||||
|
|
||||||
|
do {
|
||||||
|
$found = false;
|
||||||
|
$resource = hash('md5',uniqid(mt_rand(),true));
|
||||||
|
$r = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1",
|
||||||
|
dbesc($resource)
|
||||||
|
);
|
||||||
|
if(count($r))
|
||||||
|
$found = true;
|
||||||
|
} while($found == true);
|
||||||
|
return $resource;
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(! function_exists('get_uid')) {
|
if(! function_exists('get_uid')) {
|
||||||
function get_uid() {
|
function get_uid() {
|
||||||
return ((x($_SESSION,'uid')) ? intval($_SESSION['uid']) : 0) ;
|
return ((x($_SESSION,'uid')) ? intval($_SESSION['uid']) : 0) ;
|
||||||
|
|
|
@ -308,7 +308,7 @@ function get_atom_elements($item) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function post_remote($a,$arr) {
|
function item_store($arr) {
|
||||||
|
|
||||||
//print_r($arr);
|
//print_r($arr);
|
||||||
|
|
||||||
|
@ -330,14 +330,14 @@ function post_remote($a,$arr) {
|
||||||
$arr['owner-name'] = notags(trim($arr['owner-name']));
|
$arr['owner-name'] = notags(trim($arr['owner-name']));
|
||||||
$arr['owner-link'] = notags(trim($arr['owner-link']));
|
$arr['owner-link'] = notags(trim($arr['owner-link']));
|
||||||
$arr['owner-avatar'] = notags(trim($arr['owner-avatar']));
|
$arr['owner-avatar'] = notags(trim($arr['owner-avatar']));
|
||||||
$arr['created'] = datetime_convert('UTC','UTC',$arr['created'],'Y-m-d H:i:s');
|
$arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert());
|
||||||
$arr['edited'] = datetime_convert('UTC','UTC',$arr['edited'],'Y-m-d H:i:s');
|
$arr['edited'] = ((x($arr,'edited') !== false) ? datetime_convert('UTC','UTC',$arr['edited']) : datetime_convert());
|
||||||
$arr['changed'] = datetime_convert();
|
$arr['changed'] = datetime_convert();
|
||||||
$arr['title'] = notags(trim($arr['title']));
|
$arr['title'] = notags(trim($arr['title']));
|
||||||
$arr['location'] = notags(trim($arr['location']));
|
$arr['location'] = notags(trim($arr['location']));
|
||||||
$arr['body'] = escape_tags(trim($arr['body']));
|
$arr['body'] = escape_tags(trim($arr['body']));
|
||||||
$arr['last-child'] = intval($arr['last-child']);
|
$arr['last-child'] = intval($arr['last-child']);
|
||||||
$arr['visible'] = 1;
|
$arr['visible'] = ((x($arr,'visible') !== false) ? intval($arr['visible']) : 1);
|
||||||
$arr['deleted'] = 0;
|
$arr['deleted'] = 0;
|
||||||
$arr['parent-uri'] = notags(trim($arr['parent-uri']));
|
$arr['parent-uri'] = notags(trim($arr['parent-uri']));
|
||||||
$arr['verb'] = notags(trim($arr['verb']));
|
$arr['verb'] = notags(trim($arr['verb']));
|
||||||
|
|
|
@ -348,7 +348,7 @@
|
||||||
$datarray['parent-uri'] = $parent_uri;
|
$datarray['parent-uri'] = $parent_uri;
|
||||||
$datarray['uid'] = $importer['uid'];
|
$datarray['uid'] = $importer['uid'];
|
||||||
$datarray['contact-id'] = $contact['id'];
|
$datarray['contact-id'] = $contact['id'];
|
||||||
$r = post_remote($a,$datarray);
|
$r = item_store($datarray);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@
|
||||||
$datarray['parent-uri'] = $item_id;
|
$datarray['parent-uri'] = $item_id;
|
||||||
$datarray['uid'] = $importer['uid'];
|
$datarray['uid'] = $importer['uid'];
|
||||||
$datarray['contact-id'] = $contact['id'];
|
$datarray['contact-id'] = $contact['id'];
|
||||||
$r = post_remote($a,$datarray);
|
$r = item_store($datarray);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ function dfrn_confirm_post(&$a) {
|
||||||
|
|
||||||
$img->scaleImageSquare(175);
|
$img->scaleImageSquare(175);
|
||||||
|
|
||||||
$hash = hash('md5',uniqid(mt_rand(),true));
|
$hash = photo_new_resource();
|
||||||
|
|
||||||
$r = $img->store($local_uid, $dfrn_record, $hash, $filename, t('Contact Photos') , 4);
|
$r = $img->store($local_uid, $dfrn_record, $hash, $filename, t('Contact Photos') , 4);
|
||||||
|
|
||||||
|
@ -332,12 +332,13 @@ function dfrn_confirm_post(&$a) {
|
||||||
|
|
||||||
$img->scaleImageSquare(175);
|
$img->scaleImageSquare(175);
|
||||||
|
|
||||||
$hash = hash('md5',uniqid(mt_rand(),true));
|
$hash = photo_new_resource();
|
||||||
|
|
||||||
$r = $img->store($uid, $contact_id, $hash, $filename, t('Contact Photos'), 4 );
|
$r = $img->store($uid, $contact_id, $hash, $filename, t('Contact Photos'), 4 );
|
||||||
|
|
||||||
if($r === false)
|
if($r === false)
|
||||||
$photo_failure = true;
|
$photo_failure = true;
|
||||||
|
|
||||||
$img->scaleImage(80);
|
$img->scaleImage(80);
|
||||||
|
|
||||||
$r = $img->store($uid, $contact_id, $hash, $filename, t('Contact Photos'), 5 );
|
$r = $img->store($uid, $contact_id, $hash, $filename, t('Contact Photos'), 5 );
|
||||||
|
|
|
@ -208,7 +208,7 @@ function dfrn_notify_post(&$a) {
|
||||||
$datarray['parent-uri'] = $parent_uri;
|
$datarray['parent-uri'] = $parent_uri;
|
||||||
$datarray['uid'] = $importer['importer_uid'];
|
$datarray['uid'] = $importer['importer_uid'];
|
||||||
$datarray['contact-id'] = $importer['id'];
|
$datarray['contact-id'] = $importer['id'];
|
||||||
$posted_id = post_remote($a,$datarray);
|
$posted_id = item_store($datarray);
|
||||||
|
|
||||||
if($posted_id) {
|
if($posted_id) {
|
||||||
$r = q("SELECT `parent` FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
$r = q("SELECT `parent` FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
|
@ -280,7 +280,7 @@ function dfrn_notify_post(&$a) {
|
||||||
$datarray['parent-uri'] = $parent_uri;
|
$datarray['parent-uri'] = $parent_uri;
|
||||||
$datarray['uid'] = $importer['importer_uid'];
|
$datarray['uid'] = $importer['importer_uid'];
|
||||||
$datarray['contact-id'] = $importer['id'];
|
$datarray['contact-id'] = $importer['id'];
|
||||||
$r = post_remote($a,$datarray);
|
$r = item_store($datarray);
|
||||||
|
|
||||||
// find out if our user is involved in this conversation and wants to be notified.
|
// find out if our user is involved in this conversation and wants to be notified.
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ function dfrn_notify_post(&$a) {
|
||||||
$datarray['parent-uri'] = $item_id;
|
$datarray['parent-uri'] = $item_id;
|
||||||
$datarray['uid'] = $importer['importer_uid'];
|
$datarray['uid'] = $importer['importer_uid'];
|
||||||
$datarray['contact-id'] = $importer['id'];
|
$datarray['contact-id'] = $importer['id'];
|
||||||
$r = post_remote($a,$datarray);
|
$r = item_store($datarray);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
138
mod/photos.php
138
mod/photos.php
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('Photo.php');
|
require_once('Photo.php');
|
||||||
|
require_once('include/items.php');
|
||||||
require_once('view/acl_selectors.php');
|
require_once('view/acl_selectors.php');
|
||||||
|
|
||||||
function photos_init(&$a) {
|
function photos_init(&$a) {
|
||||||
|
@ -54,7 +55,7 @@ function photos_post(&$a) {
|
||||||
|
|
||||||
$r = q("SELECT `contact`.* `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
$r = q("SELECT `contact`.* `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||||
WHERE `user`.`uid` = %d AND `self` = 1 LIMIT 1",
|
WHERE `user`.`uid` = %d AND `self` = 1 LIMIT 1",
|
||||||
intval($_SESSION['uid'])
|
intval(get_uid())
|
||||||
);
|
);
|
||||||
|
|
||||||
$contact_record = $r[0];
|
$contact_record = $r[0];
|
||||||
|
@ -70,7 +71,7 @@ function photos_post(&$a) {
|
||||||
|
|
||||||
$r = q("SELECT count(*) FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
|
$r = q("SELECT count(*) FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
|
||||||
dbesc($album),
|
dbesc($album),
|
||||||
intval($_SESSION['uid'])
|
intval(get_uid())
|
||||||
);
|
);
|
||||||
if(! count($r)) {
|
if(! count($r)) {
|
||||||
notice( t('Album not found.') . EOL);
|
notice( t('Album not found.') . EOL);
|
||||||
|
@ -83,7 +84,7 @@ function photos_post(&$a) {
|
||||||
q("UPDATE `photo` SET `album` = '%s' WHERE `album` = '%s' AND `uid` = %d",
|
q("UPDATE `photo` SET `album` = '%s' WHERE `album` = '%s' AND `uid` = %d",
|
||||||
dbesc($newalbum),
|
dbesc($newalbum),
|
||||||
dbesc($album),
|
dbesc($album),
|
||||||
intval($_SESSION['uid'])
|
intval(get_uid())
|
||||||
);
|
);
|
||||||
$newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']);
|
$newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']);
|
||||||
goaway($a->get_baseurl() . '/' . $newurl);
|
goaway($a->get_baseurl() . '/' . $newurl);
|
||||||
|
@ -199,52 +200,33 @@ function photos_post(&$a) {
|
||||||
|
|
||||||
$title = '';
|
$title = '';
|
||||||
$basename = basename($filename);
|
$basename = basename($filename);
|
||||||
|
$uri = item_new_uri($a->get_hostname(),get_uid());
|
||||||
// Create item container
|
// Create item container
|
||||||
|
|
||||||
$body = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
|
$arr = array();
|
||||||
. '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]'
|
|
||||||
. '[/url]';
|
|
||||||
|
|
||||||
$uri = item_new_uri($a->get_hostname(),get_uid());
|
$arr['uid'] = get_uid();
|
||||||
|
$arr['uri'] = $uri;
|
||||||
|
$arr['parent-uri'] = $uri;
|
||||||
|
$arr['type'] = 'photo';
|
||||||
|
$arr['wall'] = 1;
|
||||||
|
$arr['resource-id'] = $p[0]['resource-id'];
|
||||||
|
$arr['contact-id'] = $contact_record['id'];
|
||||||
|
$arr['owner-name'] = $contact_record['name'];
|
||||||
|
$arr['owner-link'] = $contact_record['url'];
|
||||||
|
$arr['owner-avatar'] = $contact_record['thumb'];
|
||||||
|
$arr['title'] = $title;
|
||||||
|
$arr['allow_cid'] = $p[0]['allow_cid'];
|
||||||
|
$arr['allow_gid'] = $p[0]['allow_gid'];
|
||||||
|
$arr['deny_cid'] = $p[0]['deny_cid'];
|
||||||
|
$arr['deny_gid'] = $p[0]['deny_gid'];
|
||||||
|
$arr['last-child'] = 1;
|
||||||
|
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
|
||||||
|
. '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]'
|
||||||
|
. '[/url]';
|
||||||
|
|
||||||
|
$item_id = item_store($arr);
|
||||||
|
|
||||||
$r = q("INSERT INTO `item` (`uid`, `type`, `wall`, `resource-id`, `contact-id`,
|
|
||||||
`owner-name`,`owner-link`,`owner-avatar`, `created`,
|
|
||||||
`edited`, `changed`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
|
|
||||||
VALUES( %d, '%s', %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
|
|
||||||
intval(get_uid()),
|
|
||||||
dbesc('photo'),
|
|
||||||
intval(1),
|
|
||||||
dbesc($p[0]['resource-id']),
|
|
||||||
intval($contact_record['id']),
|
|
||||||
dbesc($contact_record['name']),
|
|
||||||
dbesc($contact_record['url']),
|
|
||||||
dbesc($contact_record['thumb']),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc($uri),
|
|
||||||
dbesc($uri),
|
|
||||||
dbesc($title),
|
|
||||||
dbesc($body),
|
|
||||||
dbesc($p[0]['allow_cid']),
|
|
||||||
dbesc($p[0]['allow_gid']),
|
|
||||||
dbesc($p[0]['deny_cid']),
|
|
||||||
dbesc($p[0]['deny_gid'])
|
|
||||||
|
|
||||||
);
|
|
||||||
if($r) {
|
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
|
|
||||||
dbesc($uri)
|
|
||||||
);
|
|
||||||
if(count($r))
|
|
||||||
$item_id = $r[0]['id'];
|
|
||||||
q("UPDATE `item` SET `parent` = %d, `last-child` = 1 WHERE `id` = %d LIMIT 1",
|
|
||||||
intval($r[0]['id']),
|
|
||||||
intval($r[0]['id'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("UPDATE `item` SET `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
$r = q("UPDATE `item` SET `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
|
@ -315,8 +297,8 @@ function photos_post(&$a) {
|
||||||
|
|
||||||
$smallest = 0;
|
$smallest = 0;
|
||||||
|
|
||||||
$photo_hash = hash('md5',uniqid(mt_rand(),true));
|
$photo_hash = photo_new_resource();
|
||||||
|
|
||||||
$r = $ph->store(get_uid(), 0, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
$r = $ph->store(get_uid(), 0, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||||
|
|
||||||
if(! $r) {
|
if(! $r) {
|
||||||
|
@ -337,51 +319,35 @@ function photos_post(&$a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$basename = basename($filename);
|
$basename = basename($filename);
|
||||||
|
$uri = item_new_uri($a->get_hostname(), get_uid());
|
||||||
|
|
||||||
// Create item container
|
// Create item container
|
||||||
|
|
||||||
$body = '[url=' . $a->get_baseurl() . '/photos/' . $contact_record['nickname'] . '/image/' . $photo_hash . ']'
|
|
||||||
. '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.jpg" . '[/img]'
|
|
||||||
. '[/url]';
|
|
||||||
|
|
||||||
$uri = item_new_uri($a->get_hostname(), get_uid());
|
$arr = array();
|
||||||
|
|
||||||
$r = q("INSERT INTO `item` (`uid`, `type`, `wall`, `resource-id`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `created`,
|
$arr['uid'] = get_uid();
|
||||||
`edited`, `changed`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `visible`)
|
$arr['uri'] = $uri;
|
||||||
VALUES( %d, '%s', %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d )",
|
$arr['parent-uri'] = $uri;
|
||||||
intval(get_uid()),
|
$arr['type'] = 'photo';
|
||||||
dbesc('photo'),
|
$arr['wall'] = 1;
|
||||||
intval(1),
|
$arr['resource-id'] = $photo_hash;
|
||||||
dbesc($photo_hash),
|
$arr['contact-id'] = $contact_record['id'];
|
||||||
intval($contact_record['id']),
|
$arr['owner-name'] = $contact_record['name'];
|
||||||
dbesc($contact_record['name']),
|
$arr['owner-link'] = $contact_record['url'];
|
||||||
dbesc($contact_record['url']),
|
$arr['owner-avatar'] = $contact_record['thumb'];
|
||||||
dbesc($contact_record['thumb']),
|
$arr['title'] = $title;
|
||||||
dbesc(datetime_convert()),
|
$arr['allow_cid'] = $str_contact_allow;
|
||||||
dbesc(datetime_convert()),
|
$arr['allow_gid'] = $str_group_allow;
|
||||||
dbesc(datetime_convert()),
|
$arr['deny_cid'] = $str_contact_deny;
|
||||||
dbesc($uri),
|
$arr['deny_gid'] = $str_group_deny;
|
||||||
dbesc($uri),
|
$arr['last-child'] = 1;
|
||||||
dbesc($title),
|
$arr['visible'] = $visible;
|
||||||
dbesc($body),
|
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $contact_record['nickname'] . '/image/' . $photo_hash . ']'
|
||||||
dbesc($str_contact_allow),
|
. '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.jpg" . '[/img]'
|
||||||
dbesc($str_group_allow),
|
. '[/url]';
|
||||||
dbesc($str_contact_deny),
|
|
||||||
dbesc($str_group_deny),
|
|
||||||
intval($visible)
|
|
||||||
);
|
|
||||||
if($r) {
|
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
|
$item_id = item_store($arr);
|
||||||
dbesc($uri)
|
|
||||||
);
|
|
||||||
if(count($r))
|
|
||||||
q("UPDATE `item` SET `parent` = %d, `last-child` = 1 WHERE `id` = %d LIMIT 1",
|
|
||||||
intval($r[0]['id']),
|
|
||||||
intval($r[0]['id'])
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(! $java_upload) {
|
if(! $java_upload) {
|
||||||
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
|
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
|
||||||
|
|
|
@ -45,7 +45,7 @@ function profile_photo_post(&$a) {
|
||||||
//dbg(3);
|
//dbg(3);
|
||||||
$r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = %d LIMIT 1",
|
$r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = %d LIMIT 1",
|
||||||
dbesc($image_id),
|
dbesc($image_id),
|
||||||
dbesc($_SESSION['uid']),
|
dbesc(get_uid()),
|
||||||
intval($scale));
|
intval($scale));
|
||||||
|
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
|
@ -55,14 +55,14 @@ function profile_photo_post(&$a) {
|
||||||
$im = new Photo($base_image['data']);
|
$im = new Photo($base_image['data']);
|
||||||
$im->cropImage(175,$srcX,$srcY,$srcW,$srcH);
|
$im->cropImage(175,$srcX,$srcY,$srcW,$srcH);
|
||||||
|
|
||||||
$r = $im->store($_SESSION['uid'], 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, 1);
|
$r = $im->store(get_uid(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, 1);
|
||||||
|
|
||||||
if($r === false)
|
if($r === false)
|
||||||
notice ( t('Image size reduction (175) failed.') . EOL );
|
notice ( t('Image size reduction (175) failed.') . EOL );
|
||||||
|
|
||||||
$im->scaleImage(80);
|
$im->scaleImage(80);
|
||||||
|
|
||||||
$r = $im->store($_SESSION['uid'], 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 5, 1);
|
$r = $im->store(get_uid(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 5, 1);
|
||||||
|
|
||||||
if($r === false)
|
if($r === false)
|
||||||
notice( t('Image size reduction (80) failed.') . EOL );
|
notice( t('Image size reduction (80) failed.') . EOL );
|
||||||
|
@ -71,12 +71,12 @@ function profile_photo_post(&$a) {
|
||||||
|
|
||||||
$r = q("UPDATE `photo` SET `profile` = 0 WHERE `profile` = 1 AND `resource-id` != '%s' AND `uid` = %d",
|
$r = q("UPDATE `photo` SET `profile` = 0 WHERE `profile` = 1 AND `resource-id` != '%s' AND `uid` = %d",
|
||||||
dbesc($base_image['resource-id']),
|
dbesc($base_image['resource-id']),
|
||||||
intval($_SESSION['uid'])
|
intval(get_uid())
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
$r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($_SESSION['uid'])
|
intval(get_uid())
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update global directory in background
|
// Update global directory in background
|
||||||
|
@ -115,12 +115,12 @@ function profile_photo_post(&$a) {
|
||||||
$height = $ph->getHeight();
|
$height = $ph->getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
$hash = hash('md5',uniqid(mt_rand(),true));
|
$hash = photo_new_resource();
|
||||||
|
|
||||||
|
|
||||||
$smallest = 0;
|
$smallest = 0;
|
||||||
|
|
||||||
$r = $ph->store($_SESSION['uid'], 0 , $hash, $filename, t('Profile Photos'), 0 );
|
$r = $ph->store(get_uid(), 0 , $hash, $filename, t('Profile Photos'), 0 );
|
||||||
|
|
||||||
if($r)
|
if($r)
|
||||||
notice( t('Image uploaded successfully.') . EOL );
|
notice( t('Image uploaded successfully.') . EOL );
|
||||||
|
@ -129,7 +129,7 @@ function profile_photo_post(&$a) {
|
||||||
|
|
||||||
if($width > 640 || $height > 640) {
|
if($width > 640 || $height > 640) {
|
||||||
$ph->scaleImage(640);
|
$ph->scaleImage(640);
|
||||||
$r = $ph->store($_SESSION['uid'], 0 , $hash, $filename, t('Profile Photos'), 1 );
|
$r = $ph->store(get_uid(), 0 , $hash, $filename, t('Profile Photos'), 1 );
|
||||||
|
|
||||||
if($r === false)
|
if($r === false)
|
||||||
notice( t('Image size reduction (640) failed.') . EOL );
|
notice( t('Image size reduction (640) failed.') . EOL );
|
||||||
|
|
|
@ -30,11 +30,11 @@ function wall_upload_post(&$a) {
|
||||||
$width = $ph->getWidth();
|
$width = $ph->getWidth();
|
||||||
$height = $ph->getHeight();
|
$height = $ph->getHeight();
|
||||||
|
|
||||||
$hash = hash('md5',uniqid(mt_rand(),true));
|
$hash = photo_new_resource();
|
||||||
|
|
||||||
$smallest = 0;
|
$smallest = 0;
|
||||||
|
|
||||||
$r = $ph->store($_SESSION['uid'], 0, $hash, $filename, t('Wall Photos'), 0 );
|
$r = $ph->store(get_uid(), 0, $hash, $filename, t('Wall Photos'), 0 );
|
||||||
|
|
||||||
if(! $r) {
|
if(! $r) {
|
||||||
echo ( t('Image upload failed.') . EOL);
|
echo ( t('Image upload failed.') . EOL);
|
||||||
|
@ -43,14 +43,14 @@ function wall_upload_post(&$a) {
|
||||||
|
|
||||||
if($width > 640 || $height > 640) {
|
if($width > 640 || $height > 640) {
|
||||||
$ph->scaleImage(640);
|
$ph->scaleImage(640);
|
||||||
$r = $ph->store($_SESSION['uid'], 0, $hash, $filename, t('Wall Photos'), 1 );
|
$r = $ph->store(get_uid(), 0, $hash, $filename, t('Wall Photos'), 1 );
|
||||||
if($r)
|
if($r)
|
||||||
$smallest = 1;
|
$smallest = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($width > 320 || $height > 320) {
|
if($width > 320 || $height > 320) {
|
||||||
$ph->scaleImage(320);
|
$ph->scaleImage(320);
|
||||||
$r = $ph->store($_SESSION['uid'], 0, $hash, $filename, t('Wall Photos'), 2 );
|
$r = $ph->store(get_uid(), 0, $hash, $filename, t('Wall Photos'), 2 );
|
||||||
if($r)
|
if($r)
|
||||||
$smallest = 2;
|
$smallest = 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue