Jump to content

Archived

This topic is now archived and is closed to further replies.

jfreak53

PHP internal autoinstaller

Recommended Posts

Ok, I downloaded a program called MyWebFTP Free, and only four files come with this program.  When I upload it I run one of them and it extracts all the other files from one of those four, so I looked at it and it's a PHP file with all of the other PHP files and Images and all other things inside of it, there not compressed, it just contains the files contents inside of another PHP file, for quicker uploading I guess.  But I liked this and I would like to know if anyone knows how this is done, is there a program or a script that does this or is it done manually??

This is the actual funtion inside the setup.php file that extracts the other files as I can see:

[code]function step_core(){
echo "<H3>Install Application Files</H3>";

$ifh = fopen( MAIN_DIR . '/' . SETUP_FILE, 'rb');
rewind($ifh);
//first line is service one
$line = fgets($ifh, 1024);

$fileCount = process_setup_file( $ifh, FILE_TYPE_APP );

echo "<BR>$fileCount files have been extracted. <BR><BR>";

fclose($ifh);
}
[/code]

Thanks in advance.

Joel

Share this post


Link to post
Share on other sites
I think they have done it simular to getting files from a database

I can see it being possible to store the content and MIME of all files needed in a file in RAW format and then parse the file for the diffrent MIME and contents and write to the actual file and create the files needed.

Think you may be missing another function process_setup_file as that doesn't seem to be on the php functions list.

Regards
Liam

Share this post


Link to post
Share on other sites
Yep your correct, I didn't really get into the setup file to look at the functions of it, from what I can see it's pretty straight forward how it get's the files out and back into their original format:

[quote]function process_setup_file( &$sf_h, $type = 0 ){
$fileCount = 0;
$file = null;
echo "<B>Writing files:</B><BR>";

while( ! feof($sf_h) ){
// $line = trim(fgets($sf_h, 1024));
$line = rtrim(fgets($sf_h, 64000));
if( strlen($line) > 0 ){
if( preg_match("/startFile\s*:\s*([^\s]+)\s*:\s*(\d)$/", $line, $matches) ){
// NEW FILE
// CLOSE OLD
if( $file ){
fclose($file);
@chmod($fullFileName, 0666);
$file = null;
$fileCount++;
}

// START NEW
$fileName = trim( $matches[1] );
$fileType = (int)trim( $matches[2] );

if( ($fileType != FILE_TYPE_SKIP) && ($type == $fileType) ){
echo "$fileName<BR>";
$fullFileName = MAIN_DIR . '/' . $fileName;
makeDir( dirname($fullFileName) );
if( ! ($file = fopen($fullFileName, 'w')) )
fatalError( "Can't open file '$fullFileName' for writing<BR>" );
}

// copy the new non-application files if any appeared
if( ($type != $fileType) && ($type == FILE_TYPE_APP) ){
$fullFileName = MAIN_DIR . '/' . $fileName;
if( ! file_exists($fullFileName) ){
echo "$fileName<BR>";
makeDir( dirname($fullFileName) );
if( ! ($file = fopen($fullFileName, 'w')) )
fatalError( "Can't open file '$fullFileName' for writing<BR>" );
}
}
}
else {
// EXISTING FILE
if( $file ){
if( ftell($file) > 0 )
fwrite($file, "\n");
fwrite($file, $line);
}
}
}
else {
// WRITE EMPTY LINE
if( $file )
fwrite($file, "\n");
}
}
if( $file ){
fclose($file);
@chmod($fullFileName, 0666);
}

return $fileCount;
}

function fatalError( $msg ){
echo $msg;
exit;
}[/quote]

The start of every new file is like this:

[quote]startFile : mwftp5/common/classes/mwfCommonView.php : 1[/quote]

So I mean it's pretty straight forward design the "extracting them", so I guess to make a "compactor" as it would be, would just be the reverse of all that, parsing the other way.  I was just checking if someone has heard of a program or script that does that, the "reverse" that is, because I liked it for large systems, makes it easier to upload in one file than many files.

Share this post


Link to post
Share on other sites
Try this...I haven't, but it seems to be along the lines of what you want:

http://www.phpclasses.org/browse/package/715.html

Share this post


Link to post
Share on other sites
Or you could just do what php is for and build your own if you find anything.
I am saying nothing but i try not to use third parties for anything except occassionally stat statistics when I don't have time to build my own system.  Craigslist could be built within 1 month.  I think you should try and build one, i couldn't help ont hat because I don't know what you mean, but if it can be done with php you can build it.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.