Archive: Can NSISdl read from www page?


Can NSISdl read from www page?
Hi,

I'm back at trying to use NSIS to build an over-the-web installer after spending some time building full EXE's. It doesn't look like NSISdl is able to just download the contents of a web page into a file eg.:

1. PHP script over on the www server
<?php
//GET /check.php HTTP/1.0
echo "myapp.exe\t1.0.0.0";
?>

2. NSIS installer
Section ""
Call ConnectInternet

StrCpy $2 "$INSTDIR\check.txt"
NSISdl::download http://srv/check.php $2
Pop $R0
#"Server did not specify content length"
MessageBox MB_OK|MB_ICONSTOP $R0
SectionEnd

Besides creating a file on the www server (eg. list.ini), is there a way?

Thank you
JD.


If you have a dynamic page you should send the content length header.


Thx Joost :-) This is the first time I'm sending raw data. Do you know what I'm doing wrong?

<?php
echo "Content-type: text/plain\r\n";
echo "Content-length: 17\r\n\r\n";
echo "myapp.exe\t1.0.0.0";
?>

Thx
JD.


Ha! :-)

<?php
ob_start();
header('Content-Type: text/plain');
?>
<html>
<head>
</head>
<body>

<?php
$dir = opendir(".");

while ($item = readdir($dir)) {
if(strstr($item,".exe")) {
print "$item\n";
}
}
?>

</body>
</html>
<?php
header('Content-Length: ' . ob_get_length());
ob_end_flush();
?>


For those interested, this is how you can generate an INI file dynamically, listing all the binary files in the current directory.

Since I haven't found whether PHP supports the PE file format (maybe through the Win32 package, but no idea if available in the Unix port of the language), the version number for each file is currently forced to 1.0.0.0. The output will look like a standard INI file, eg.

[myapp]
myfile.exe=1.0.0.0
myocx.ocx=1.0.0.0

You can then download this file from an NSIS EXE, and access it using the ReadINIStr() function.

=> Does someone know of to go about, and build a hashed table in NSIS, inserting all the key/value tuples from a section?
I need to do this so I can browse through eg. the [myapp] section, checking whether each file is available and in the right version, and download it otherwise.

Hope that helps
JD.

-----------------

<?php
ob_start();
header('Content-Type: text/plain');

print "[myapp]\r\n";
$dir = opendir(".");

while ($item = readdir($dir)) {
if (eregi("(.exe|.dll|.ocx)", $item)) {
print "$item=1.0.0.0\r\n";
}
}

header('Content-Length: ' . ob_get_length());
ob_end_flush();
?>