<?php
|
//TODO ELIMINARE
|
/***
|
*
|
* Da base_64 a file
|
* "$ php scripts\generate-string_64.php dGVzdG8gYSBjYXNvIA==
|
* lanciando il comando sopra da terminale la stringa verrà automaticamente convertita all'interno del file "scripts/decoded_files/new_decoded_file.txt"
|
* altrimenti sarà possibile inserire il secondo valore "false" per compiere il l'encode partendo da un file
|
* "$ php scripts\generate-string_64.php C:\User\Documents\filename.txt
|
*
|
* Inserendo come primo parametro un path o una stringa 64 verrà automaticamente fatta la conversione
|
*
|
* //TODO terminare e fare un secondo script che genera l'array con i tre parametri che si attende il tool per ogni file da allegare
|
*
|
* include __DIR__ . '/ParamsBase64.php';
|
*
|
*
|
* $newParams64 = new ParamsBase64();
|
*
|
*
|
* if (isset($argv[1])) {
|
* $newParams64->setStringValue($argv[1]);
|
* }
|
*
|
* if (isset($argv[2])) {
|
* $newParams64->setEncode($argv[2]);
|
* } else if (isset($argv[1]) && is_file($argv[1])) {
|
* $newParams64->setEncode(false);
|
* }
|
*
|
*
|
* function fileToBase64($filePath): string
|
* {
|
* if (!file_exists($filePath)) {
|
* var_dump("File non trovato al path {$filePath}");
|
* die();
|
* }
|
*
|
* $fileContent = file_get_contents($filePath);
|
*
|
* //TODO refactoring
|
* $newFile = fopen( __DIR__ . "\\encoded_files\\new_encoded_file.txt" , "w");
|
* fwrite($newFile, base64_encode($fileContent));
|
* fclose($newFile);
|
*
|
* return base64_encode($fileContent);
|
* }
|
*
|
* function base64ToFile($base64String, $filePath)
|
* {
|
* $decodedData = base64_decode($base64String);
|
* $newFile = fopen($filePath, "w");
|
* fwrite($newFile, $decodedData);
|
* fclose($newFile);
|
* }
|
*
|
* if ($newParams64->isEncode()) {
|
* var_dump("base64ToFile");
|
* base64ToFile($newParams64->getStringValue(), $newParams64->getPath());
|
* } else {
|
* var_dump("fileToBase64");
|
* var_dump("La tua stringa in base64: " . '"' . fileToBase64($newParams64->getStringValue())) . '"';
|
* }
|
*/
|
//TODO ELIMINARE
|
|
include __DIR__ . '/Base64.php';
|
//Base64::encode("C:\Users\Simone Lollini\\decoded_64.txt", true);
|
//Base64::decode("C:\Users\Simone Lollini\\encoded_64.txt", true);
|
//Base64::encode( "test-encoded data",false,true,"C:\Users\Simone Lollini\Desktop\mega-test.txt");
|