Пример #1
0
     echo get_friends_req_result();
     break;
 case 'get_requests':
     echo get_requests();
     break;
 case 'accept_ignore_request':
     $friend_user_name = $_POST['username'];
     $note_id = $_POST['note_id'];
     if (isset($_POST['ignore']) && ($ignore = 'ignore')) {
         echo accept_ignore_request($friend_user_name, $note_id, $ignore);
         break;
     }
     echo accept_ignore_request($friend_user_name, $note_id);
     break;
 case 'get_all_friends':
     echo get_all_friends();
     break;
 case 'delete_friend':
     $friend_user_name = $_POST['username'];
     echo delete_friend($friend_user_name);
     break;
     //ALL FRIENDS COUNT!!!!
 //ALL FRIENDS COUNT!!!!
 case 'get_new_friend_view':
     echo get_new_friend_view();
     break;
 case 'autocomplete':
     $search_input = $_GET['search_input'];
     echo autocomplete_search($search_input);
     break;
     //default : redirect('../error.php');
Пример #2
0
function get_agent($agenturi)
{
    if ($agenturi) {
        $agent = NULL;
        $store = create_store($agenturi);
        if ($agentrsakey = get_foaf_rsakey($store, $agenturi)) {
            $agent = safe_array_merge($agent, array('RSAKey' => $agentrsakey));
        }
        if ($nyms = get_all_nyms($store, $agenturi)) {
            $agent = safe_array_merge($agent, $nyms);
        } else {
            // Where the san points to a rdf file (not the webid) try to find the primary topic of the rdf file
            if ($primaryuri = get_primary_profile($store)) {
                if (($nyms = get_all_nyms($store, $primaryuri)) || ($nyms = get_all_nyms_sec($store, $primaryuri))) {
                    $agent = safe_array_merge($agent, $nyms);
                    $agenturi = $primaryuri;
                } else {
                    //					print "primaryTopic $primaryuri is not helping<br><br>";
                }
            } else {
                if ($holdaccount = get_online_account($store, $agenturi)) {
                    if ($nyms = get_agent($holdaccount)) {
                        return $nyms;
                    } else {
                        //							print "holdAccount is not helping<br><br>";
                    }
                } else {
                    //							print "holdAccount is missing<br><br>";
                }
            }
        }
        if ($friends = get_all_friends($store, $agenturi)) {
            $agent = safe_array_merge($agent, array('knows' => $friends));
        }
        if ($agent) {
            $agent = safe_array_merge(array("webid" => $agenturi), $agent);
            $agent = array('agent' => $agent);
        }
        return $agent;
    }
}
Пример #3
0
<?php

require 'vendor/autoload.php';
$config = parse_ini_file('/../../../config.ini');
use Elasticsearch\ClientBuilder;
$client = ClientBuilder::create()->build();
$m = new Mustache_Engine(array('loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__) . '/views')));
session_start();
if (isset($_SESSION['auth_user']) && $_SESSION["auth_user"]) {
    echo $m->render('main', get_all_friends());
} else {
    if ($_SESSION['invalid']) {
        echo 'invalid username or password';
    }
    echo $m->render('login-form');
}
function get_all_friends($config)
{
    $client = ClientBuilder::create()->build();
    $params = [];
    $params['index'] = 'friends';
    $params['type'] = 'friends';
    $params['size'] = 1000;
    $params['body']['query']['match_all'] = [$_GET['search']];
    $params['body']['sort'] = ['_score'];
    $result = $client->search($params)['hits']['hits'];
    $sources = array_map(function ($arr) {
        return $arr['_source'];
    }, $result);
    $current_user_location = get_address_from_source(extract_current_user($sources, $_SESSION['user_email']));
    $config = parse_ini_file('/../../../config.ini');