Author Topic: Luna online  (Read 8313 times)

0 Members and 1 Guest are viewing this topic.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Luna online
« on: April 16, 2011, 12:38:26 pm »
Thought this might be useful: http://clrhome.org/b/lua/ (URL subject to change, and the UI of course :P).

Just another Lua > TI converter, this time in PHP (read: online).

I actually have no idea if it really works or not. I checked the raw hex of the .tns files in a hex viewer, but who knows how well it stands up on an actual calculator. I don't have an Nspire to test and I lost the boot2.img I used for nspire_emu, so if someone could test for me that'd be great :)

The routine is based straight off of Levak's Python version. Source below. Feel free to offer suggestions/optimizations. I'm pretty new to PHP, anyway.
Spoiler For Code:
Code: (PHP) [Select]
<?
$zip = new ZipArchive;
$name = basename($_FILES['lua']['name'], '.lua');
if (file_exists("$name.lua"))
{
die ('NAMEFAIL');
}
else
{
if (move_uploaded_file($_FILES['lua']['tmp_name'], "$name.lua"))
{
if ($res = $zip->open("$name.zip", ZipArchive::CREATE))
{
$zip->addFromString('Problem1.xml', '<?xml version="1.0" encoding="UTF-8" ?><prob xmlns="urn:TI.Problem" ver="1.0" pbname=""><sym></sym><card clay="0" h1="10000" h2="10000" w1="10000" w2="10000"><isDummyCard>0</isDummyCard><flag>0</flag><wdgt xmlns:sc="urn:TI.ScriptApp" type="TI.ScriptApp" ver="1.0"><sc:mFlags>0</sc:mFlags><sc:value>-1</sc:value><sc:script>' . str_replace(array('&', '"', '\'', '<', '>'), array('&amp;', '&quot;', '&#039;', '&lt', '&gt'), file_get_contents("$name.lua")) . '</sc:script></wdgt></card></prob>');
$zip->close();
}
else
{
die ('ZIPFAIL');
}
}
else
{
die ('MOVEFAIL');
}
}
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$name.tns\"");
echo pack('c*', 0x2a, 0x54, 0x49, 0x4d, 0x4c, 0x50, 0x30, 0x35, 0x30, 0x30, 0x14, 0x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0x09, 0xd1, 0xed, 0xb3, 0xd3, 0x92, 0x69, 0xdf, 0xb5, 0x94, 0x72, 0xa6, 0x37, 0x58, 0x58, 0xc4, 0xd4, 0x29, 0xd1, 0xba, 0xaf, 0x84, 0x4a, 0x2e, 0xcf, 0x2e, 0x7b, 0xfb, 0xbd, 0x91, 0xac, 0x99, 0xba, 0xa8, 0xcc, 0xc0, 0x95, 0x5b, 0x21, 0xe4, 0x3d, 0x58, 0xfa, 0x8f, 0xc4, 0x21, 0xc7, 0x66, 0xc5, 0x7b, 0xa7, 0x31, 0x9f, 0x70, 0x2d, 0x1e, 0xce, 0x37, 0x8a, 0x13, 0xe1, 0xe8, 0x1e, 0x88, 0x67, 0x11, 0x7c, 0x3e, 0x7d, 0x75, 0x52, 0xbd, 0x9a, 0x40, 0xd7, 0xaf, 0x3d, 0xa1, 0x10, 0x3a, 0xeb, 0x91, 0xc8, 0x8d, 0x4a, 0x24, 0x9b, 0x38, 0x85, 0x8f, 0x38, 0xb5, 0x3c, 0xb5, 0xa3, 0xfa, 0x1b, 0xbe, 0x4a, 0xca, 0x93, 0xd7, 0x41, 0x69, 0x02, 0x0d, 0xad, 0x30, 0x6d, 0xba, 0x08, 0x54, 0xfc, 0x13, 0xe8, 0xfa, 0xeb, 0xc0, 0xfd, 0xe8, 0xad, 0x51, 0x1a, 0x4a, 0x89, 0x95, 0x3a, 0x27, 0xd4, 0xf2, 0xcc, 0x40, 0x46, 0xcd, 0xc9, 0x8a, 0x14, 0xd5, 0x83, 0xdf, 0x60, 0xdc, 0xce, 0x06, 0x5e, 0x9e, 0x2e, 0xb1, 0xd3, 0x54, 0x97, 0xf7, 0x7b, 0xae, 0x6f, 0x51, 0x4f, 0x74, 0xdc, 0x57, 0x6a, 0xd4, 0x7f, 0x37, 0x2a, 0x49, 0xba, 0x86, 0x2a);
readfile("$name.zip");
unlink("$name.lua");
unlink("$name.zip");
?>
UPDATE: New URL, new script.
« Last Edit: January 04, 2012, 07:38:50 pm by Deep Thought »




