Merge pull request #1487 from fabrixxm/projects
new api dfrn/remoteauth, allow plugins to use update_structure
This commit is contained in:
commit
178b7eba1b
|
@ -102,6 +102,9 @@
|
||||||
$password = $_SERVER['PHP_AUTH_PW'];
|
$password = $_SERVER['PHP_AUTH_PW'];
|
||||||
$encrypted = hash('whirlpool',trim($password));
|
$encrypted = hash('whirlpool',trim($password));
|
||||||
|
|
||||||
|
// allow "user@server" login (but ignore 'server' part)
|
||||||
|
$at=strstr($user, "@", true);
|
||||||
|
if ( $at ) $user=$at;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* next code from mod/auth.php. needs better solution
|
* next code from mod/auth.php. needs better solution
|
||||||
|
@ -2666,6 +2669,70 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* similar as /mod/redir.php
|
||||||
|
* redirect to 'url' after dfrn auth
|
||||||
|
*
|
||||||
|
* why this when there is mod/redir.php already?
|
||||||
|
* This use api_user() and api_login()
|
||||||
|
*
|
||||||
|
* params
|
||||||
|
* c_url: url of remote contact to auth to
|
||||||
|
* url: string, url to redirect after auth
|
||||||
|
*/
|
||||||
|
function api_friendica_remoteauth(&$a) {
|
||||||
|
$url = ((x($_GET,'url')) ? $_GET['url'] : '');
|
||||||
|
$c_url = ((x($_GET,'c_url')) ? $_GET['c_url'] : '');
|
||||||
|
|
||||||
|
if ($url === '' || $c_url === '')
|
||||||
|
die((api_error($a, 'json', "Wrong parameters")));
|
||||||
|
|
||||||
|
$c_url = normalise_link($c_url);
|
||||||
|
|
||||||
|
// traditional DFRN
|
||||||
|
|
||||||
|
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `nurl` = '%s' LIMIT 1",
|
||||||
|
dbesc($c_url),
|
||||||
|
intval(api_user())
|
||||||
|
);
|
||||||
|
|
||||||
|
if ((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN))
|
||||||
|
die((api_error($a, 'json', "Unknown contact")));
|
||||||
|
|
||||||
|
$cid = $r[0]['id'];
|
||||||
|
|
||||||
|
$dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']);
|
||||||
|
|
||||||
|
if($r[0]['duplex'] && $r[0]['issued-id']) {
|
||||||
|
$orig_id = $r[0]['issued-id'];
|
||||||
|
$dfrn_id = '1:' . $orig_id;
|
||||||
|
}
|
||||||
|
if($r[0]['duplex'] && $r[0]['dfrn-id']) {
|
||||||
|
$orig_id = $r[0]['dfrn-id'];
|
||||||
|
$dfrn_id = '0:' . $orig_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sec = random_string();
|
||||||
|
|
||||||
|
q("INSERT INTO `profile_check` ( `uid`, `cid`, `dfrn_id`, `sec`, `expire`)
|
||||||
|
VALUES( %d, %s, '%s', '%s', %d )",
|
||||||
|
intval(api_user()),
|
||||||
|
intval($cid),
|
||||||
|
dbesc($dfrn_id),
|
||||||
|
dbesc($sec),
|
||||||
|
intval(time() + 45)
|
||||||
|
);
|
||||||
|
|
||||||
|
logger($r[0]['name'] . ' ' . $sec, LOGGER_DEBUG);
|
||||||
|
$dest = (($url) ? '&destination_url=' . $url : '');
|
||||||
|
goaway ($r[0]['poll'] . '?dfrn_id=' . $dfrn_id
|
||||||
|
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION
|
||||||
|
. '&type=profile&sec=' . $sec . $dest . $quiet );
|
||||||
|
}
|
||||||
|
api_register_func('api/friendica/remoteauth', 'api_friendica_remoteauth', true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function api_share_as_retweet(&$item) {
|
function api_share_as_retweet(&$item) {
|
||||||
$body = trim($item["body"]);
|
$body = trim($item["body"]);
|
||||||
|
|
||||||
|
@ -2884,6 +2951,7 @@ function api_best_nickname(&$contacts) {
|
||||||
$contacts = array($contacts[0]);
|
$contacts = array($contacts[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Not implemented by now:
|
Not implemented by now:
|
||||||
statuses/retweets_of_me
|
statuses/retweets_of_me
|
||||||
|
|
|
@ -120,7 +120,7 @@ function print_structure($database) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_structure($verbose, $action) {
|
function update_structure($verbose, $action, $tables=null, $definition=null) {
|
||||||
global $a, $db;
|
global $a, $db;
|
||||||
|
|
||||||
$errors = false;
|
$errors = false;
|
||||||
|
@ -130,7 +130,8 @@ function update_structure($verbose, $action) {
|
||||||
// Get the current structure
|
// Get the current structure
|
||||||
$database = array();
|
$database = array();
|
||||||
|
|
||||||
$tables = q("show tables");
|
if (is_null($tables))
|
||||||
|
$tables = q("show tables");
|
||||||
|
|
||||||
foreach ($tables AS $table) {
|
foreach ($tables AS $table) {
|
||||||
$table = current($table);
|
$table = current($table);
|
||||||
|
@ -139,7 +140,8 @@ function update_structure($verbose, $action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the definition
|
// Get the definition
|
||||||
$definition = db_definition();
|
if (is_null($definition))
|
||||||
|
$definition = db_definition();
|
||||||
|
|
||||||
// Compare it
|
// Compare it
|
||||||
foreach ($definition AS $name => $structure) {
|
foreach ($definition AS $name => $structure) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user