Added free space stat on home page
|
@ -24,7 +24,23 @@ upload_max_filesize = 20M
|
|||
|
||||
## Setup nginx
|
||||
|
||||
```sudo apt install nginx
|
||||
```bash
|
||||
sudo apt install nginx
|
||||
sudo cp /var/Www/chiro-canto/chiro-canto.conf /etc/nginx/sites-available/chiro-canto.conf
|
||||
```
|
||||
Adapt parameter to configuration.
|
||||
|
||||
## Create self-signed certifcates
|
||||
|
||||
```bash
|
||||
sudo dnf install openssl
|
||||
cd /etc/nginx/ssl/
|
||||
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privkey.pem -out cert.pem
|
||||
```
|
||||
|
||||
## Install PhpMyAdmin
|
||||
|
||||
```bash
|
||||
sudo dnf -y install phpMyAdmin
|
||||
sudo mv
|
||||
```
|
||||
|
|
Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 159 KiB |
Before Width: | Height: | Size: 234 KiB After Width: | Height: | Size: 234 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
0
node_modules/colormap/res/res/freesurface-blue.js
generated
vendored
Normal file → Executable file
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
0
node_modules/colormap/res/res/vorticity-turquoise.js
generated
vendored
Normal file → Executable file
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
@ -1,6 +1,57 @@
|
|||
# Queries | Chiro-Canto API v1
|
||||
|
||||
## /api/v1/species
|
||||
## `/api/v1/species`
|
||||
Retrieve informations on species present in Chiro-Canto database
|
||||
### Method: GET
|
||||
### Results: JSON
|
||||
### Method: `GET`
|
||||
### Results: `JSON`
|
||||
|
||||
## `/api/v1/records`
|
||||
### Method: `GET`
|
||||
#### `cURL` command
|
||||
```bash
|
||||
curl -X GET https://chiro-canto.ortion.xyz/api/v1/records
|
||||
```
|
||||
### Results: `JSON`
|
||||
#### Result sample
|
||||
```json
|
||||
{
|
||||
"records": [
|
||||
{
|
||||
"id": 1,
|
||||
"author_id": 9,
|
||||
"recordist_name": "Samuel ORTION",
|
||||
"file_name": "PaRecAR628069_20200526_040726.wav",
|
||||
"url": "https://chiro-canto.ortion.xyz/storage/records/PaRecAR628069_20200526_040726.wav",
|
||||
"license": "CC-by-nc-sa-4.0",
|
||||
"species": "Pipistrellus pipistrellus",
|
||||
"subspecies": "pipistrellus",
|
||||
"sound": {
|
||||
"types": [
|
||||
"echolocation", "buzz"
|
||||
],
|
||||
"duration": "00:22",
|
||||
"sample_rate": 384,
|
||||
"time_expansion": 10
|
||||
},
|
||||
"recorder": {
|
||||
"make": "TeensyRecorder",
|
||||
"model": "ActiveRecorder",
|
||||
"serial": "AR628069",
|
||||
},
|
||||
"location": {
|
||||
"country": "France",
|
||||
"lat": "47.87840601525087",
|
||||
"lng": "0.21813243633005192"
|
||||
},
|
||||
"datetime": {
|
||||
"date": "2020-05-26",
|
||||
"time": "04:07:00"
|
||||
},
|
||||
"remarks": ""
|
||||
},
|
||||
{
|
||||
...
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
define("CALLBACK_URL", "https://chiro-canto.ortion.xyz/api/v1/oauth2/oauth2client.php");
|
||||
define("AUTH_URL", "https://chiro-canto.ortion.xyz/api/v1/oauth2/authorize");
|
||||
define("ACCESS_TOKEN_URL", "https://chiro-canto.ortion.xyz/api/v1/oauth2/token");
|
||||
define("CLIENT_ID", "wsdfdcjdfvsfdvqwdi86Ubdf0");
|
||||
define("CLIENT_SECRET", "g2OKQ9isj2pcaextQdjx5xW3KoAa");
|
||||
define("SCOPE", ""); // optional
|
||||
|
||||
$url = AUTH_URL."?"
|
||||
."response_type=code"
|
||||
."&client_id".urlencode(CLIENT_ID)
|
||||
."&scope=".urlencode(SCOPE)
|
||||
."&redirect_uri".urlencode(CALLBACK_URL)
|
||||
;
|
||||
?>
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
function getToken(){
|
||||
$curl = curl_init();
|
||||
|
||||
$params = array(
|
||||
CURLOPT_URL => ACCESS_TOKEN_URL."?"
|
||||
."code=".$code
|
||||
."&grant_type=authorization_code"
|
||||
."&client_id=". CLIENT_ID
|
||||
."&client_secret=". CLIENT_SECRET
|
||||
."&redirect_uri=". CALLBACK_URL,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_NOBODY => false,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
"cache-control: no-cache",
|
||||
"content-type: application/x-www-form-urlencoded",
|
||||
"accept: *",
|
||||
"accept-encoding: gzip, deflate",
|
||||
),
|
||||
);
|
||||
|
||||
curl_setopt_array($curl, $params);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err) {
|
||||
echo "cURL Error #01: " . $err;
|
||||
} else {
|
||||
$response = json_decode($response, true);
|
||||
if(array_key_exists("access_token", $response)) return $response;
|
||||
if(array_key_exists("error", $response)) echo $response["error_description"];
|
||||
echo "cURL Error #02: Something went wrong! Please contact admin.";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
function fill_record($id, $data) {
|
||||
global $response;
|
||||
$response['records'][$id] = array();
|
||||
$response['records'][$id]['id'] = $data['id'];
|
||||
$response['records'][$id]['author_id'] = $data['author_id'];
|
||||
$response['records'][$id]['recordist_name'] = $data['recordist_name'];
|
||||
$response['records'][$id]['file_name'] = $data['file_name'];
|
||||
$response['records'][$id]['url'] = "https://".$_SERVER['SERVER_NAME']."/storage/records/".$data['file_name'];
|
||||
$response['records'][$id]['license'] = $data['license'];
|
||||
$response['records'][$id]['species'] = $data['species'];
|
||||
$response['records'][$id]['subspecies'] = $data['subspecies'];
|
||||
$response['records'][$id]['sound'] = array();
|
||||
$response['records'][$id]['sound']['type'] = $data['sound_type'];
|
||||
$response['records'][$id]['sound']['duration'] = $data['duration'];
|
||||
$response['records'][$id]['sound']['sample_rate'] = $data['sample_rate'];
|
||||
$response['records'][$id]['sound']['time_expansion'] = $data['time_expansion'];
|
||||
$response['records'][$id]['recorder'] = array();
|
||||
$response['records'][$id]['recorder']['make'] = $data['make'];
|
||||
$response['records'][$id]['recorder']['model'] = $data['model'];
|
||||
$response['records'][$id]['recorder']['serial'] = $data['serial'];
|
||||
$response['records'][$id]['location'] = array();
|
||||
$response['records'][$id]['location']['country'] = $data['country'];
|
||||
$response['records'][$id]['location']['lat'] = $data['lat'];
|
||||
$response['records'][$id]['location']['lng'] = $data['lng'];
|
||||
$response['records'][$id]['datetime'] = array();
|
||||
$response['records'][$id]['datetime']['date'] = $data['date'];
|
||||
$response['records'][$id]['datetime']['time'] = $data['time'];
|
||||
$response['records'][$id]['remarks'] = $data['remarks'];
|
||||
}
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
session_start();
|
||||
header("Content-Type: application/json");
|
||||
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
|
||||
require "$root/database/credentials.php";
|
||||
// Connect the database
|
||||
try{
|
||||
$db = new PDO("mysql:host=$host;dbname=$database;charset=utf8",
|
||||
$user,
|
||||
$password,
|
||||
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||
));
|
||||
}catch (Exception $e){
|
||||
die("Error : ".$e->getMessage());
|
||||
}
|
||||
|
||||
$response = array();
|
||||
|
||||
if (isset($_GET['id'])) {
|
||||
$req = $db->prepare('SELECT * FROM records WHERE id=:id');
|
||||
$req->execute(array(
|
||||
"id"=>$_GET['id']
|
||||
));
|
||||
if ($data = $req->fetch()) {
|
||||
$response['records'] = array();
|
||||
fill_record(0, $data);
|
||||
} else {
|
||||
$response['status'] = "Not found";
|
||||
$response['message'] = "Can't fetch data for this record id.";
|
||||
}
|
||||
} else {
|
||||
$req = $db->prepare('SELECT * FROM records');
|
||||
$req->execute();
|
||||
$result = $req->fetchAll();
|
||||
$i = 0;
|
||||
foreach($result as $row) {
|
||||
fill_record($i, $row);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
Can't render this file because it is too large.
|
|
@ -21,8 +21,27 @@ include("$root/analytics/matomo.php");
|
|||
<?php include("$root/menu.php");?>
|
||||
<?php include("$root/header.php");?>
|
||||
<section>
|
||||
<h3>Explore</h3>
|
||||
<ul>
|
||||
<h2>Explore</h2>
|
||||
<div class="explore wrapper">
|
||||
<div class="list">
|
||||
<a href="/explore/list"><img src="/media/icons/list.png" alt="list"></a>
|
||||
</div>
|
||||
<div class="spectro">
|
||||
<a href="/explore/spectrograms"><img src="/media/pictures/spectrogram.png" alt="spectrogram"></a>
|
||||
</div>
|
||||
<div class="mystery">
|
||||
<a href="/explore/mysteries"><img src="/media/icons/mystery.png" alt=""></a>
|
||||
</div>
|
||||
|
||||
<div class="larynx">
|
||||
<a href="/larynx"><img src="/media/icons/larynx.png" alt="human larynx"></a>
|
||||
</div>
|
||||
<div class="search">
|
||||
<a href="/explore/search"><img src="/media/icons/search.png" alt="search"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <ul>
|
||||
<a href="list">
|
||||
<li>List Uploaded Recording</li>
|
||||
</a>
|
||||
|
@ -38,7 +57,7 @@ include("$root/analytics/matomo.php");
|
|||
<a href="random">
|
||||
<li>Random Recording</li>
|
||||
</a>
|
||||
</ul>
|
||||
</ul> -->
|
||||
</section>
|
||||
<?php include("$root/footer.php");?>
|
||||
</body>
|
||||
|
|