// workaround for HTTP-auth in CGI mode
- if (x($_SERVER,'REDIRECT_REMOTE_USER')) {
+ if(x($_SERVER,'REDIRECT_REMOTE_USER')) {
$userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"],6)) ;
- if (strlen($userpass)) {
+ if(strlen($userpass)) {
list($name, $password) = explode(':', $userpass);
$_SERVER['PHP_AUTH_USER'] = $name;
$_SERVER['PHP_AUTH_PW'] = $password;
call_hooks('authenticate', $addon_auth);
- if (($addon_auth['authenticated']) && (count($addon_auth['user_record']))) {
+ if(($addon_auth['authenticated']) && (count($addon_auth['user_record']))) {
$record = $addon_auth['user_record'];
}
else {
$record = $r[0];
}
- if ((! $record) || (! count($record))) {
+ if((! $record) || (! count($record))) {
logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG);
header('WWW-Authenticate: Basic realm="Friendica"');
#header('HTTP/1.0 401 Unauthorized');
}
}
}
+ logger('API call not implemented: '.$a->query_string);
throw new NotImplementedException();
} catch (HTTPException $e) {
header("HTTP/1.1 {$e->httpcode} {$e->httpdesc}");
logger("api_get_user: Fetching user data for user ".$contact_id, LOGGER_DEBUG);
// Searching for contact URL
- if (!is_null($contact_id) AND (intval($contact_id) == 0)){
+ if(!is_null($contact_id) AND (intval($contact_id) == 0)){
$user = dbesc(normalise_link($contact_id));
$url = $user;
$extra_query = "AND `contact`.`nurl` = '%s' ";
}
// Searching for contact id with uid = 0
- if (!is_null($contact_id) AND (intval($contact_id) != 0)){
+ if(!is_null($contact_id) AND (intval($contact_id) != 0)){
$user = dbesc(api_unique_id_to_url($contact_id));
if ($user == "")
if (api_user()!==false) $extra_query .= "AND `contact`.`uid`=".intval(api_user());
}
- if (is_null($user) && x($_GET, 'user_id')) {
+ if(is_null($user) && x($_GET, 'user_id')) {
$user = dbesc(api_unique_id_to_url($_GET['user_id']));
if ($user == "")
$extra_query = "AND `contact`.`nurl` = '%s' ";
if (api_user()!==false) $extra_query .= "AND `contact`.`uid`=".intval(api_user());
}
- if (is_null($user) && x($_GET, 'screen_name')) {
+ if(is_null($user) && x($_GET, 'screen_name')) {
$user = dbesc($_GET['screen_name']);
$nick = $user;
$extra_query = "AND `contact`.`nick` = '%s' ";
if (is_null($user) AND ($a->argc > (count($called_api)-1)) AND (count($called_api) > 0)){
$argid = count($called_api);
list($user, $null) = explode(".",$a->argv[$argid]);
- if (is_numeric($user)){
+ if(is_numeric($user)){
$user = dbesc(api_unique_id_to_url($user));
if ($user == "")
}
}
- if ($uinfo[0]['self']) {
+ if($uinfo[0]['self']) {
if ($uinfo[0]['network'] == "")
$uinfo[0]['network'] = NETWORK_DFRN;
$starred = $r[0]['count'];
- if (! $uinfo[0]['self']) {
+ if(! $uinfo[0]['self']) {
$countfriends = 0;
$countfollowers = 0;
$starred = 0;
$txt = requestdata('status');
//$txt = urldecode(requestdata('status'));
- if ((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
+ if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
$txt = html2bb_video($txt);
$config = HTMLPurifier_Config::createDefault();
// logger('api_post: ' . print_r($_POST,true));
- if (requestdata('htmlstatus')) {
+ if(requestdata('htmlstatus')) {
$txt = requestdata('htmlstatus');
- if ((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
+ if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
$txt = html2bb_video($txt);
$config = HTMLPurifier_Config::createDefault();
if ($parent == -1)
$parent = "";
- if (ctype_digit($parent))
+ if(ctype_digit($parent))
$_REQUEST['parent'] = $parent;
else
$_REQUEST['parent_uri'] = $parent;
- if (requestdata('lat') && requestdata('long'))
+ if(requestdata('lat') && requestdata('long'))
$_REQUEST['coord'] = sprintf("%s %s",requestdata('lat'),requestdata('long'));
$_REQUEST['profile_uid'] = api_user();
- if ($parent)
+ if($parent)
$_REQUEST['type'] = 'net-comment';
else {
// Check for throttling (maximum posts per day, week and month)
$_REQUEST['type'] = 'wall';
}
- if (x($_FILES,'media')) {
+ if(x($_FILES,'media')) {
// upload the image if we have one
$_REQUEST['hush']='yeah'; //tell wall_upload function to return img info instead of echo
$media = wall_upload_post($a);
- if (strlen($media)>0)
+ if(strlen($media)>0)
$_REQUEST['body'] .= "\n\n".$media;
}
$user_info = api_get_user($a);
- if (!x($_FILES,'media')) {
+ if(!x($_FILES,'media')) {
// Output error
throw new BadRequestException("No media.");
}
$media = wall_upload_post($a, false);
- if (!$media) {
+ if(!$media) {
// Output error
throw new InternalServerErrorException();
}
return false;
}
- if ($qtype == 'friends')
+ if($qtype == 'friends')
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
- if ($qtype == 'followers')
+ if($qtype == 'followers')
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
// friends and followers only for self
$closed = (($a->config['register_policy'] == REGISTER_CLOSED) ? 'true' : 'false');
$private = ((Config::get('system', 'block_public')) ? 'true' : 'false');
$textlimit = (string) (($a->config['max_import_size']) ? $a->config['max_import_size'] : 200000);
- if ($a->config['api_import_size'])
+ if($a->config['api_import_size'])
$texlimit = string($a->config['api_import_size']);
$ssl = ((Config::get('system', 'have_ssl')) ? 'true' : 'false');
$sslserver = (($ssl === 'true') ? str_replace('http:','https:',App::get_baseurl()) : '');
return api_format_data('config', $type, array('config' => $config));
}
+ api_register_func('api/gnusocial/config','api_statusnet_config',false);
api_register_func('api/statusnet/config','api_statusnet_config',false);
function api_statusnet_version($type) {
return api_format_data('version', $type, array('version' => $fake_statusnet_version));
}
+ api_register_func('api/gnusocial/version','api_statusnet_version',false);
api_register_func('api/statusnet/version','api_statusnet_version',false);
/**
$a = get_app();
- if (! api_user()) throw new ForbiddenException();
+ if(! api_user()) throw new ForbiddenException();
$user_info = api_get_user($a);
- if ($qtype == 'friends')
+ if($qtype == 'friends')
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
- if ($qtype == 'followers')
+ if($qtype == 'followers')
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
if (!$user_info["self"])
if ($user_id !="") {
$sql_extra .= ' AND `mail`.`contact-id` = ' . intval($user_id);
}
- elseif ($screen_name !=""){
+ elseif($screen_name !=""){
$sql_extra .= " AND `contact`.`nick` = '" . dbesc($screen_name). "'";
}
);
if ($verbose == "true") {
// stop execution and return error message if no mails available
- if ($r == null) {
+ if($r == null) {
$answer = array('result' => 'error', 'message' => 'no mails available');
return api_format_data("direct_messages_all", $type, array('$result' => $answer));
}
function api_fr_photo_detail($type) {
if (api_user()===false) throw new ForbiddenException();
- if (!x($_REQUEST,'photo_id')) throw new BadRequestException("No photo id.");
+ if(!x($_REQUEST,'photo_id')) throw new BadRequestException("No photo id.");
$scale = (x($_REQUEST, 'scale') ? intval($_REQUEST['scale']) : false);
$scale_sql = ($scale === false ? "" : sprintf("and scale=%d",intval($scale)));
$dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']);
- if ($r[0]['duplex'] && $r[0]['issued-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']) {
+ if($r[0]['duplex'] && $r[0]['dfrn-id']) {
$orig_id = $r[0]['dfrn-id'];
$dfrn_id = '0:' . $orig_id;
}
$multi_profiles = feature_enabled(api_user(),'multi_profiles');
$directory = get_config('system', 'directory');
-// get data of the specified profile id or all profiles of the user if not specified
+ // get data of the specified profile id or all profiles of the user if not specified
if ($profileid != 0) {
$r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d",
intval(api_user()),
// error message if specified gid is not in database
if (!dbm::is_result($r))
throw new BadRequestException("profile_id not available");
- }
- else
+ } else {
$r = q("SELECT * FROM `profile` WHERE `uid` = %d",
intval(api_user()));
-
+ }
// loop through all returned profiles and retrieve data and users
$k = 0;
foreach ($r as $rr) {
}
// return settings, authenticated user and profiles data
+ $self = q("SELECT `nurl` FROM `contact` WHERE `uid`= %d AND `self` LIMIT 1", intval(api_user()));
+
$result = array('multi_profiles' => $multi_profiles ? true : false,
'global_dir' => $directory,
- 'friendica_owner' => api_get_user($a, intval(api_user())),
+ 'friendica_owner' => api_get_user($a, $self[0]['nurl']),
'profiles' => $profiles);
return api_format_data("friendica_profiles", $type, array('$result' => $result));
}