Last active
August 29, 2015 14:15
-
-
Save francoiscolas/e475931237e2b1f715dc to your computer and use it in GitHub Desktop.
A shell script to create rollerblading events without having to use the ugly ovs website!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -le 0 ] | |
then | |
echo "Usage: $0 DAY-MONTH..." | |
exit 1 | |
fi | |
USERNAME=francolas | |
if [ -z "$PASSWORD" ] | |
then | |
read -p "$USERNAME's password: " -s PASSWORD | |
echo | |
fi | |
# Fetch PHPSESSID and TOKEN values | |
echo -n "Fetching PHPSESSID and TOKEN values... " | |
declare $(curl -s -i http://angers.onvasortir.com | awk ' | |
match($0, /(PHPSESSID=[^;]+)/, cap) { | |
print cap[1] | |
} | |
match($0, /<input.*value=.([a-z0-9]{40}).>/, cap) { | |
print "TOKEN=" cap[1] | |
}' | |
) | |
echo "Done" | |
# Authenticate | |
echo -n "Authenticating... " | |
curl -s -X POST -b"PHPSESSID=$PHPSESSID" -d"Pseudo=$USERNAME&Password=$PASSWORD&tok=$TOKEN&token2=$USERNAME" http://angers.onvasortir.com/page_action_connect_new.php | |
echo "Done" | |
# Create new events | |
EVENT_TITLE="Rando roller tous niveaux." | |
EVENT_ADDR="Place la Fayette, Angers" | |
EVENT_YEAR=`date +%Y` | |
EVENT_DESC=" | |
<p>Bonjour à tous,</p> | |
<p> </p> | |
<p>Je vous propose une rando roller en deux temps. Une première partie pour <strong>tous les niveaux</strong>, avec un rythme plutôt cool.</p> | |
<p> </p> | |
<p>Ensuite, une rando <strong>plus sportive et plus rapide</strong> pour ceux qui sont très à l'aise et veulent se dépenser :). L'itinéraire est choisi ensemble au fur et à mesure.</p> | |
<p> </p> | |
<p>Départ à 20h. <span style=\"font-size: 12px;\">Prenez des lumières et/ou gillets reflechissants. Protections recommandées.</span></p> | |
<p> </p> | |
<p>Durée première partie: 1h</p> | |
<p>Durée deuxème partie: 1h</p> | |
<p>Départ/retour: Place Lafayette</p> | |
<p> </p> | |
<p>À bientôt!</p>" | |
for DATE in "$@" | |
do | |
echo -n "Creating roller event on $DATE... " | |
RETVALUE=$(curl -s -i -X POST \ | |
-b"PHPSESSID=$PHPSESSID" \ | |
-F"Modele=" \ | |
-F"Brouillon=0" \ | |
-F"VideoModele=" \ | |
-F"AgeOrga=1987" \ | |
-F"MAX_FILE_SIZE=1000000" \ | |
-F"file_name=@" \ | |
-F"Dailymotion=" \ | |
-F"Tel=" \ | |
-F"Ouverte=tous" \ | |
-F"TypeSortie=Sport" \ | |
-F"Intitule=$EVENT_TITLE" \ | |
-F"SortieTheme1=85" \ | |
-F"SortieTheme2=" \ | |
-F"DateCal=$DATE-$EVENT_YEAR" \ | |
-F"Heure=19" \ | |
-F"Minute=50" \ | |
-F"Delai=0" \ | |
-F"Descriptif=$EVENT_DESC" \ | |
-F"NbMaxi=20" \ | |
-F"Invites=oui" \ | |
-F"Adresse=$EVENT_ADDR" \ | |
-F"Departement=1" \ | |
-F"RDV=$EVENT_ADDR" \ | |
http://angers.onvasortir.com/sortie_action_create.php | awk '/^Location: sortie_read_new.php/ { print "SUCCESS" }') | |
if [ "$RETVALUE" = "SUCCESS" ] | |
then | |
echo "Done" | |
else | |
echo "Error" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment