From 5c7ec71442b87855fb1cef8aa53249078e1cdc9e Mon Sep 17 00:00:00 2001 From: Odweta Date: Sun, 7 Jan 2024 16:40:48 +0000 Subject: [PATCH] Sun Jan 7 16:40:48 UTC 2024 --- .gitignore | 0 Makefile | 9 +++-- README.md | 2 +- mobile/App.class | Bin 0 -> 3117 bytes mobile/App.java | 69 +++++++++++++++++++++++++++++++++++++++ mobile/test.php | 29 ++++++++++++++++ requirements.txt | 2 +- src/lib/crypto.py | 0 src/lib/schedule_week.py | 1 + 9 files changed, 105 insertions(+), 7 deletions(-) mode change 100644 => 100755 .gitignore create mode 100644 mobile/App.class create mode 100644 mobile/App.java create mode 100644 mobile/test.php mode change 100644 => 100755 src/lib/crypto.py diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/Makefile b/Makefile index a96cb0c..33bb75a 100755 --- a/Makefile +++ b/Makefile @@ -1,15 +1,14 @@ SHELL=/bin/bash install: - python3 -m pip install -r requirements.txt + python -m pip install -r requirements.txt ./.config/mkdirs.sh - cp ./src/main.py /bin/solen - chmod 774 /bin/solen - chmod 774 /usr/bin/solen + sudo cp ./src/main.py /bin/solen + sudo chown $(USER) /bin/solen - cp ./src/lib/*.py $(HOME)/.local/lib/python3.11/site-packages/solenlib + sudo cp ./src/lib/*.py $(HOME)/.local/lib/python3.10/site-packages/solenlib run: ./.config/launch.sh diff --git a/README.md b/README.md index 4f0bfa7..e9cc4a4 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ An enhanced version of the ŠkolaOnLine (ŠOL) online school system. -It aims to provide more readable data than the web version and remove some of the annoyances of the mobile app. It is intended to be an Android app in the future, but so far it is **only for Linux** (not tested anywhere else). +It aims to provide more readable data than the web version and remove some of the annoyances of the mobile app. It is intended to be and Android app in the future, but so far it is **only for Linux** (not tested anywhere else). Insiration was taken from [@JakubAndrysek](https://github.com/JakubAndrysek)'s [skola-online-stahovani-znamek](https://github.com/JakubAndrysek/skola-online-stahovani-znamek) project. diff --git a/mobile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s~W*`ykF zl5yXW_Ep?JyNX>(Z1)QGte`s+TgBel6+Dp9ld&rH&1SSW5Krn!t&05@uCM*;6+Du2MG|T3WVCnT zG3>?}bYq5`i+BJ}VIL%Vu!w_1mf|Mn yFdFzoOjva9I~D0npp8{Ah*rFh>lQlV_nZyVev3cicXa&Y+{ekeK-!1Gaq0iP_#fc_ literal 0 HcmV?d00001 diff --git a/mobile/App.java b/mobile/App.java new file mode 100644 index 0000000..787c895 --- /dev/null +++ b/mobile/App.java @@ -0,0 +1,69 @@ +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.SocketTimeoutException; +import java.net.URL; +import java.net.URLEncoder; + +public class App { + + public static void main(String[] args) throws IOException { + URL url = new URL("http://127.0.0.1:8080/fetch.php"); + HttpURLConnection client = null; + try { + client = (HttpURLConnection) url.openConnection(); + + // Additional headers + client.setRequestProperty("Connection", "close"); + client.setUseCaches(false); + + // Set the request method to POST + client.setRequestMethod("POST"); + client.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + client.setDoOutput(true); + + // Send the parameters in the request body + String urlParameters = "username=" + URLEncoder.encode("zlevorantonin", "UTF-8") + + "&password=" + URLEncoder.encode("Skolajenej!22", "UTF-8"); + + DataOutputStream wr = new DataOutputStream(client.getOutputStream()); + wr.writeBytes(urlParameters); + wr.flush(); + wr.close(); + + // Get the response code + int responseCode = client.getResponseCode(); + //System.out.println("Response Code: " + responseCode); + + // Read the response body + try (BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()))) { + String inputLine; + StringBuilder response = new StringBuilder(); + + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + + // Print the response body + System.out.println(response.toString()); + } + + } catch (MalformedURLException error) { + // Handles an incorrectly entered URL + System.out.println("malformed URL"); + } catch (SocketTimeoutException error) { + // Handles URL access timeout. + System.out.println("socket timeout"); + } catch (IOException error) { + // Handles input and output errors + System.out.println("IO exception: " + error.getMessage()); + error.printStackTrace(); + } finally { + if (client != null) // Make sure the connection is not null. + client.disconnect(); + } + } +} diff --git a/mobile/test.php b/mobile/test.php new file mode 100644 index 0000000..708501e --- /dev/null +++ b/mobile/test.php @@ -0,0 +1,29 @@ + "x", + 'password' => "y" +]; + +//url-ify the data for the POST +$fields_string = http_build_query($fields); + +//open connection +$ch = curl_init(); + +//set the url, number of POST vars, POST data +curl_setopt($ch,CURLOPT_URL, $url); +curl_setopt($ch,CURLOPT_POST, true); +curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); + +//So that curl_exec returns the contents of the cURL; rather than echoing it +curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); + +//execute post +$result = curl_exec($ch); +echo $result; +?> + diff --git a/requirements.txt b/requirements.txt index 314f890..ccff3a7 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ lxml bs4 requests - +cryptography diff --git a/src/lib/crypto.py b/src/lib/crypto.py old mode 100644 new mode 100755 diff --git a/src/lib/schedule_week.py b/src/lib/schedule_week.py index a5ab4d1..1aee963 100755 --- a/src/lib/schedule_week.py +++ b/src/lib/schedule_week.py @@ -230,6 +230,7 @@ def get_whitespace(password, username, strdata, key: str, idx=0) -> int: except ValueError: pass + print(max_len) return max_len def show_schedule(password, username, local=False):