mirror of https://git.42l.fr/neil/sncf.git
36 changed files with 2977 additions and 0 deletions
@ -0,0 +1,23 @@
|
||||
[package] |
||||
name = "sncf" |
||||
version = "1.0.0" |
||||
authors = ["Association 42l <contact@noreply.example.org>"] |
||||
edition = "2018" |
||||
|
||||
[dependencies] |
||||
actix-rt = "1.0.0" |
||||
actix-web = "3.0.0-beta.3" |
||||
actix-files = "0.3.0-beta.1" |
||||
diesel = { version = "1.4", features = ["sqlite", "r2d2", "chrono"] } |
||||
diesel_migrations = "1.4" |
||||
url = "2.0" |
||||
toml = "0.5" |
||||
lazy_static = "1.4" |
||||
serde = "1.0" |
||||
serde_json = "1.0" |
||||
serde_derive = "1.0" |
||||
chrono = { version = "0.4", features = ["serde"] } |
||||
regex = "1.3" |
||||
base64 = "0.12" |
||||
rand = "0.7" |
||||
askama = "0.10" |
@ -0,0 +1,141 @@
|
||||
Adorable |
||||
Adventurous |
||||
Aggressive |
||||
Agreeable |
||||
Ambitious |
||||
Amused |
||||
Annoying |
||||
Ashy |
||||
Attractive |
||||
Beautiful |
||||
Better |
||||
Black |
||||
Blue |
||||
Blushing |
||||
Brave |
||||
Bright |
||||
Busy |
||||
Calm |
||||
Careful |
||||
Cautious |
||||
Charming |
||||
Cheerful |
||||
Clever |
||||
Clumsy |
||||
Colorful |
||||
Combative |
||||
Confident |
||||
Cooperative |
||||
Courageous |
||||
Crazy |
||||
Creative |
||||
Creepy |
||||
Cruel |
||||
Curious |
||||
Cute |
||||
Dangerous |
||||
Dark |
||||
Dazzling |
||||
Delightful |
||||
Determined |
||||
Different |
||||
Distinct |
||||
Dizzy |
||||
Eager |
||||
Elegant |
||||
Embarrassed |
||||
Enchanting |
||||
Encouraging |
||||
Energetic |
||||
Enthusiastic |
||||
Evil |
||||
Excited |
||||
Fair |
||||
Faithful |
||||
Famous |
||||
Fancy |
||||
Fantastic |
||||
Fierce |
||||
Fine |
||||
Friendly |
||||
Funny |
||||
Gentle |
||||
Gifted |
||||
Glad |
||||
Glamorous |
||||
Gleaming |
||||
Glorious |
||||
Good |
||||
Gorgeous |
||||
Graceful |
||||
Gray |
||||
Green |
||||
Grumpy |
||||
Handsome |
||||
Happy |
||||
Hardy |
||||
Healthy |
||||
Helpful |
||||
Hilarious |
||||
Homely |
||||
Hungry |
||||
Icy |
||||
Important |
||||
Innocent |
||||
Inquisitive |
||||
Jolly |
||||
Joyful |
||||
Joyous |
||||
Kind |
||||
Lazy |
||||
Light |
||||
Lively |
||||
Lovely |
||||
Loving |
||||
Lucky |
||||
Magnificent |
||||
Marvelous |
||||
Misty |
||||
Modern |
||||
Muscular |
||||
Mysterious |
||||
Nice |
||||
Obedient |
||||
Optimistic |
||||
Orange |
||||
Outstanding |
||||
Perfect |
||||
Pleasant |
||||
Polite |
||||
Powerful |
||||
Precious |
||||
Proud |
||||
Purple |
||||
Red |
||||
Scary |
||||
Shiny |
||||
Shy |
||||
Silly |
||||
Skinny |
||||
Sleepy |
||||
Smiling |
||||
Sparkling |
||||
Splendid |
||||
Spotless |
||||
Stormy |
||||
Strange |
||||
Super |
||||
Talented |
||||
Tenacious |
||||
Thankful |
||||
Thoughtful |
||||
Tired |
||||
Tough |
||||
Unusual |
||||
Victorious |
||||
Vivacious |
||||
White |
||||
Wild |
||||
Witty |
||||
Wonderful |
||||
Yellow |
@ -0,0 +1,26 @@
|
||||
# The address and port sncf will listen |
||||
listening_address = "0.0.0.0" |
||||
listening_port = 8000 |
||||
|
||||
# Public-facing domain for sncf. |
||||
# includes protocol, FQDN and port, without the trailing slash. |
||||
sncf_url = "http://localhost:8000" |
||||
|
||||
# path to the SQLite DB |
||||
database_path = "./db/sncf.sqlite" |
||||
|
||||
# IP address of the Nextcloud instance, including protocol and port |
||||
nextcloud_url = "http://10.0.0.0" |
||||
|
||||
# Nextcloud admin account |
||||
admin_username = "adminusername" |
||||
admin_password = "adminverylongandsecurepassword" |
||||
|
||||
# How many days of inactivity for an admin token before deleting NC accounts |
||||
prune_days = 150 |
||||
|
||||
# Displays route names and a lot of information |
||||
debug_mode = true |
||||
|
||||
# Don't touch this unless you know what you're doing |
||||
config_version = 1 |
@ -0,0 +1,322 @@
|
||||
{ |
||||
"lang_code": { |
||||
"en": "en", |
||||
"fr": "fr" |
||||
}, |
||||
"lang_full": { |
||||
"en": "English", |
||||
"fr": "Franรงais" |
||||
}, |
||||
"meta_description": { |
||||
"en": "42l Forms : create forms for free, without registration while protecting your privacy", |
||||
"fr": "42l Formulaires (Forms) : crรฉez des formulaires ou questionnaires gratuitement, sans inscription et dans le respect de votre vie privรฉe" |
||||
}, |
||||
"index_title": { |
||||
"en": "42l Forms", |
||||
"fr": "42l Formulaires" |
||||
}, |
||||
"index_description": { |
||||
"en": "Create forms without registration", |
||||
"fr": "Crรฉez des questionnaires sans inscription" |
||||
}, |
||||
"index_beta_tag": { |
||||
"en": "BETA", |
||||
"fr": "BETA" |
||||
}, |
||||
"index_createform_button": { |
||||
"en": "Create a form", |
||||
"fr": "Crรฉer un formulaire" |
||||
}, |
||||
"index_beta_banner_title": { |
||||
"en": "Warning: Service in beta.", |
||||
"fr": "Attention : Service en bรชta." |
||||
}, |
||||
"index_beta_banner_desc1": { |
||||
"en": "This service is currently under development and might behave in an unexpected way.", |
||||
"fr": "Ce service est en cours de dรฉveloppement et pourrait se comporter de maniรจre inattendue." |
||||
}, |
||||
"index_beta_banner_desc2": { |
||||
"en": "Feel free to send feedbacks on our ", |
||||
"fr": "Vous pouvez nous envoyer vos retours sur " |
||||
}, |
||||
"index_beta_banner_desc_link": { |
||||
"en": "our contact page", |
||||
"fr": "notre page de contact" |
||||
}, |
||||
"index_disclaimer1": { |
||||
"en": "This service is maintained for free, without subscription nor advertising nor tracking or selling of your personal data, on a server hosted in France.", |
||||
"fr": "Ce service vous est fourni gratuitement, sans inscription, sans publicitรฉs, sans pistage ou revente de vos donnรฉes personnelles, sur un serveur hรฉbergรฉ en France." |
||||
}, |
||||
"index_disclaimer2": { |
||||
"en": "If you appreciate our work, please consider donating to ", |
||||
"fr": "Si vous apprรฉciez notre travail, merci d'envisager de faire un don ร " |
||||
}, |
||||
"index_disclaimer2_link_org": { |
||||
"en": "the 42l association", |
||||
"fr": "l'association 42l" |
||||
}, |
||||
"index_disclaimer2_or": { |
||||
"en": " or ", |
||||
"fr": " ou ร " |
||||
}, |
||||
"index_disclaimer2_nc": { |
||||
"en": "Nextcloud", |
||||
"fr": "Nextcloud" |
||||
}, |
||||
"index_panel1_title": { |
||||
"en": "Responsive and intuitive interface", |
||||
"fr": "Interface intuitive et compatible mobile" |
||||
}, |
||||
"index_panel1_desc1": { |
||||
"en": "Are you searching for a privacy-friendly alternative to Google Forms while keeping its ease of use?", |
||||
"fr": "Cherchez-vous une alternative รฉthique ร Google Forms qui reste simple d'utilisation ?" |
||||
}, |
||||
"index_panel1_desc2": { |
||||
"en": "You've just found it.", |
||||
"fr": "Vous venez de la trouver." |
||||
}, |
||||
"index_panel2_title": { |
||||
"en": "Choose and order your fields", |
||||
"fr": "Choisissez et ordonnez vos champs" |
||||
}, |
||||
"index_panel2_desc1": { |
||||
"en": "The software currently supports five field types.", |
||||
"fr": "Pour le moment, le logiciel supporte cinq types de champs." |
||||
}, |
||||
"index_panel2_desc2": { |
||||
"en": "New field types are ", |
||||
"fr": "De nouveaux types de champs sont " |
||||
}, |
||||
"index_panel2_desc2_link": { |
||||
"en": "currently in the works", |
||||
"fr": "en cours d'รฉlaboration" |
||||
}, |
||||
"index_panel3_title": { |
||||
"en": "Analyze the answers", |
||||
"fr": "Analysez les rรฉponses" |
||||
}, |
||||
"index_panel3_desc1": { |
||||
"en": "See detailed graphs of the answers to your form.", |
||||
"fr": "Visualisez les rรฉponses ร votre formulaire avec un graphique." |
||||
}, |
||||
"index_panel4_title": { |
||||
"en": "Export the answers", |
||||
"fr": "Exportez les rรฉponses" |
||||
}, |
||||
"index_panel4_desc1": { |
||||
"en": "Export the raw data of your form in CSV format to integrate the answers in other software (e.g. LibreOffice Calc or Microsoft Excel).", |
||||
"fr": "Exportez les donnรฉes brutes de votre formulaire en format CSV pour intรฉgrer les rรฉponses dans d'autres logiciels (ex. LibreOffice Calc ou Microsoft Excel)." |
||||
}, |
||||
"index_panel5_title": { |
||||
"en": "Edit your form's settings", |
||||
"fr": "Paramรฉtrez vos formulaires" |
||||
}, |
||||
"index_panel5_desc1": { |
||||
"en": "Use the share link to send your form to other people.", |
||||
"fr": "Utilisez le lien de partage pour envoyer votre formulaire ร d'autres personnes." |
||||
}, |
||||
"index_panel5_desc2": { |
||||
"en": "You can also define an expiration date for your form.", |
||||
"fr": "Vous pouvez รฉgalement dรฉfinir une date d'expiration pour votre formulaire." |
||||
}, |
||||
"index_panel6_title": { |
||||
"en": "All your forms in one place", |
||||
"fr": "Tous vos formulaires au mรชme endroit" |
||||
}, |
||||
"index_panel6_desc1": { |
||||
"en": "Find all your forms in the same panel.", |
||||
"fr": "Retrouvez tous vos formulaires sur un mรชme panel." |
||||
}, |
||||
"index_bottom_docs": { |
||||
"en": "Documentation", |
||||
"fr": "Documentation" |
||||
}, |
||||
"index_bottom_source": { |
||||
"en": "Source code", |
||||
"fr": "Code source" |
||||
}, |
||||
"index_bottom_lic": { |
||||
"en": "License", |
||||
"fr": "Licence" |
||||
}, |
||||
"index_credits_title": { |
||||
"en": "Credits", |
||||
"fr": "Crรฉdits" |
||||
}, |
||||
"index_credits_desc1": { |
||||
"en": "The Nextcloud software suite and the Nextcloud Forms application has been developed by ", |
||||
"fr": "La suite logicielle Nextcloud et l'application Nextcloud Forms a รฉtรฉ dรฉveloppรฉe par " |
||||
}, |
||||
"index_credits_desc1_link": { |
||||
"en": "the Nextcloud team", |
||||
"fr": "l'รฉquipe Nextcloud" |
||||
}, |
||||
"index_credits_desc1_a": { |
||||
"en": " and its contributors.", |
||||
"fr": " et ses contributeurยทices." |
||||
}, |
||||
"index_credits_desc2": { |
||||
"en": "The Simple Nextcloud Forms software, which simplifies the form creation process, has been developed by ", |
||||
"fr": "Le logiciel Simple Nextcloud Forms, qui simplifie la crรฉation de formulaires, a รฉtรฉ dรฉveloppรฉ par " |
||||
}, |
||||
"index_credits_desc2_for": { |
||||
"en": " for ", |
||||
"fr": " pour " |
||||
}, |
||||
"index_credits_desc2_org": { |
||||
"en": "the 42l association", |
||||
"fr": "l'association 42l" |
||||
}, |
||||
"index_credits_desc3": { |
||||
"en": "(sources available soon)", |
||||
"fr": "(sources bientรดt disponibles)" |
||||
}, |
||||
"link_title": { |
||||
"en": "Link created", |
||||
"fr": "Lien crรฉรฉ" |
||||
}, |
||||
"link_desc1": { |
||||
"en": "Here's an <b>administration link</b>, which will allow you to access all your forms and check your answers.", |
||||
"fr": "Voici un <b>lien d'administration</b>, qui vous permettra d'accรฉder ร tous vos formulaires et de consulter vos rรฉponses." |
||||
}, |
||||
"link_desc2": { |
||||
"en": "<b>Keep it</b> carefully and don't give it away (it'd be the same as giving out your password!).", |
||||
"fr": "<b>Conservez-le</B> bien prรฉcieusement et ne le donnez pas (cela reviendrait ร donner un mot de passe !)." |
||||
}, |
||||
"link_desc3": { |
||||
"en": "Once your link copied, click on the button below to start editing your forms.", |
||||
"fr": "Une fois votre lien copiรฉ, cliquez sur le bouton ci-dessous pour commencer ร รฉditer vos formulaires." |
||||
}, |
||||
"link_access_btn": { |
||||
"en": "Access the forms", |
||||
"fr": "Accรฉder aux formulaires" |
||||
}, |
||||
"link_note": { |
||||
"en": "Note: If you don't use your administration link during more than ", |
||||
"fr": "Note : Si vous n'utilisez pas votre lien d'administration pendant plus de " |
||||
}, |
||||
"link_note2": { |
||||
"en": " days, your forms will be automatically deleted.", |
||||
"fr": " jours, vos formulaires seront automatiquement supprimรฉs." |
||||
}, |
||||
"link_copy": { |
||||
"en": "Copy link", |
||||
"fr": "Copier le lien" |
||||
}, |
||||
"link_copied": { |
||||
"en": "Link copied!", |
||||
"fr": "Lien copiรฉ !" |
||||
}, |
||||
"error_title": { |
||||
"en": "Oops!...", |
||||
"fr": "Oups !..." |
||||
}, |
||||
"error_description": { |
||||
"en": "The application encountered a problem:", |
||||
"fr": "L'application a rencontrรฉ un problรจme :" |
||||
}, |
||||
"error_back": { |
||||
"en": "Back to the main page", |
||||
"fr": "Retour ร la page principale" |
||||
}, |
||||
"error_note1": { |
||||
"en": "We are (probably) aware of this bug, but feel free to contact us if you need assistance.", |
||||
"fr": "Nous sommes (probablement) au courant, mais n'hรฉsitez pas ร nous contacter si vous avez besoin d'aide." |
||||
}, |
||||
"error_note2": { |
||||
"en": "Sorry for the inconvenience.", |
||||
"fr": "Dรฉsolรฉs pour les dรฉsagrรฉments occasionnรฉs." |
||||
}, |
||||
"error_forward_req": { |
||||
"en": "Error while connecting to the Nextcloud instance.", |
||||
"fr": "Erreur lors de la connexion ร l'instance Nextcloud." |
||||
}, |
||||
"error_forward_resp": { |
||||
"en": "Error while reading Nextcloud instance's response.", |
||||
"fr": "Erreur lors de la lecture de la rรฉponse de l'instance Nextcloud." |
||||
}, |
||||
"error_forward_isanon": { |
||||
"en": "Couldn't set the form's isAnonymous value.", |
||||
"fr": "รchec lors de la dรฉfinition de la valeur isAnonymous du formulaire." |
||||
}, |
||||
"error_forwardlogin_db": { |
||||
"en": "Couldn't connect to the local database.", |
||||
"fr": "รchec lors de la connexion ร la base de donnรฉes locale." |
||||
}, |
||||
"error_forwardlogin_db_get": { |
||||
"en": "Error during information retrieval from the local database.", |
||||
"fr": "Erreur lors de la rรฉcupรฉration des informations dans la base de donnรฉes locale." |
||||
}, |
||||
"error_login_get": { |
||||
"en": "The account creation request (GET) to Nextcloud has failed.", |
||||
"fr": "La requรชte de crรฉation de compte (GET) vers l'instance Nextcloud a รฉchouรฉ." |
||||
}, |
||||
"error_login_get_body": { |
||||
"en": "Reading response from the account creation request to Nextcloud has failed.", |
||||
"fr": "La lecture de la rรฉponse ร la requรชte de crรฉation de compte vers l'instance Nextcloud a รฉchouรฉ." |
||||
}, |
||||
"error_login_post": { |
||||
"en": "The account creation request (POST) to Nextcloud has failed.", |
||||
"fr": "La requรชte de crรฉation de compte (POST) vers l'instance Nextcloud a รฉchouรฉ." |
||||
}, |
||||
"error_login_redir": { |
||||
"en": "Redirection to Nextcloud accout failed.", |
||||
"fr": "La redirection vers le compte Nextcloud a รฉchouรฉ." |
||||
}, |
||||
"error_createaccount_post": { |
||||
"en": "Account creation: connection to the Nextcloud API failed.", |
||||
"fr": "Crรฉation de compte : la connexion ร l'API Nextcloud a รฉchouรฉ." |
||||
}, |
||||
"error_createaccount_post_body": { |
||||
"en": "Account creation: reading the answer from the Nextcloud API failed.", |
||||
"fr": "Crรฉation de compte : le traitement de la rรฉponse de l'API Nextcloud a รฉchouรฉ." |
||||
}, |
||||
"error_createaccount_status": { |
||||
"en": "The Nextcloud instance responded with an unexpected status code.", |
||||
"fr": "L'instance Nextcloud a rรฉpondu avec un code de statut inattendu." |
||||
}, |
||||
"error_createaccount_ncstatus": { |
||||
"en": "The Nextcloud API responded with an unexpected status code.", |
||||
"fr": "L'API Nextcloud a rรฉpondu avec un code de statut inattendu." |
||||
}, |
||||
"error_createaccount_ncstatus_parse": { |
||||
"en": "Error parsing Nextcloud API's status code.", |
||||
"fr": "Erreur lors de la lecture du code de statut de l'API Nextcloud." |
||||
}, |
||||
"error_forwardregister_pool": { |
||||
"en": "Error while connecting to the local database.", |
||||
"fr": "Erreur lors de la connexion ร la base de donnรฉes locale." |
||||
}, |
||||
"error_forwardregister_db": { |
||||
"en": "Failed adding the Nextcloud account in the local database.", |
||||
"fr": "L'ajout du compte Nextcloud dans la base de donnรฉes locale a รฉchouรฉ." |
||||
}, |
||||
"error_login_cookiepair": { |
||||
"en": "Couldn't read cookies.", |
||||
"fr": "รchec lors de la lecture de cookies." |
||||
}, |
||||
"error_login_regex": { |
||||
"en": "Couldn't read the CSRF token.", |
||||
"fr": "รchec lors de la lecture du token CSRF." |
||||
}, |
||||
"error_login_setcookie": { |
||||
"en": "Error during cookies transfer.", |
||||
"fr": "Erreur lors du transfert de cookies." |
||||
}, |
||||
"error_form_insert": { |
||||
"en": "The local database couldn't be reached", |
||||
"fr": "รchec de la connexion avec la base de donnรฉes locale" |
||||
}, |
||||
"error_createaccount": { |
||||
"en": "The Nextcloud API returned an unexpected result", |
||||
"fr": "L'API de Nextcloud a retournรฉ un rรฉsultat inattendu" |
||||
}, |
||||
"error_dirtyhacker": { |
||||
"en": "Attempt to access an unauthorized resource.", |
||||
"fr": "Tentative d'accรจs ร une ressource non autorisรฉe." |
||||
}, |
||||
"error_tplrender": { |
||||
"en": "Template rendering failed.", |
||||
"fr": "Le rendu du template a รฉchouรฉ." |
||||
} |
||||
} |
@ -0,0 +1,8 @@
|
||||
CREATE TABLE form ( |
||||
id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL, |
||||
created_at TIMESTAMP NOT NULL, |
||||
lastvisit_at TIMESTAMP NOT NULL, |
||||
token VARCHAR UNIQUE NOT NULL, |
||||
nc_username VARCHAR UNIQUE NOT NULL, |
||||
nc_password VARCHAR NOT NULL |
||||
); |
@ -0,0 +1,880 @@
|
||||
Abomasnow |
||||
Abra |
||||
Absol |
||||
Accelgor |
||||
Aegislash |
||||
Aerodactyl |
||||
Aggron |
||||
Aipom |
||||
Alakazam |
||||
Alcremie |
||||
Alomomola |
||||
Altaria |
||||
Amaura |
||||
Ambipom |
||||
Amoonguss |
||||
Ampharos |
||||
Anorith |
||||
Appletun |
||||
Applin |
||||
Araquanid |
||||
Arbok |
||||
Arcanine |
||||
Arceus |
||||
Archen |
||||
Archeops |
||||
Arctovish |
||||
Arctozolt |
||||
Ariados |
||||
Armaldo |
||||
Aromatisse |
||||
Aron |
||||
Arrokuda |
||||
Articuno |
||||
Audino |
||||
Aurorus |
||||
Avalugg |
||||
Axew |
||||
Azelf |
||||
Azumarill |
||||
Azurill |
||||
Bagon |
||||
Baltoy |
||||
Banette |
||||
Barbaracle |
||||
Barboach |
||||
Barraskewda |
||||
Basculin |
||||
Bastiodon |
||||
Bayleef |
||||
Beartic |
||||
Beautifly |
||||
Beedrill |
||||
Beheeyem |
||||
Beldum |
||||
Bellossom |
||||
Bellsprout |
||||
Bergmite |
||||
Bewear |
||||
Bibarel |
||||
Bidoof |
||||
Binacle |
||||
Bisharp |
||||
Blacephalon |
||||
Blastoise |
||||
Blaziken |
||||
Blipbug |
||||
Blissey |
||||
Blitzle |
||||
Boldore |
||||
Boltund |
||||
Bonsly |
||||
Bouffalant |
||||
Bounsweet |
||||
Braixen |
||||
Braviary |
||||
Breloom |
||||
Brionne |
||||
Bronzong |
||||
Bronzor |
||||
Bruxish |
||||
Budew |
||||
Buizel |
||||
Bulbasaur |
||||
Buneary |
||||
Bunnelby |
||||
Burmy |
||||
Butterfree |
||||
Buzzwole |
||||
Cacnea |
||||
Cacturne |
||||
Calyrex |
||||
Camerupt |
||||
Carbink |
||||
Carkol |
||||
Carnivine |
||||
Carracosta |
||||
Carvanha |
||||
Cascoon |
||||
Castform |
||||
Caterpie |
||||
Celebi |
||||
Celesteela |
||||
Centiskorch |
||||
Chandelure |
||||
Chansey |
||||
Charizard |
||||
Charjabug |
||||
Charmander |
||||
Charmeleon |
||||
Chatot |
||||
Cherrim |
||||
Cherubi |
||||
Chesnaught |
||||
Chespin |
||||
Chewtle |
||||
Chikorita |
||||
Chimchar |
||||
Chimecho |
||||
Chinchou |
||||
Chingling |
||||
Cinccino |
||||
Cinderace |
||||
Clamperl |
||||
Clauncher |
||||
Clawitzer |
||||
Claydol |
||||
Clefable |
||||
Clefairy |
||||
Cleffa |
||||
Clobbopus |
||||
Cloyster |
||||
Coalossal |
||||
Cobalion |
||||
Cofagrigus |
||||
Combee |
||||
Combusken |
||||
Comfey |
||||
Conkeldurr |
||||
Copperajah |
||||
Corphish |
||||
Corsola |
||||
Corviknight |
||||
Corvisquire |
||||
Cosmoem |
||||
Cosmog |
||||
Cottonee |
||||
Crabominable |
||||
Crabrawler |
||||
Cradily |
||||
Cramorant |
||||
Cranidos |
||||
Crawdaunt |
||||
Cresselia |
||||
Croagunk |
||||
Crobat |
||||
Croconaw |
||||
Crustle |
||||
Cryogonal |
||||
Cubchoo |
||||
Cubone |
||||
Cufant |
||||
Cursola |
||||
Cutiefly |
||||
Cyndaquil |
||||
Darkrai |
||||
Darmanitan |
||||
Dartrix |
||||
Darumaka |
||||
Decidueye |
||||
Dedenne |
||||
Deerling |
||||
Deino |
||||
Delcatty |
||||
Delibird |
||||
Delphox |
||||
Deoxys |
||||
Dewgong |
||||
Dewott |
||||
Dewpider |
||||
Dhelmise |
||||
Dialga |
||||
Diancie |
||||
Diggersby |
||||
Diglett |
||||
Ditto |
||||
Dodrio |
||||
Doduo |
||||
Donphan |
||||
Dottler |
||||
Doublade |
||||
Dracovish |
||||
Dracozolt |
||||
Dragalge |
||||
Dragapult |
||||
Dragonair |
||||
Dragonite |
||||
Drakloak |
||||
Drampa |
||||
Drapion |
||||
Dratini |
||||
Drednaw |
||||
Dreepy |
||||
Drifblim |
||||
Drifloon |
||||
Drilbur |
||||
Drizzile |
||||
Drowzee |
||||
Druddigon |
||||
Dubwool |
||||
Ducklett |
||||
Dugtrio |
||||
Dunsparce |
||||
Duosion |
||||
Duraludon |
||||
Durant |
||||
Dusclops |
||||
Dusknoir |
||||
Duskull |
||||
Dustox |
||||
Dwebble |
||||
Eelektrik |
||||
Eelektross |
||||
Eevee |
||||
Eiscue |
||||
Ekans |
||||
Eldegoss |
||||
Electabuzz |
||||
Electivire |
||||
Electrike |
||||
Electrode |
||||
Elekid |
||||
Elgyem |
||||
Emboar |
||||
Emolga |
||||
Empoleon |
||||
Entei |
||||
Escavalier |
||||
Espeon |
||||
Espurr |
||||
Eternatus |
||||
Excadrill |
||||
Exeggcute |
||||
Exeggutor |
||||
Exploud |
||||
Falinks |
||||
Farfetchโd |
||||
Fearow |
||||
Feebas |
||||
Fennekin |
||||
Feraligatr |
||||
Ferroseed |
||||
Ferrothorn |
||||
Finneon |
||||
Flaaffy |
||||
Flabebe |
||||
Flapple |
||||
Flareon |
||||
Fletchinder |
||||
Fletchling |
||||
Floatzel |
||||
Floette |
||||
Florges |
||||
Flygon |
||||
Fomantis |
||||
Foongus |
||||
Forretress |
||||
Fraxure |
||||
Frillish |
||||
Froakie |
||||
Frogadier |
||||
Froslass |
||||
Frosmoth |
||||
Furfrou |
||||
Furret |
||||
Gabite |
||||
Gallade |
||||
Galvantula |
||||
Garbodor |
||||
Garchomp |
||||
Gardevoir |
||||
Gastly |
||||
Gastrodon |
||||
Genesect |
||||
Gengar |
||||
Geodude |
||||
Gible |
||||
Gigalith |
||||
Girafarig |
||||
Giratina |
||||
Glaceon |
||||
Glalie |
||||
Glameow |
||||
Gligar |
||||
Gliscor |
||||
Gloom |
||||
Gogoat |
||||
Golbat |
||||
Goldeen |
||||
Golduck |
||||
Golem |
||||
Golett |
||||
Golisopod |
||||
Golurk |
||||
Goodra |
||||
Goomy |
||||
Gorebyss |
||||
Gossifleur |
||||
Gothita |
||||
Gothitelle |
||||
Gothorita |
||||
Gourgeist |
||||
Granbull |
||||
Grapploct |
||||
Graveler |
||||
Greedent |
||||
Greninja |
||||
Grimer |
||||
Grimmsnarl |
||||
Grookey |
||||
Grotle |
||||
Groudon |
||||
Grovyle |
||||
Growlithe |
||||
Grubbin |
||||
Grumpig |
||||
Gulpin |
||||
Gumshoos |
||||
Gurdurr |
||||
Guzzlord |
||||
Gyarados |
||||
Happiny |
||||
Hariyama |
||||
Hatenna |
||||
Hatterene |
||||
Hattrem |
||||
Haunter |
||||
Hawlucha |
||||
Haxorus |
||||
Heatmor |
||||
Heatran |
||||
Heliolisk |
||||
Helioptile |
||||
Heracross |
||||
Herdier |
||||
Hippopotas |
||||
Hippowdon |
||||
Hitmonchan |
||||
Hitmonlee |
||||
Hitmontop |
||||
Honchkrow |
||||
Honedge |
||||
Hoopa |
||||
Hoothoot |
||||
Hoppip |
||||
Horsea |
||||
Houndoom |
||||
Houndour |
||||
Huntail |
||||
Hydreigon |
||||
Hypno |
||||
Igglybuff |
||||
Illumise |
||||
Impidimp |
||||
Incineroar |
||||
Indeedee |
||||
Infernape |
||||
Inkay |
||||
Inteleon |
||||
Ivysaur |
||||
Jellicent |
||||
Jigglypuff |
||||
Jirachi |
||||
Jolteon |
||||
Joltik |
||||
Jumpluff |
||||
Jynx |
||||
Kabuto |
||||
Kabutops |
||||
Kadabra |
||||
Kakuna |
||||
Kangaskhan |
||||
Karrablast |
||||
Kartana |
||||
Kecleon |
||||
Keldeo |
||||
Kingdra |
||||
Kingler |
||||
Kirlia |
||||
Klang |
||||
Klefki |
||||
Klink |
||||
Klinklang |
||||
Koffing |
||||
Komala |
||||
Krabby |
||||
Kricketot |
||||
Kricketune |
||||
Krokorok |
||||
Krookodile |
||||
Kubfu |
||||
Kyogre |
||||
Kyurem |
||||
Lairon |
||||
Lampent |
||||
Landorus |
||||
Lanturn |
||||
Lapras |
||||
Larvesta |
||||
Larvitar |
||||
Latias |
||||
Latios |
||||
Leafeon |
||||
Leavanny |
||||
Ledian |
||||
Ledyba |
||||
Lickilicky |
||||
Lickitung |
||||
Liepard |
||||
Lileep |
||||
Lilligant |
||||
Lillipup |
||||
Linoone |
||||
Litleo |
||||
Litten |
||||
Litwick |
||||
Lombre |
||||
Lopunny |
||||
Lotad |
||||
Loudred |
||||
Lucario |
||||
Ludicolo |
||||
Lugia |
||||
Lumineon |
||||
Lunala |
||||
Lunatone |
||||
Lurantis |
||||
Luvdisc |
||||
Luxio |
||||
Luxray |
||||
Lycanroc |
||||
Machamp |
||||
Machoke |
||||
Machop |
||||
Magby |
||||
Magcargo |
||||
Magearna |
||||
Magikarp |
||||
Magmar |
||||
Magmortar |
||||
Magnemite |
||||
Magneton |
||||
Magnezone |
||||
Makuhita |
||||
Malamar |
||||
Mamoswine |
||||
Manaphy |
||||
Mandibuzz |
||||
Manectric |
||||
Mankey |
||||
Mantine |
||||
Mantyke |
||||
Maractus |
||||
Mareanie |
||||
Mareep |
||||
Marill |
||||
Marowak |
||||
Marshadow |
||||
Marshtomp |
||||
Masquerain |
||||
Mawile |
||||
Medicham |
||||
Meditite |
||||
Meganium |
||||
Melmetal |
||||
Meloetta |
||||
Meltan |
||||
Meowstic |
||||
Meowth |
||||
Mesprit |
||||
Metagross |
||||
Metang |
||||
Metapod |
||||
Mew |
||||
Mewtwo |
||||
Mienfoo |
||||
Mienshao |
||||
Mightyena |
||||
Milcery |
||||
Milotic |
||||
Miltank |
||||
Mimikyu |
||||
Minccino |
||||
Minior |
||||
Minun |
||||
Misdreavus |
||||
Mismagius |
||||
Moltres |
||||
Monferno |
||||
Morelull |
||||
Morgrem |
||||
Morpeko |
||||
Mothim |
||||
Mudbray |
||||
Mudkip |
||||
Mudsdale |
||||
Muk |
||||
Munchlax |
||||
Munna |
||||
Murkrow |
||||
Musharna |
||||
Naganadel |
||||
Natu |
||||
Necrozma |
||||
Nickit |
||||
Nidoking |
||||
Nidoqueen |
||||
Nidoran |
||||
Nidorina |
||||
Nidorino |
||||
Nihilego |
||||
Nincada |
||||
Ninetales |
||||
Ninjask |
||||
Noctowl |
||||
Noibat |
||||
Noivern |
||||
Nosepass |
||||
Numel |
||||
Nuzleaf |
||||
Obstagoon |
||||
Octillery |
||||
Oddish |
||||
Omanyte |
||||
Omastar |
||||
Onix |
||||
Oranguru |
||||
Orbeetle |
||||
Oricorio |
||||
Oshawott |
||||
Pachirisu |
||||
Palkia |
||||
Palossand |
||||
Palpitoad |
||||
Pancham |
||||
Pangoro |
||||
Panpour |
||||
Pansage |
||||
Pansear |
||||
Paras |
||||
Parasect |
||||
Passimian |
||||
Patrat |
||||
Pawniard |
||||
Pelipper |
||||
Perrserker |
||||
Persian |
||||
Petilil |
||||
Phanpy |
||||
Phantump |
||||
Pheromosa |
||||
Phione |
||||
Pichu |
||||
Pidgeot |
||||
Pidgeotto |
||||
Pidgey |
||||
Pidove |
||||
Pignite |
||||
Pikachu |
||||
Pikipek |
||||
Piloswine |
||||
Pincurchin |
||||
Pineco |
||||
Pinsir |
||||
Piplup |
||||
Plusle |
||||
Poipole |
||||
Politoed |
||||
Poliwag |
||||
Poliwhirl |
||||
Poliwrath |
||||
Polteageist |
||||
Ponyta |
||||
Poochyena |
||||
Popplio |
||||
Porygon |
||||
Primarina |
||||
Primeape |
||||
Prinplup |
||||
Probopass |
||||
Psyduck |
||||
Pumpkaboo |
||||
Pupitar |
||||
Purrloin |
||||
Purugly |
||||
Pyroar |
||||
Pyukumuku |
||||
Quagsire |
||||
Quilava |
||||
Quilladin |
||||
Qwilfish |
||||
Raboot |
||||
Raichu |
||||
Raikou |
||||
Ralts |
||||
Rampardos |
||||
Rapidash |
||||
Raticate |
||||
Rattata |
||||
Rayquaza |
||||
Regice |
||||
Regidrago |
||||
Regieleki |
||||
Regigigas |
||||
Regirock |
||||
Registeel |
||||
Relicanth |
||||
Remoraid |
||||
Reshiram |
||||
Reuniclus |
||||
Rhydon |
||||
Rhyhorn |
||||
Rhyperior |
||||
Ribombee |
||||
Rillaboom |
||||
Riolu |
||||
Rockruff |
||||
Roggenrola |
||||
Rolycoly |
||||
Rookidee |
||||
Roselia |
||||
Roserade |
||||
Rotom |
||||
Rowlet |
||||
Rufflet |
||||
Runerigus |
||||
Sableye |
||||
Salamence |
||||
Salandit |
||||
Salazzle |
||||
Samurott |
||||
Sandaconda |
||||
Sandile |
||||
Sandshrew |
||||
Sandslash |
||||
Sandygast |
||||
Sawk |
||||
Sawsbuck |
||||
Scatterbug |
||||
Sceptile |
||||
Scizor |
||||
Scolipede |
||||
Scorbunny |
||||
Scrafty |
||||
Scraggy |
||||
Scyther |
||||
Seadra |
||||
Seaking |
||||
Sealeo |
||||
Seedot |
||||
Seel |
||||
Seismitoad |
||||
Sentret |
||||
Serperior |
||||
Servine |
||||
Seviper |
||||
Sewaddle |
||||
Sharpedo |
||||
Shaymin |
||||
Shedinja |
||||
Shelgon |
||||
Shellder |
||||
Shellos |
||||
Shelmet |
||||
Shieldon |
||||
Shiftry |
||||
Shiinotic |
||||
Shinx |
||||
Shroomish |
||||
Shuckle |
||||
Shuppet |
||||
Sigilyph |
||||
Silcoon |
||||
Silicobra |
||||
Silvally |
||||
Simipour |
||||
Simisage |
||||
Simisear |
||||
Sinistea |
||||
Sizzlipede |
||||
Skarmory |
||||
Skiddo |
||||
Skiploom |
||||
Skitty |
||||
Skorupi |
||||
Skrelp |
||||
Skuntank |
||||
Skwovet |
||||
Slaking |
||||
Slakoth |
||||
Sliggoo |
||||
Slowbro |
||||
Slowking |
||||
Slowpoke |
||||
Slugma |
||||
Slurpuff |
||||
Smeargle |
||||
Smoochum |
||||
Sneasel |
||||
Snivy |
||||
Snom |
||||
Snorlax |
||||
Snorunt |
||||
Snover |
||||
Snubbull |
||||
Sobble |
||||
Solgaleo |
||||
Solosis |
||||
Solrock |
||||
Spearow |
||||
Spewpa |
||||
Spheal |
||||
Spinarak |
||||
Spinda |
||||
Spiritomb |
||||
Spoink |
||||
Spritzee |
||||
Squirtle |
||||
Stakataka |
||||
Stantler |
||||
Staraptor |
||||
Staravia |
||||
Starly |
||||
Starmie |
||||
Staryu |
||||
Steelix |
||||
Steenee |
||||
Stonjourner |
||||
Stoutland |
||||
Stufful |
||||
Stunfisk |
||||
Stunky |
||||
Sudowoodo |
||||
Suicune |
||||
Sunflora |
||||
Sunkern |
||||
Surskit |
||||
Swablu |
||||
Swadloon |
||||
Swalot |
||||
Swampert |
||||
Swanna |
||||
Swellow |
||||
Swinub |
||||
Swirlix |
||||
Swoobat |
||||
Sylveon |
||||
Taillow |
||||
Talonflame |
||||
Tangela |
||||
Tangrowth |
||||
Tauros |
||||
Teddiursa |
||||
Tentacool |
||||
Tentacruel |
||||
Tepig |
||||
Terrakion |
||||
Thievul |
||||
Throh |
||||
Thundurus |
||||
Thwackey |
||||
Timburr |
||||
Tirtouga |
||||
Togedemaru |
||||
Togekiss |
||||
Togepi |
||||
Togetic |
||||
Torchic |
||||
Torkoal |
||||
Tornadus |
||||
Torracat |
||||
Torterra |
||||
Totodile |
||||
Toucannon |
||||
Toxapex |
||||
Toxel |
||||
Toxicroak |
||||
Toxtricity |
||||
Tranquill |
||||
Trapinch |
||||
Treecko |
||||
Trevenant |
||||
Tropius |
||||
Trubbish |
||||
Trumbeak |
||||
Tsareena |
||||
Turtonator |
||||
Turtwig |
||||
Tympole |
||||
Tynamo |
||||
Typhlosion |
||||
Tyranitar |
||||
Tyrantrum |
||||
Tyrogue |
||||
Tyrunt |
||||
Umbreon |
||||
Unfezant |
||||
Unown |
||||
Ursaring |
||||
Urshifu |
||||
Uxie |
||||
Vanillish |
||||
Vanillite |
||||
Vanilluxe |
||||
Vaporeon |
||||
Venipede |
||||
Venomoth |
||||
Venonat |
||||
Venusaur |
||||
Vespiquen |
||||
Vibrava |
||||
Victini |
||||
Victreebel |
||||
Vigoroth |
||||
Vikavolt |
||||
Vileplume |
||||
Virizion |
||||
Vivillon |
||||
Volbeat |
||||
Volcanion |
||||
Volcarona |
||||
Voltorb |
||||
Vullaby |
||||
Vulpix |
||||
Wailmer |
||||
Wailord |
||||
Walrein |
||||
Wartortle |
||||
Watchog |
||||
Weavile |
||||
Weedle |
||||
Weepinbell |
||||
Weezing |
||||
Whimsicott |
||||
Whirlipede |
||||
Whiscash |
||||
Whismur |
||||
Wigglytuff |
||||
Wimpod |
||||
Wingull |
||||
Wishiwashi |
||||
Wobbuffet |
||||
Woobat |
||||
Wooloo |
||||
Wooper |
||||
Wormadam |
||||
Wurmple |
||||
Wynaut |
||||
Xatu |
||||
Xerneas |
||||
Xurkitree |
||||
Yamask |
||||
Yampur |
||||
Yanma |
||||
Yanmega |
||||
Yungoos |
||||
Yveltal |
||||
Zacian |
||||
Zamazenta |
||||
Zangoose |
||||
Zapdos |
||||
Zarude |
||||
Zebstrika |
||||
Zekrom |
||||
Zeraora |
||||
Zigzagoon |
||||
Zoroark |
||||
Zorua |
||||
Zubat |
||||
Zweilous |
||||
Zygarde |
@ -0,0 +1,243 @@
|
||||
use actix_web::client::Client; |
||||
use actix_web::{http, web, HttpRequest, HttpResponse}; |
||||
use base64::URL_SAFE_NO_PAD; |
||||
use rand::rngs::OsRng; |
||||
use rand::Rng; |
||||
use rand::RngCore; |
||||
use regex::Regex; |
||||
|
||||
use crate::templates::get_lang; |
||||
use crate::config::{ADJ_LIST, NAME_LIST}; |
||||
use crate::errors::{crash, TrainCrash}; |
||||
use crate::debug; |
||||
use crate::CONFIG; |
||||
|
||||
#[derive(Serialize)] |
||||
struct NCLoginForm<'a> { |
||||
pub user: &'a str, |
||||
pub password: &'a str, |
||||
pub timezone: &'a str, |
||||
pub timezone_offset: &'a str, |
||||
pub requesttoken: &'a str, |
||||
} |
||||
|
||||
// check if the user is connected to Nextcloud
|
||||
// returns Some(cookie_raw_value) if connected
|
||||
// returns None if disconnected
|
||||
pub fn is_logged_in(req: &HttpRequest) -> Option<&str> { |
||||
let c = req.headers().get("Cookie")?.to_str().ok()?; |
||||
if c.contains("nc_username") { |
||||
Some(c) |
||||
} else { |
||||
None |
||||
} |
||||
} |
||||
|
||||
pub fn has_admintoken(req: &HttpRequest) -> Option<&str> { |
||||
let c = req.headers().get("Cookie")?.to_str().ok()?; |
||||
if c.contains("sncf_admin_token") { |
||||
Some(c) |
||||
} else { |
||||
None |
||||
} |
||||
} |
||||
|
||||
// attempts to create the account from Nextcloud's API
|
||||
// returns the newly created username.
|
||||
// if it fails (bad return code), returns None.
|
||||
pub async fn create_account( |
||||
client: &web::Data<Client>, |
||||
user: &str, |
||||
password: &str, |
||||
lang: String, |
||||
) -> Result<String, TrainCrash> { |
||||
let mut register_query = client |
||||
.post(format!( |
||||
"{}/{}", |
||||
CONFIG.nextcloud_url, "ocs/v1.php/cloud/users" |
||||
)) |
||||
.basic_auth(&CONFIG.admin_username, Some(&CONFIG.admin_password)) |
||||
.header( |
||||
http::header::CONTENT_TYPE, |
||||
"application/x-www-form-urlencoded", |
||||
) |
||||
.header("OCS-APIRequest", "true") |
||||
.send_form(&NCCreateAccountForm { |
||||
userid: user, |
||||
password, |
||||
quota: "0B", |
||||
language: &lang, |
||||
}) |
||||
.await |
||||
.map_err(|e| { |
||||
eprintln!("error_createaccount_post: {}", e); |
||||
crash(lang.clone(), "error_createaccount_post") |
||||
})?; |
||||
|
||||
// only 200 http status code is allowed
|
||||
if register_query.status() != 200 { |
||||
eprintln!("error_createaccount_status: {}", register_query.status()); |
||||
return Err(crash(lang.clone(), "error_createaccount_status")); |
||||
} |
||||
|
||||
// extract response body
|
||||
let response_body = register_query.body().await.map_err(|e| { |
||||
eprintln!("error_createaccount_post_body: {}", e); |
||||
crash(lang.clone(), "error_createaccount_post_body") |
||||
})?; |
||||
let response_body = String::from_utf8_lossy(&response_body); |
||||
// grasp NC status code
|
||||
let status_start = response_body.find("<statuscode>").ok_or_else(|| { |
||||
eprintln!("error_createaccount_ncstatus_parse: start missing"); |
||||
crash(lang.clone(), "error_createaccount_ncstatus_parse") |
||||
})? + 12; |
||||
let status_end = response_body.find("</statuscode>").ok_or_else(|| { |
||||
eprintln!("error_createaccount_ncstatus_parse: end missing"); |
||||
crash(lang.clone(), "error_createaccount_ncstatus_parse") |
||||
})?; |
||||
let code = &response_body[status_start..status_end]; |
||||
match code.parse::<u16>() { |
||||
Ok(100) => Ok(String::from(user)), // success
|
||||
Ok(r) => { |
||||
eprintln!("error_createaccount_ncstatus: {}", r); |
||||
Err(crash(lang.clone(), "error_createaccount_ncstatus")) |
||||
} |
||||
Err(e) => { |
||||
eprintln!("error_createaccount_ncstatus_parse: {}", e); |
||||
Err(crash(lang.clone(), "error_createaccount_ncstatus_parse")) |
||||
} |
||||
} |
||||
} |
||||
|
||||
#[derive(Serialize)] |
||||
struct NCCreateAccountForm<'a> { |
||||
pub userid: &'a str, |
||||
pub password: &'a str, |
||||
pub quota: &'a str, |
||||
pub language: &'a str, |
||||
} |
||||
|
||||
pub async fn login( |
||||
client: &web::Data<Client>, |
||||
req: &HttpRequest, |
||||
user: &str, |
||||
password: &str, |
||||
) -> Result<HttpResponse, TrainCrash> { |
||||
debug(&format!("Sending forged login for user {}", user)); |
||||
|
||||
// 1. GET /login
|
||||
let mut login_get = client |
||||
.get(format!("{}/{}", CONFIG.nextcloud_url, "login")) |
||||
.header("User-Agent", "Actix-web") |
||||
.send() |
||||
.await.map_err(|e| { |
||||
eprintln!("error_login_get: {}", e); |
||||
crash(get_lang(&req), "error_login_get") |
||||
})?; |
||||
|
||||
// rewrite cookie headers from GET to POST
|
||||
let mut str_cookiepair = String::new(); |
||||
for h_value in login_get.headers().get_all("set-cookie") { |
||||
str_cookiepair = format!("{}; {}", str_cookiepair, h_value.clone().to_str().map_err(|e| { |
||||
eprintln!("error_login_cookiepair: {}", e); |
||||
crash(get_lang(&req), "error_login_cookiepair") |
||||
})?); |
||||
} |
||||
|
||||
// load requesttoken regex
|
||||
lazy_static! { |
||||
static ref RE: Regex = Regex::new(r#"requesttoken="(?P<token>.*)""#).expect("Error while parsing the requesttoken regex"); |
||||
} |
||||
|
||||
let post_body = login_get.body().await.map_err(|e| { |
||||
eprintln!("error_login_get_body: {}", e); |
||||
crash(get_lang(&req), "error_login_get_body") |
||||
})?; |
||||
let post_body_str = String::from_utf8_lossy(&post_body); |
||||
|
||||
// save requesttoken (CSRF) for POST
|
||||
let requesttoken = RE |
||||
.captures(&post_body_str) |
||||
.ok_or_else(|| { |
||||
eprintln!("error_login_regex (no capture)"); |
||||
crash(get_lang(&req), "error_login_regex") |
||||
})? |
||||
.name("token") |
||||
.ok_or_else(|| { |
||||
eprintln!("error_login_regex (no capture named token)"); |
||||
crash(get_lang(&req), "error_login_regex") |
||||
})? |
||||
.as_str(); |
||||
|
||||
// 2. POST /login
|
||||
let mut login_post = client |
||||
.post(format!("{}/{}", CONFIG.nextcloud_url, "login")) |
||||
.header("User-Agent", "Actix-web"); |
||||
|
||||
// include all NC cookies in one cookie (cookie pair)
|
||||
login_post = login_post.header("Cookie", str_cookiepair); |
||||
|
||||