Ashbad

  • Guest
Re: Online Lua > TI converter
« Reply #1 on: April 16, 2011, 12:45:11 pm »
wow, this looks awesome :) nice work :D

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Online Lua > TI converter
« Reply #2 on: April 16, 2011, 12:46:07 pm »
Great idea !

I tested it and it doesn't work, sorry.

When I compare a working .tns file (generated by the python converter, or mine), there are 7 extra bytes in some places around the files, and the inner part of the compressed (zipped) part is totally different.

The syntax and everything in the php source looks good so the problem must be coming from the zipping part.

The compression used here is quite special... Lionel Debroux found today that with the unix/linux/mac-version of zip, it had to be written like that : " zip -9 -q -X -j "...

and I don't know what PHP does for its zip function...
« Last Edit: April 16, 2011, 12:47:03 pm by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Online Lua > TI converter
« Reply #3 on: April 16, 2011, 12:50:51 pm »
Great idea !

I tested it and it doesn't work, sorry.

Darn. Bugs >:(

When I compare a working .tns file (generated by the python converter, or mine), there are 7 extra bytes in some places around the files, and the inner part of the compressed (zipped) part is totally different.

The syntax and everything in the php source looks good so the problem must be coming from the zipping part.

The compression used here is quite special... Lionel Debroux found today that with the unix/linux/mac-version of zip, it had to be written like that : " zip -9 -q -X -j "...

and I don't know what PHP does for its zip function...

I don't understand the different ZIP formats... Maybe I shouldn't have made this :P
« Last Edit: January 04, 2012, 07:53:27 pm by Deep Thought »




Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Online Lua > TI converter
« Reply #4 on: April 16, 2011, 12:52:32 pm »
You can try to use the 7zip extension for PHP, as it directly compress the files in the right format, readble by the Nspire :)

http://download.modem-help.co.uk/non-modem/PHP/7z/


and that might be interesting :

http://stackoverflow.com/questions/4596121/possible-to-feed-stdout-of-7-zip-to-php-script
« Last Edit: April 16, 2011, 12:53:42 pm by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Online Lua > TI converter
« Reply #5 on: April 16, 2011, 01:06:29 pm »
You can try to use the 7zip extension for PHP, as it directly compress the files in the right format, readble by the Nspire :)

http://download.modem-help.co.uk/non-modem/PHP/7z/

I can't install extensions -- it's not my server :( And of course passthru is disabled (same reason).

Anybody who wants to host this on their own server, go ahead.
« Last Edit: April 16, 2011, 01:08:48 pm by Deep Thought »




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Online Lua > TI converter
« Reply #6 on: April 17, 2011, 05:33:28 am »
You can try to use the 7zip extension for PHP, as it directly compress the files in the right format, readble by the Nspire :)

http://download.modem-help.co.uk/non-modem/PHP/7z/

I can't install extensions -- it's not my server :( And of course passthru is disabled (same reason).

Anybody who wants to host this on their own server, go ahead.

Will you be able to do that in the new host?

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Online Lua > TI converter
« Reply #7 on: April 17, 2011, 09:56:46 am »
Nope. Still doesn't support 7-zip or allow me to install software.




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Online Lua > TI converter
« Reply #8 on: April 17, 2011, 01:35:17 pm »
Nope. Still doesn't support 7-zip or allow me to install software.

I think I can make an online version of it... Isn't there a Python one? I can make it online!

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Online Lua > TI converter
« Reply #9 on: July 11, 2011, 12:21:12 am »
EDIT: Never mind, found it: http://withg.us.to/lua2tns/MakeTNS.php (alberthro's script). Funnily enough, that one's hosted on the same server (his).

Mine is now officially of no use. But it works ;D
« Last Edit: January 04, 2012, 06:58:52 pm by Deep Thought »




Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Luna online
« Reply #10 on: January 04, 2012, 07:37:52 pm »
Changed it again. This time, it's just an online front-end for Luna (thanks to ExtendeD for permission).

You can upload your source in one of three ways:
  • Drag-and-drop into the window (on newer browsers)
  • Press Ctrl+V to paste, then click Submit
  • Open a file, then click Submit
In any case, the file is sent to the server, which runs it through luna and gives you the TNS.

Luna online
« Last Edit: January 04, 2012, 07:41:33 pm by Deep Thought »




Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Luna online
« Reply #11 on: January 05, 2012, 03:37:39 am »
Very nice and thanks,  I was waiting for the update :)

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Luna online
« Reply #12 on: July 06, 2012, 12:26:30 am »
Fixed drag-and-drop upload and updated Luna to 0.3a.