Commit 2daa558e authored by David Libeau's avatar David Libeau

Add log system and fix activitypub bug

parent 26d6e1af
<?php
require("autoload.php");
$logEnabled=true;
if(isset($_GET["q"]) && $_GET["q"]!=""){
if($logEnabled){
$headers = apache_request_headers();
$echolog="";
foreach ($headers as $header => $value) {
$echolog.="$header: $value\n";
}
file_put_contents("../log/".date("d-m-Y").".txt",date("h:i:sa")." : ".$_SERVER["REQUEST_URI"]."\r".$echolog."\r",FILE_USE_INCLUDE_PATH | FILE_APPEND);
}
$core=new Core();
$core->welcome($_GET["q"]);
}
......
......@@ -123,12 +123,12 @@ class Core{
header('Content-type: application/json;charset=utf-8');
echo(json_encode(array(
"subject" => join(":", $query),
"links" => array(
"links" => array(array(
"rel" => "self",
"href" => "https://".$this->get("domain")."/account/".$username,
"type" => "application/activity+json",
),
"aliases" => "https://".$this->get("domain")."/account/".$username,
)),
"aliases" => array("https://".$this->get("domain")."/account/".$username),
)));
}else{
$this->error("404");
......
......@@ -59,6 +59,7 @@ class User{
$activityjson=array(
"@context" => array(
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
),
"id" => "https://".$core->get("domain")."/account/".$this->id,
"type" => "Person",
......@@ -69,7 +70,13 @@ class User{
"preferredUsername" => "David",
"name" => "".$this->name,
"summary" => "<p>".$this->description."</p>",
"manuallyApprovesFollowers" => false,
"url" => "https://".$core->get("domain")."/account/".$this->id,
"publicKey" => array(
"id" => "https://".$core->get("domain")."/account/".$this->id."#main-key",
"owner" => "https://".$core->get("domain")."/account/".$this->id,
"publicKeyPem" => "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyJAjDVrhKSGRQaG8Z59E\nHB7Q7c58pYOGmEpzV2Vrboi9A0EOOH7qrmVsnuncPOoxd31z3cwAQyCz+WkXVsG5\npUbvG3XjzUQKXSwOUemg8jCJ7/JHrqCpaSX5f4i028F+eNX8yjuYlj208COk37qz\nR96p2Nvzm+3RSodcYIf0qEi2d0x+cmoDSMSf3K/AdkgKIi5IA02kStOAt1bXnpeA\nhw0bdMGjq+z6B083zfZKi4Ya6s51fh/kV/dB/K4VxNsKaMXUhwk/558x5v43OiuO\ntBP4bbJwJm8txCt2eG3WxoDxbZvRbenp4DK4P6F0JLi42oVRWnGTcTKzt0F3KK4d\njQIDAQAB\n-----END PUBLIC KEY-----\n",
),
"icon" => array(
"type" => "Image",
"mediaType" => "image/jpeg",
......@@ -80,8 +87,11 @@ class User{
"mediaType" => "image/jpeg",
"url" => "https://".$core->get("domain")."/account/".$this->id."/header.jpg",
),
"endpoints" => array(
"sharedInbox" => "https://".$core->get("domain")."/account/".$this->id."/inbox",
),
);
View::render("json",$activityjson);
View::render("activityjson",$activityjson);
}
public function viewFollowing($id){
global $core;
......@@ -99,7 +109,7 @@ class User{
"type" => "OrderedCollection",
"totalItems" => 0,
);
View::render("json",$activityjson);
View::render("activityjson",$activityjson);
}
public function viewFollowers($id){
global $core;
......@@ -117,7 +127,7 @@ class User{
"type" => "OrderedCollection",
"totalItems" => 0,
);
View::render("json",$activityjson);
View::render("activityjson",$activityjson);
}
public function viewOutbox($id){
global $core;
......@@ -135,9 +145,26 @@ class User{
"type" => "OrderedCollection",
"totalItems" => 0,
);
View::render("json",$activityjson);
View::render("activityjson",$activityjson);
}
public function viewInbox($id){
global $core;
$this->init($id);
/*
viewFollowers : view inbox in Activity Pub json format
@param: $id
*/
$activityjson=array(
"@context" => array(
"https://www.w3.org/ns/activitystreams",
),
"id" => "https://".$core->get("domain")."/account/".$this->id,
"type" => "OrderedCollection",
"totalItems" => 0,
);
View::render("activityjson",$activityjson);
}
public function dump($id) {
$this->init($id);
......
......@@ -10,6 +10,9 @@ class View{
}else if($viewName=="json"){
header('Content-type: application/json;charset=utf-8');
echo(json_encode($object));
}else if($viewName=="activityjson"){
header('Content-type: application/activity+json');
echo(json_encode($object));
}else if($viewName=="image"){
header('Content-type: image/jpeg;charset=utf-8');
echo($object);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment