Skip to content
Snippets Groups Projects
Commit ffd8535b authored by Lucio Zambon's avatar Lucio Zambon
Browse files

Update talk.php

parent bb4772bd
No related branches found
No related tags found
No related merge requests found
......@@ -5,10 +5,33 @@
file_put_contents("./token", $t);
}
if (!empty($_REQUEST['send'])) {
/*
pwma=# CREATE EXTENSION pg_trgm;
pub_types │ character varying(2000)[]
SELECT * FROM mytable WHERE 'give'=ANY(speech_it);
UPDATE launcher SET speech_it = array_append(speech_it, $1) WHERE id = $2
https://puma-01.elettra.eu/lib/fm.php?open_editor=/run/knob/launch_do
nokill
100 100 /runtime/bin/modmulti-gui
*/
$t = file_get_contents("./token");
if ($t != $_REQUEST['token']-0) die('');
if (time() -filectime("./token") > 36000) die('');
file_put_contents("./msg", $_REQUEST['send']);
require_once("../../conf.php");
require_once("../../lib/sql_interface.php");
$sql = open_db();
$query = "SELECT exename FROM launcher WHERE $1=ANY(speech_it)";
$data = $sql->sql_secure($query, array($_REQUEST['send']));
if ($data !== false) {file_put_contents("./msg", $data[0]["exename"]); die("Panel {$data[0]["exename"]} has been opened");}
// die("$query<br>$err<br>\n".json_encode($data));
$query = "SELECT title, description, word_similarity(title, $1) AS ws FROM launcher ORDER BY ws DESC LIMIT 3";
$data = $sql->sql_secure($query, array($_REQUEST['send']));
$err = $sql->sql_error();
header('Content-Type: application/json');
die(json_encode($data));
}
if (isset($_REQUEST['read'])) {
set_time_limit(0);
......@@ -53,12 +76,14 @@
/*$sql->sql_query("INSERT INTO launcher (folder_id, title, description, exename) VALUES (2, 'Jive','Jive','jive')");
echo $sql->last_insert_id();
die();
puma@pwma-dev:~$ sudo psql -U postgres
postgres=# \c pwma
pwma=# CREATE EXTENSION pg_trgm;
puma@pwma-dev:~$ sudo psql -U postgres
postgres=# \c pwma
*/
$context = stream_context_create(array("ssl"=>array("verify_peer"=>false,"verify_peer_name"=>false)));
// /home/fermi/etc/launcher/fermi/launcher_es.conf
// /runtime/etc/browser/fermi.xml
// /runtime/etc/browser/laser.xml
$f = strtr(file_get_contents('https://gitlab.elettra.eu/cs/etc/browser/fermi/-/raw/master/fermi.xml', false, $context), ['exename=""'=>'']);
// var_dump(libxml_use_internal_errors(true));
$xml = simplexml_load_string($f, "SimpleXMLElement", LIBXML_NOERROR | LIBXML_ERR_NONE);
......@@ -88,9 +113,6 @@ pwma=# CREATE EXTENSION pg_trgm;
<div style="max-width: 500px; text-align: center">
<audio id='speechText' onended='speakagain();' onerror='showLog("audio err: "+event.error)'></audio>
<script>
// /home/fermi/etc/launcher/fermi/launcher_es.conf
// /runtime/etc/browser/fermi.xml
// /runtime/etc/browser/laser.xml
if (document.location.search.indexOf('background=')>-1) {
const a = document.location.search.split('background=')[1].split('&')[0];
$('body').css('background-color', +a > 0? '#'+a: a);
......@@ -248,7 +270,10 @@ pwma=# CREATE EXTENSION pg_trgm;
const i = detect_token(transcript, locale[lang].section);
if (i>-1) {
showLog('section: '+i+'--'+transcript.substring(i));
if (transcript.substring(i).length>0) fetch('./talk.php?send=S'+transcript.substring(i)+'&token='+document.location.search.split('talk=')[1].split('&')[0]);
if (transcript.substring(i).length>0) {
const snd = './talk.php?send=S'+transcript.substring(i)+'&token='+document.location.search.split('talk=')[1].split('&')[0];
fetch(snd).then((response) => {return response.json();}).then((rlocale) => {alert(rlocale);});
}
return;
}
// else {showLog('+ '+transcript);}
......
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