Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ test.php
core/config/common.config.php
plugins
sftp-config.json
.project
.project
.vscode/settings.json
120 changes: 33 additions & 87 deletions core/class/script.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,93 +50,6 @@ public static function cron() {

}

public static function shareOnMarket(&$market) {
$cibDir = calculPath(config::byKey('userScriptDir', 'script') . '/' . $market->getLogicalId());
if (!file_exists($cibDir)) {
throw new Exception(__('Impossible de trouver le script :', __FILE__) . $cibDir);
}
$tmp = dirname(__FILE__) . '/../../../../tmp/' . $market->getLogicalId() . '.zip';
if (file_exists($tmp)) {
if (!unlink($tmp)) {
throw new Exception(__('Impossible de supprimer : ', __FILE__) . $tmp . __('. Vérifiez les droits', __FILE__));
}
}
if (!create_zip($cibDir, $tmp)) {
throw new Exception(__('Echec de création du zip. Répertoire source : ', __FILE__) . $cibDir . __(' / Répertoire cible : ', __FILE__) . $tmp);
}
return $tmp;
}

public static function getFromMarket(&$market, $_path) {
$cibDir = calculPath(config::byKey('userScriptDir', 'script'));
if (!file_exists($cibDir)) {
throw new Exception(__('Impossible d\'installer le script. Le dossier n\'existe pas : ', __FILE__) . $cibDir);
}
$zip = new ZipArchive;
$res = $zip->open($_path);
if ($res === true) {
$zip->extractTo($cibDir . '/');
$zip->close();
} else {
switch ($res) {
case ZipArchive::ER_EXISTS:
$ErrMsg = "Le fichier existe déjà.";
break;
case ZipArchive::ER_INCONS:
$ErrMsg = "L'archive est inconsistante.";
break;
case ZipArchive::ER_MEMORY:
$ErrMsg = "Echec d'allocation mémoire (malloc).";
break;
case ZipArchive::ER_NOENT:
$ErrMsg = "Le fichier n'existe pas.";
break;
case ZipArchive::ER_NOZIP:
$ErrMsg = "Ce n'est pas une archive zip.";
break;
case ZipArchive::ER_OPEN:
$ErrMsg = "Le fichier ne peut pas être ouvert.";
break;
case ZipArchive::ER_READ:
$ErrMsg = "Erreur de lecture.";
break;
case ZipArchive::ER_SEEK:
$ErrMsg = "Erreur de recherche.";
break;
default:
$ErrMsg = "Unknow (Code $res)";
break;
}
throw new Exception(__('Impossible de décompresser l\'archive zip : ', __FILE__) . $_path . 'Erreur : ' . $ErrMsg);
}
$scriptPath = realpath(dirname(__FILE__) . '/../../../../' . config::byKey('userScriptDir', 'script') . '/' . $market->getLogicalId());
if (!file_exists($scriptPath)) {
throw new Exception(__('Echec de l\'installation. Impossible de trouver le script ', __FILE__) . $scriptPath);
}
chmod($scriptPath, 0770);
}

public static function removeFromMarket(&$market) {
$scriptPath = calculPath(config::byKey('userScriptDir', 'script') . '/' . $market->getLogicalId());
if (!file_exists($scriptPath)) {
return true;
}
unlink($scriptPath);
if (!file_exists($scriptPath)) {
throw new Exception(__('Echec de la désinstallation. Impossible de supprimer le script ', __FILE__) . $scriptPath);
}
}

public static function listMarketObject() {
$return = array();
foreach (ls(calculPath(config::byKey('userScriptDir', 'script')), '*') as $logical_id) {
if (is_file(calculPath(config::byKey('userScriptDir', 'script')) . '/' . $logical_id)) {
$return[] = $logical_id;
}
}
return $return;
}

/* * *********************Méthodes d'instance************************* */

