]> 91.132.146.200 Git - scientia.git/commitdiff
go client edit and edit list commands
authorBanana <mail@bananas-playground.net>
Thu, 25 Jul 2024 20:13:45 +0000 (22:13 +0200)
committerBanana <mail@bananas-playground.net>
Thu, 25 Jul 2024 20:13:45 +0000 (22:13 +0200)
adding get endpoint.php

Signed-off-by: Banana <mail@bananas-playground.net>
client/go-cli/scientia/cmd/edit.go [new file with mode: 0644]
client/go-cli/scientia/cmd/edit_list.go [new file with mode: 0644]
webroot/get.php [new file with mode: 0644]

diff --git a/client/go-cli/scientia/cmd/edit.go b/client/go-cli/scientia/cmd/edit.go
new file mode 100644 (file)
index 0000000..872272e
--- /dev/null
@@ -0,0 +1,38 @@
+package cmd
+
+import (
+       "github.com/spf13/cobra"
+       "os"
+)
+
+/**
+ * scientia
+ *
+ * Copyright 2023 - 2024 Johannes Keßler
+ *
+ * https://www.bananas-playground.net/projekt/scientia/
+ *
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
+ *
+ * You should have received a copy of the
+ * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+ * along with this program.  If not, see http://www.sun.com/cddl/cddl.html
+ */
+
+var editCmd = &cobra.Command {
+       Use: "edit",
+       Short: "Modify an entry",
+       Long: "Edit an existing entry.",
+       Run: func(cmd *cobra.Command, args []string) {
+               if len(args) == 0 {
+                       cmd.Help()
+                       os.Exit(0)
+               }
+       },
+}
+
+func init() {
+       rootCmd.AddCommand(editCmd)
+}
diff --git a/client/go-cli/scientia/cmd/edit_list.go b/client/go-cli/scientia/cmd/edit_list.go
new file mode 100644 (file)
index 0000000..e7adfe2
--- /dev/null
@@ -0,0 +1,45 @@
+package cmd
+
+import (
+       "fmt"
+       "github.com/spf13/cobra"
+)
+
+/**
+ * scientia
+ *
+ * Copyright 2023 - 2024 Johannes Keßler
+ *
+ * https://www.bananas-playground.net/projekt/scientia/
+ *
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
+ *
+ * You should have received a copy of the
+ * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+ * along with this program.  If not, see http://www.sun.com/cddl/cddl.html
+ */
+
+
+// Subcommand of edit
+// to list all available entries
+
+var editListCmd = &cobra.Command {
+       Use:   "list",
+       Short: "List all available entries",
+       Long:  "List all available entries",
+       Run: func(cmd *cobra.Command, args []string) {
+               listEntries()
+       },
+}
+
+func init() {
+       editCmd.AddCommand(editListCmd)
+}
+
+func listEntries() {
+       if FlagVerbose {
+               fmt.Println("Starting to request entries")
+       }
+}
diff --git a/webroot/get.php b/webroot/get.php
new file mode 100644 (file)
index 0000000..c9ae3a3
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+/**
+ * scientia
+ *
+ * Copyright 2023 - 2024 Johannes Keßler
+ *
+ * https://www.bananas-playground.net/projekt/scientia/
+ *
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
+ *
+ * You should have received a copy of the
+ * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+ * along with this program.  If not, see http://www.sun.com/cddl/cddl.html
+ */
+
+/**
+ * get endpoint. Accepts only GET and returns data
+ */
+
+mb_http_output('UTF-8');
+mb_internal_encoding('UTF-8');
+ini_set('error_reporting',-1); // E_ALL & E_STRICT
+
+## check request
+$_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);
+if(!empty($_urlToParse)) {
+    # see http://de2.php.net/manual/en/regexp.reference.unicode.php
+    if(preg_match('/[\p{C}\p{M}\p{Sc}\p{Sk}\p{So}\p{Zl}\p{Zp}]/u',$_urlToParse) === 1) {
+        die('Malformed request. Make sure you know what you are doing.');
+    }
+}
+
+## config
+require_once('config/config.php');
+
+## set the error reporting
+ini_set('log_errors',true);
+ini_set('error_log',PATH_SYSTEMOUT.'/error.log');
+if(DEBUG === true) {
+    ini_set('display_errors',true);
+}
+else {
+    ini_set('display_errors',false);
+}
+
+# time settings
+date_default_timezone_set(TIMEZONE);
+
+# required libs
+require_once('lib/summoner.class.php');