• Hi Guest!

    Please be aware that we have released another critical security patch for VaM. We strongly recommend updating to version 1.22.0.12 using the VaM_Updater found in your installation folder.

    Details about the security patch can be found here.

Plugin template, GitHub Actions and Virtamate forum automation

Acid Bubbles

Invaluable member
Developer
Featured Contributor
Messages
1,403
Reactions
5,786
Points
173
Website
github.com
Twitter
acidbubblesanon
Patreon
acidbubbles
I don't like doing the same thing twice. I'll spend days avoiding repeating a 5 minutes task.

I already have a plugin template where everything is automated using GitHub Actions: https://github.com/acidbubbles/vam-plugin-template

Except posting to this new otherwise-amazing resouces site.

So, until this becomes official, here's a few notes on how I'll automate this from GitHub... eventually.

Code:
$url = "https://hub.virtamate.com/dev/index.php?login/login"
$username = "you@example.org"
$password = "please-dont-use-1234"
curl -c cookies.txt "$url" -w "%{http_code}"
curl -c cookies.txt -b cookies.txt -d "login=$username&password=$password&cookie_check=1&redirect=https://hub.virtamate.com/dev&register=0&remember=0" -w "%{http_code}" $url

Now to actually create a new version for an existing post... the content type here being
Code:
multipart/form-data; boundary=---------------------------272578178724936978892724889818

Code:
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="new_version"

1
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="version_string"

v0.0.0-test
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="version_type"

external
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="external_download_url"

https://github.com/acidbubbles/vam-timeline/releases
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="new_update"

1
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="update_title"

Timeline v0.0.0-test
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="update_message_html"

<p>Please hold for release notes...</p>
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="attachment_hash"

2add47801e153f4a80e79fcc46648129
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="attachment_hash_combined"

{"type":"resource_update","context":{"resource_id":94},"hash":"2add47801e153f4a80e79fcc46648129"}
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="_xfToken"

1589251266,971e77ec81ffd3a633129e24a551a346
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="_xfRequestUri"

/dev/index.php?resources/timeline.94/post-update
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="_xfWithData"

1
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="_xfToken"

1589251266,971e77ec81ffd3a633129e24a551a346
-----------------------------272578178724936978892724889818
Content-Disposition: form-data; name="_xfResponseType"

json
-----------------------------272578178724936978892724889818--

So that means to actually make this last request, I need to:

1. Determine how to create this hash, which should be found in the javascript code
2. Show the form and extract the csrf token before building this
3. Create a template of the form data to push and POST it

So... a pain, but feasible.

The response can then be verified:

Code:
{
    "status": "ok"
}
 
Back
Top Bottom