public function postSave() {
Expand Down Expand Up @@ -390,21 +303,54 @@ public function execute($_options = null) {
}
$json = json_decode($json_str, true);
if ($json === null) {
$json = json_decode($json_str, true, 512, JSON_INVALID_UTF8_IGNORE);
if ($json === null) {
throw new Exception(__('Json invalide ou non décodable : ', __FILE__) . $json_str);
}
}
log::add('script', 'debug', 'tags : ' . $request);
log::add('script', 'debug', 'json : ' . json_encode($json));
$tags = explode('>', $request);
foreach ($tags as $tag) {
$tag = trim($tag);
log::add('script', 'debug', 'tag : ' . $tag);
if (isset($json[$tag])) {
$json = $json[$tag];
} elseif (strpos($tag,'@')!==false && strpos($tag,'=')!==false) {
$tag = ltrim($tag,"@");
$conditions = explode('&', $tag);
foreach ($json as $json_element) {
$found = true;
foreach ($conditions as $condition) {
$condition_kv = explode('=',$condition,2);
$condition_k = trim($condition_kv[0]);
$condition_v = trim($condition_kv[1]);
if ($json_element[$condition_k]==$condition_v) {
$found = $found && true;
} else {
$found = false;
}
}
if ($found) {
$json = $json_element;
break;
}
}
if(!$found) {
$json = '';
log::add('script', 'debug', 'tag not found');
break;
}
} elseif (is_numeric(intval($tag)) && isset($json[intval($tag)])) {
$json = $json[intval($tag)];
} elseif (is_numeric(intval($tag)) && intval($tag) < 0 && isset($json[count($json) + intval($tag)])) {
$json = $json[count($json) + intval($tag)];
} else {
$json = '';
log::add('script', 'debug', 'tag not found');
break;
}
log::add('script', 'debug', 'json : ' . json_encode($json));
}
if($this->getType() == 'info'){
return (is_array($json)) ? json_encode($json) : $json;
Expand Down
5 changes: 5 additions & 0 deletions core/config/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Order allow,deny
<Files ~ "\.(jpg|jpeg|png|gif|pdf|txt|bmp)$">
allow from all
</Files>
Deny from all
50 changes: 26 additions & 24 deletions core/i18n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,29 @@
"Gestion": "Verwaltung",
"Ajouter": "Hinzufügen",
"Configuration": "Konfiguration",
"Market": "Markt",
"Mes Scripts": "Meine Skripte",
"Aucun équipement trouvé, cliquer sur \"Ajouter\" pour commencer": "Keine Ausrüstung gefunden, klicken Sie zum Starten auf \"Hinzufügen\"",
"Rechercher": "Suchen nach",
"Equipement visible": "Sichtbare Ausrüstung",
"Equipement non visible": "Ausrüstung nicht sichtbar",
"Configuration avancée": "Erweiterte Konfiguration",
"Dupliquer": "Duplikat",
"Sauvegarder": "Speichern",
"Supprimer": "Löschen",
"Equipement": "Gerät",
"Commandes": "Befehle",
"Nom de l'équipement script": "Name der Skriptausrüstung",
"Paramètres généraux": "Allgemeine Einstellungen",
"Nom de l'équipement": "Ausrüstungsname",
"Objet parent": "Übergeordnetes Objekt",
"Aucun": "Ohne",
"Catégorie": "Kategorie",
"Options": "Optionen",
"Activer": "Aktivieren",
"Visible": "Sichtbar",
"Auto-actualisation (cron)": "Selbstaktualisierung (cron)",
"Paramètres spécifiques": "Spezifische Parameter",
"Auto-actualisation": "Selbstauffrischung",
"Fréquence de rafraîchissement des commandes infos de l'équipement": "Aktualisierungsrate des Ausrüstungsinfo-Befehls",
"Cliquer sur ? pour afficher l'assistant cron": "Klicke auf ? um den Cron-Helfer anzuzeigen",
"Délai avant d'actualiser les infos suite à une action (en secondes)": "Zeit vor dem Aktualisieren der Informationen nach einer Aktion (in Sekunden)",
"Ajouter une commande script": "Fügen Sie einen Skriptbefehl hinzu",
" Sous type :": "Untertyp:",
Expand All @@ -35,24 +42,25 @@
"Type script": "Skripttyp",
"Type": "Typ",
"Requête": "Petition",
"Options": "Optionen",
"Divers": "Verschiedene",
"Paramètres": "Einstellungen"
"Paramètres": "Einstellungen",
"Etat": "Bundesland",
"Actions": "Anteile"
},
"plugins\/script\/desktop\/js\/script.js": {
"Etes-vous sûr de vouloir supprimer le script :": "Möchten Sie das Skript wirklich löschen:",
"Vous devez d\\'abord sélectioner un script": "Sie müssen zuerst ein Skript auswählen",
"Partager sur le market": "Auf dem Markt Teilen",
"Script": "Skript",
"HTTP": "Http",
"HTML": "HTML",
"XML": "Xml",
"JSON": "Json",
"Nom de la commande": "Befehlsname",
"Choisir une icône": "Wählen Sie ein Symbol aus",
"Commande info liée": "Verknüpfter Info-Befehl",
"Aucune": "Keiner",
"Parcourir": "Reise",
"Editer": "Bearbeiten",
"Nouveau": "Neu",
"Supprimer": "Löschen",
"Partager": "Aktie",
"Vérifier SSL": "Überprüfen Sie SSL",
"Retour vide": "Leere Rückgabe",
"Pas d\\'erreurs": "Keine Fehler",
Expand All @@ -62,16 +70,16 @@
"Maximum d\\'essai": "Maximaler Test",
"Mot de passe": "Passwort",
"Essais au maximum": "Maximale Prüfung",
"Unité": "Unit",
"Afficher": "Anzeige",
"Historiser": "Chronik",
"Inverser": "Umgekehrt",
"Min": "Niedrig",
"Max": "Max",
"Unité": "Unit",
"Liste de valeur|texte séparé par ;": "Werteliste | Text getrennt durch;",
"Liste": "Auflistung",
"Afficher": "Anzeige",
"Historiser": "Chronik",
"Inverser": "Umgekehrt",
"Configuration de la commande": "Befehl Konfiguration",
"Tester": "Test"
"Commande d\\'information à mettre à jour": "Bestellinformationen zu aktualisieren",
"Valeur de l\\'information": "Informationswert"
},
"plugins\/script\/core\/ajax\/script.ajax.php": {
"401 - Accès non autorisé": "401 - Nicht autorisierter Zugriff",
Expand All @@ -87,15 +95,6 @@
"plugins\/script\/core\/class\/script.class.php": {
"Erreur pour ": "Fehler für",
"Expression cron non valide pour ": "Ungültiger Cron-Ausdruck für",
"Impossible de trouver le script :": "Das Skript konnte nicht gefunden werden:",
"Impossible de supprimer : ": "Löschen nicht möglich:",
". Vérifiez les droits": "Überprüfen Sie die Rechte",
"Echec de création du zip. Répertoire source : ": "Fehler beim Erstellen der Zip. Quellverzeichnis:",
" \/ Répertoire cible : ": "\/ Zielverzeichnis:",
"Impossible d\\'installer le script. Le dossier n\\'existe pas : ": "Das Skript kann nicht installiert werden. Der Ordner existiert nicht:",
"Impossible de décompresser l\\'archive zip : ": "Das Zip-Archiv kann nicht dekomprimiert werden:",
"Echec de l\\'installation. Impossible de trouver le script ": "Installation fehlgeschlagen. Das Skript konnte nicht gefunden werden",
"Echec de la désinstallation. Impossible de supprimer le script ": "Deinstallation fehlgeschlagen. Skript kann nicht gelöscht werden",
"Rafraichir": "Aktualisieren",
"Le champ requête ne peut pas être vide": "Das Anforderungsfeld darf nicht leer sein",
"Le champ requête type ne peut pas être vide": "Das Standardanforderungsfeld darf nicht leer sein",
Expand All @@ -104,5 +103,8 @@
"Le message et le sujet ne peuvent pas être vide": "Nachricht und Betreff dürfen nicht leer sein",
"La réponse ne contient pas ": "Die Antwort enthält nicht",
"Json invalide ou non décodable : ": "Json ungültig oder nicht dekodierbar:"
},
"info.json": {
"Plugin ajoutant le support des scripts dans Jeedom. Les scripts sont des programmes en Python\/PHP\/Shell\/Ruby etc... qui permettent d'ajouter des fonctions à Jeedom": "Plugin zur Unterstützung von Skripten in Jeedom. Skripte sind Programme in Python \/ PHP \/ Shell \/ Ruby usw., mit denen Sie Jeedom Funktionen hinzufügen können"
}
}
58 changes: 30 additions & 28 deletions core/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,29 @@
"Gestion": "Management",
"Ajouter": "Add",
"Configuration": "Setup",
"Market": "Market",
"Mes Scripts": "My Scripts",
"Aucun équipement trouvé, cliquer sur \"Ajouter\" pour commencer": "No equipment found, click \"Add\" to start",
"Rechercher": "Search",
"Equipement visible": "Visible equipment",
"Equipement non visible": "Equipment not visible",
"Configuration avancée": "Advanced configuration",
"Dupliquer": "Duplicate",
"Sauvegarder": "Save",
"Supprimer": "Delete",
"Equipement": "Device",
"Equipement": "Equipment",
"Commandes": "Commands",
"Nom de l'équipement script": "Script equipment name",
"Paramètres généraux": "General settings",
"Nom de l'équipement": "Equipment name",
"Objet parent": "Parent object",
"Aucun": "None",
"Catégorie": "Category",
"Options": "Options",
"Activer": "Activate",
"Visible": "Visible",
"Auto-actualisation (cron)": "Self-updating (cron)",
"Paramètres spécifiques": "Specific parameters",
"Auto-actualisation": "Self-refresh",
"Fréquence de rafraîchissement des commandes infos de l'équipement": "Equipment Info Command Refresh Rate",
"Cliquer sur ? pour afficher l'assistant cron": "Click on ? to display the cron helper",
"Délai avant d'actualiser les infos suite à une action (en secondes)": "Time before updating the info following an action (in seconds)",
"Ajouter une commande script": "Add a script command",
" Sous type :": "Sub type:",
Expand All @@ -35,43 +42,44 @@
"Type script": "Script type",
"Type": "Type",
"Requête": "Request",
"Options": "Options",
"Divers": "Various",
"Paramètres": "Settings"
"Paramètres": "Settings",
"Etat": "State",
"Actions": "Shares"
},
"plugins\/script\/desktop\/js\/script.js": {
"Etes-vous sûr de vouloir supprimer le script :": "Are you sure you want to delete the script:",
"Vous devez d\\'abord sélectioner un script": "You must first select a script",
"Partager sur le market": "Share on Market",
"Script": "Script",
"HTTP": "HTTP",
"HTML": "L'opération à mener",
"HTML": "HTML",
"XML": "XML",
"JSON": "JSON",
"Nom de la commande": "Command name",
"Choisir une icône": "Choose an icon",
"Commande info liée": "Linked info command",
"Aucune": "None",
"Parcourir": "Browse",
"Editer": "Edit",
"Nouveau": "New",
"Supprimer": "Delete",
"Partager": "Share",
"Vérifier SSL": "Verify SSL",
"Retour vide": "Empty return",
"Pas d\\'erreurs": "No errors",
"Pas d\\'erreurs": "No error",
"La réponse doit contenir": "The answer must contain",
"Timeout (s)": "Timeout (s)",
"Utilisateur": "User",
"Maximum d\\'essai": "Maximum test",
"Mot de passe": "Password",
"Essais au maximum": "Maximum testing",
"Unité": "Unit",
"Essais au maximum": "Maximum tests",
"Afficher": "Show",
"Historiser": "Historize",
"Inverser": "Invert",
"Min": "Min",
"Max": "Max",
"Unité": "Unit",
"Liste de valeur|texte séparé par ;": "List of values | text separated by;",
"Liste": "List",
"Afficher": "Show",
"Historiser": "Historize",
"Inverser": "Invert",
"Configuration de la commande": "Command setup",
"Tester": "Test"
"Commande d\\'information à mettre à jour": "Order information to update",
"Valeur de l\\'information": "Information value"
},
"plugins\/script\/core\/ajax\/script.ajax.php": {
"401 - Accès non autorisé": "401 - Unauthorized access",
Expand All @@ -87,15 +95,6 @@
"plugins\/script\/core\/class\/script.class.php": {
"Erreur pour ": "Error for",
"Expression cron non valide pour ": "Invalid cron expression for",
"Impossible de trouver le script :": "Unable to find the script:",
"Impossible de supprimer : ": "Unable to delete:",
". Vérifiez les droits": "Check the rights",
"Echec de création du zip. Répertoire source : ": "Failed to create the zip. Source directory:",
" \/ Répertoire cible : ": "\/ Target directory:",
"Impossible d\\'installer le script. Le dossier n\\'existe pas : ": "Unable to install the script. The folder does not exist:",
"Impossible de décompresser l\\'archive zip : ": "Unable to decompress the zip archive:",
"Echec de l\\'installation. Impossible de trouver le script ": "Installation failed. Unable to find the script",
"Echec de la désinstallation. Impossible de supprimer le script ": "Uninstall failed. Unable to delete script",
"Rafraichir": "Refresh",
"Le champ requête ne peut pas être vide": "Request field cannot be empty",
"Le champ requête type ne peut pas être vide": "The standard request field cannot be empty",
Expand All @@ -104,5 +103,8 @@
"Le message et le sujet ne peuvent pas être vide": "Message and subject cannot be empty",
"La réponse ne contient pas ": "The answer does not contain",
"Json invalide ou non décodable : ": "Json invalid or not decodable:"
},
"info.json": {
"Plugin ajoutant le support des scripts dans Jeedom. Les scripts sont des programmes en Python\/PHP\/Shell\/Ruby etc... qui permettent d'ajouter des fonctions à Jeedom": "Plugin adding scripting support in Jeedom. Scripts are programs in Python \/ PHP \/ Shell \/ Ruby etc ... which allow you to add functions to Jeedom"
}
}
Loading