now it gets hard
This commit is contained in:
parent
fb714f9e72
commit
5d23e701c0
18
boot.php
18
boot.php
@ -929,6 +929,7 @@ if(! function_exists('login')) {
|
||||
));
|
||||
|
||||
$tpl = get_markup_template("login.tpl");
|
||||
if(strlen($a->query_string))
|
||||
$_SESSION['return_url'] = $a->query_string;
|
||||
}
|
||||
|
||||
@ -1055,7 +1056,7 @@ if(! function_exists('get_max_import_size')) {
|
||||
*/
|
||||
|
||||
if(! function_exists('profile_load')) {
|
||||
function profile_load(&$a, $nickname, $profile = 0) {
|
||||
function profile_load(&$a, $nickname, $profile = 0) {
|
||||
if(remote_user()) {
|
||||
$r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
|
||||
intval($_SESSION['visitor_id']));
|
||||
@ -1067,17 +1068,17 @@ if(! function_exists('profile_load')) {
|
||||
|
||||
if($profile) {
|
||||
$profile_int = intval($profile);
|
||||
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
|
||||
left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
|
||||
WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d and `contact`.`self` = 1 LIMIT 1",
|
||||
$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 entity ON `profile`.`uid` = entity.entity_id
|
||||
WHERE entity.entity_address = '%s' AND `profile`.`id` = %d and `contact`.`self` = 1 LIMIT 1",
|
||||
dbesc($nickname),
|
||||
intval($profile_int)
|
||||
);
|
||||
}
|
||||
if((! $r) && (! count($r))) {
|
||||
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
|
||||
left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
|
||||
WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 and `contact`.`self` = 1 LIMIT 1",
|
||||
$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 `entity` ON `profile`.`uid` = entity.entity_id
|
||||
WHERE entity.entity_address = '%s' AND `profile`.`is-default` = 1 and `contact`.`self` = 1 LIMIT 1",
|
||||
dbesc($nickname)
|
||||
);
|
||||
}
|
||||
@ -1102,7 +1103,8 @@ if(! function_exists('profile_load')) {
|
||||
$a->profile = $r[0];
|
||||
|
||||
|
||||
$a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
|
||||
$a->page['title'] = $a->profile['entity_name'] . " @ " . $a->config['sitename'];
|
||||
// FIXME
|
||||
$_SESSION['theme'] = $a->profile['theme'];
|
||||
|
||||
/**
|
||||
|
@ -31,6 +31,7 @@ function identity_check_service_class($account_id) {
|
||||
|
||||
function create_identity($arr) {
|
||||
|
||||
$a = get_app();
|
||||
$ret = array('success' => false);
|
||||
|
||||
if(! $arr['account_id']) {
|
||||
@ -98,6 +99,93 @@ function create_identity($arr) {
|
||||
if(! $r)
|
||||
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;
|
||||
return $ret;
|
||||
|
@ -9,20 +9,15 @@ function profile_init(&$a) {
|
||||
|
||||
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
|
||||
|
||||
if($a->argc > 1)
|
||||
$which = $a->argv[1];
|
||||
else {
|
||||
$r = q("select nickname from user where blocked = 0 and account_expired = 0 and verified = 1 order by rand() limit 1");
|
||||
if(count($r)) {
|
||||
goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']);
|
||||
}
|
||||
if(argc() > 1)
|
||||
$which = argv(1);
|
||||
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;
|
||||
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
|
||||
|
Reference in New Issue
Block a user