0 Members and 1 Guest are viewing this topic.
<?$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('&', '"', ''', '<', '>'), 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, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x3c, 0x17, 0x8d, 0x3e, 0x73, 0x45, 0x68, 0x44, 0x40, 0x01, 0x00, 0x00, 0x93, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x78, 0x6d, 0x6c, 0x0f, 0xce, 0xd8, 0xd2, 0x81, 0x06, 0x86, 0x5b, 0x62, 0x81, 0xc2, 0xa6, 0x21, 0xa5, 0xfd, 0x08, 0x23, 0x0f, 0x92, 0xae, 0x38, 0x45, 0x2a, 0x05, 0x66, 0xbb, 0xc7, 0xdf, 0x98, 0x87, 0x55, 0x13, 0x61, 0x47, 0x75, 0x24, 0x66, 0xf9, 0x71, 0x1f, 0xcd, 0xe5, 0xb3, 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d, 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");?>
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...
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/
Quote from: adriweb on April 16, 2011, 12:52:32 pmYou 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.
Nope. Still doesn't support 7-zip or allow me to install software.