Self-Host

To Self-host @ https://link.flossboxin.org.in
This commit is contained in:
vdbhb59 2025-02-21 21:50:36 +05:30
commit c9898cf261
95 changed files with 5217 additions and 0 deletions

View file

@ -0,0 +1,32 @@
<?php
class DefinitionRequest extends EngineRequest {
public function get_request_url() {
$split_query = explode(" ", $this->query);
$reversed_split_q = array_reverse($split_query);
$word_to_define = $reversed_split_q[1] == "define" ? $reversed_split_q[0] : $reversed_split_q[1];
return "https://api.dictionaryapi.dev/api/v2/entries/en/$word_to_define";
}
public function parse_results($response) {
$json_response = json_decode($response, true);
if (!$json_response)
return array();
if (!array_key_exists("title", $json_response))
{
$definition = $json_response[0]["meanings"][0]["definitions"][0]["definition"];
$source = "https://dictionaryapi.dev";
return array(
"special_response" => array(
"response" => htmlspecialchars($definition),
"source" => $source
)
);
}
}
}
?>