now it gets hard
This commit is contained in:
parent
fb714f9e72
commit
5d23e701c0
86
boot.php
86
boot.php
@ -929,7 +929,8 @@ if(! function_exists('login')) {
|
|||||||
));
|
));
|
||||||
|
|
||||||
$tpl = get_markup_template("login.tpl");
|
$tpl = get_markup_template("login.tpl");
|
||||||
$_SESSION['return_url'] = $a->query_string;
|
if(strlen($a->query_string))
|
||||||
|
$_SESSION['return_url'] = $a->query_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1055,55 +1056,56 @@ if(! function_exists('get_max_import_size')) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if(! function_exists('profile_load')) {
|
if(! function_exists('profile_load')) {
|
||||||
function profile_load(&$a, $nickname, $profile = 0) {
|
function profile_load(&$a, $nickname, $profile = 0) {
|
||||||
if(remote_user()) {
|
if(remote_user()) {
|
||||||
$r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
|
$r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
|
||||||
intval($_SESSION['visitor_id']));
|
intval($_SESSION['visitor_id']));
|
||||||
if(count($r))
|
if(count($r))
|
||||||
$profile = $r[0]['profile-id'];
|
$profile = $r[0]['profile-id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = null;
|
$r = null;
|
||||||
|
|
||||||
if($profile) {
|
if($profile) {
|
||||||
$profile_int = intval($profile);
|
$profile_int = intval($profile);
|
||||||
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
|
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, entity.* FROM `profile`
|
||||||
left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
|
left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN entity ON `profile`.`uid` = entity.entity_id
|
||||||
WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d and `contact`.`self` = 1 LIMIT 1",
|
WHERE entity.entity_address = '%s' AND `profile`.`id` = %d and `contact`.`self` = 1 LIMIT 1",
|
||||||
dbesc($nickname),
|
dbesc($nickname),
|
||||||
intval($profile_int)
|
intval($profile_int)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if((! $r) && (! count($r))) {
|
if((! $r) && (! count($r))) {
|
||||||
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
|
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `entity`.* FROM `profile`
|
||||||
left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
|
left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `entity` ON `profile`.`uid` = entity.entity_id
|
||||||
WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 and `contact`.`self` = 1 LIMIT 1",
|
WHERE entity.entity_address = '%s' AND `profile`.`is-default` = 1 and `contact`.`self` = 1 LIMIT 1",
|
||||||
dbesc($nickname)
|
dbesc($nickname)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($r === false) || (! count($r))) {
|
if(($r === false) || (! count($r))) {
|
||||||
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
|
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
|
||||||
notice( t('Requested profile is not available.') . EOL );
|
notice( t('Requested profile is not available.') . EOL );
|
||||||
$a->error = 404;
|
$a->error = 404;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch user tags if this isn't the default profile
|
// fetch user tags if this isn't the default profile
|
||||||
|
|
||||||
if(! $r[0]['is-default']) {
|
if(! $r[0]['is-default']) {
|
||||||
$x = q("select `pub_keywords` from `profile` where uid = %d and `is-default` = 1 limit 1",
|
$x = q("select `pub_keywords` from `profile` where uid = %d and `is-default` = 1 limit 1",
|
||||||
intval($profile_uid)
|
intval($profile_uid)
|
||||||
);
|
);
|
||||||
if($x && count($x))
|
if($x && count($x))
|
||||||
$r[0]['pub_keywords'] = $x[0]['pub_keywords'];
|
$r[0]['pub_keywords'] = $x[0]['pub_keywords'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->profile = $r[0];
|
$a->profile = $r[0];
|
||||||
|
|
||||||
|
|
||||||
$a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
|
$a->page['title'] = $a->profile['entity_name'] . " @ " . $a->config['sitename'];
|
||||||
$_SESSION['theme'] = $a->profile['theme'];
|
// FIXME
|
||||||
|
$_SESSION['theme'] = $a->profile['theme'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load/reload current theme info
|
* load/reload current theme info
|
||||||
|
@ -31,6 +31,7 @@ function identity_check_service_class($account_id) {
|
|||||||
|
|
||||||
function create_identity($arr) {
|
function create_identity($arr) {
|
||||||
|
|
||||||
|
$a = get_app();
|
||||||
$ret = array('success' => false);
|
$ret = array('success' => false);
|
||||||
|
|
||||||
if(! $arr['account_id']) {
|
if(! $arr['account_id']) {
|
||||||
@ -98,6 +99,93 @@ function create_identity($arr) {
|
|||||||
if(! $r)
|
if(! $r)
|
||||||
logger('create_identity: Unable to store hub location');
|
logger('create_identity: Unable to store hub location');
|
||||||
|
|
||||||
|
$newuid = $ret['entity']['entity_id'];
|
||||||
|
|
||||||
|
$r = q("INSERT INTO `profile` ( `uid`, `profile_name`, `is-default`, `name`, `photo`, `thumb`)
|
||||||
|
VALUES ( %d, '%s', %d, '%s', '%s', '%s') ",
|
||||||
|
intval($ret['entity']['entity_id']),
|
||||||
|
t('default'),
|
||||||
|
1,
|
||||||
|
dbesc($ret['entity']['entity_name']),
|
||||||
|
dbesc($a->get_baseurl() . "/photo/profile/{$newuid}"),
|
||||||
|
dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}")
|
||||||
|
);
|
||||||
|
|
||||||
|
$r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `name-date`, `uri-date`, `avatar-date`, `closeness` )
|
||||||
|
VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', 0 ) ",
|
||||||
|
intval($ret['entity']['entity_id']),
|
||||||
|
datetime_convert(),
|
||||||
|
dbesc($ret['entity']['entity_name']),
|
||||||
|
dbesc($ret['entity']['entity_address']),
|
||||||
|
dbesc($a->get_baseurl() . "/photo/profile/{$newuid}"),
|
||||||
|
dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}"),
|
||||||
|
dbesc($a->get_baseurl() . "/photo/micro/{$newuid}"),
|
||||||
|
dbesc($a->get_baseurl() . "/profile/{$ret['entity']['entity_address']}"),
|
||||||
|
dbesc(datetime_convert()),
|
||||||
|
dbesc(datetime_convert()),
|
||||||
|
dbesc(datetime_convert())
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create a group with no members. This allows somebody to use it
|
||||||
|
// right away as a default group for new contacts.
|
||||||
|
|
||||||
|
require_once('include/group.php');
|
||||||
|
group_add($ret['entity']['entity_id'], t('Friends'));
|
||||||
|
|
||||||
|
|
||||||
|
// if we have no OpenID photo try to look up an avatar
|
||||||
|
// FIXME - we need the top level account email
|
||||||
|
|
||||||
|
$photo = avatar_img($email);
|
||||||
|
$photo = '';
|
||||||
|
|
||||||
|
// unless there is no avatar-plugin loaded
|
||||||
|
if(strlen($photo)) {
|
||||||
|
require_once('include/Photo.php');
|
||||||
|
$photo_failure = false;
|
||||||
|
|
||||||
|
$filename = basename($photo);
|
||||||
|
$img_str = fetch_url($photo,true);
|
||||||
|
// guess mimetype from headers or filename
|
||||||
|
$type = guess_image_type($photo,true);
|
||||||
|
|
||||||
|
|
||||||
|
$img = new Photo($img_str, $type);
|
||||||
|
if($img->is_valid()) {
|
||||||
|
|
||||||
|
$img->scaleImageSquare(175);
|
||||||
|
|
||||||
|
$hash = photo_new_resource();
|
||||||
|
|
||||||
|
$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 );
|
||||||
|
|
||||||
|
if($r === false)
|
||||||
|
$photo_failure = true;
|
||||||
|
|
||||||
|
$img->scaleImage(80);
|
||||||
|
|
||||||
|
$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 5 );
|
||||||
|
|
||||||
|
if($r === false)
|
||||||
|
$photo_failure = true;
|
||||||
|
|
||||||
|
$img->scaleImage(48);
|
||||||
|
|
||||||
|
$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 6 );
|
||||||
|
|
||||||
|
if($r === false)
|
||||||
|
$photo_failure = true;
|
||||||
|
|
||||||
|
if(! $photo_failure) {
|
||||||
|
q("UPDATE `photo` SET `profile` = 1 WHERE `resource-id` = '%s' ",
|
||||||
|
dbesc($hash)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
call_hooks('register_account', $newuid);
|
||||||
|
|
||||||
|
|
||||||
$ret['success'] = true;
|
$ret['success'] = true;
|
||||||
return $ret;
|
return $ret;
|
||||||
|
@ -9,21 +9,16 @@ function profile_init(&$a) {
|
|||||||
|
|
||||||
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
|
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
|
||||||
|
|
||||||
if($a->argc > 1)
|
if(argc() > 1)
|
||||||
$which = $a->argv[1];
|
$which = argv(1);
|
||||||
else {
|
else {
|
||||||
$r = q("select nickname from user where blocked = 0 and account_expired = 0 and verified = 1 order by rand() limit 1");
|
logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
|
||||||
if(count($r)) {
|
notice( t('Requested profile is not available.') . EOL );
|
||||||
goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']);
|
$a->error = 404;
|
||||||
}
|
return;
|
||||||
else {
|
|
||||||
logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
|
|
||||||
notice( t('Requested profile is not available.') . EOL );
|
|
||||||
$a->error = 404;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$profile = 0;
|
$profile = 0;
|
||||||
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
|
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
|
||||||
$which = $a->user['nickname'];
|
$which = $a->user['nickname'];
|
||||||
|
Reference in New Issue
Block a user