Page 1 of 1

Using compiled WebPages.dll without source files

PostPosted: December 18th, 2012, 12:54 pm
by papachumba
I have been trying to find information on this since yesterday - there is not one single bit of text describing this option anywhere on the web as far as I can see.

I have deployed Phalanger 3.0 successfully on IIS 7.5
It runs php files no problem.
I have compiled a WebPages.dll sitting in the /bin folder in my application.

Now, I'd like to remove my source files and have WebPages.dll to take over all processing, until I recompile them again. Basically Im trying to protect the source code by only leaving the .dll on the server.

I have tried including following in my web.config in the root of my application, however this has had no effect:
Code: Select all
<paths>
<set name="DynamicWrappers" value=".\Dynamic"/>
<set name="Libraries" value=".\Bin"/>
<set name="ExtWrappers" value=".\Bin"/>
<set name="ExtNatives" value=".\Bin\Extensions"/>
</paths>
<compiler>
<set name="Debug" value="true" />
</compiler>


As soon as I remove my source .php files, IIS complains it cannot find the file.
What should I do to complete this?

Re: Using compiled WebPages.dll without source files

PostPosted: December 18th, 2012, 1:08 pm
by Jakub Misek
There is phpc.exe help at http://wiki.php-compiler.net/Phpc.exe

Hiding script files on your server is possible in this way, WebPages.dll will contain all your (compiled) .php files, so inclusion and requesting these scripts will work. File system functions won't.

Re: Using compiled WebPages.dll without source files

PostPosted: December 18th, 2012, 1:29 pm
by papachumba
Hi Jacob, thank you for your prompt answer.
I understand phpc.exe will compile my scripts into a WebPages.dll, i have managed to do this ok.

Problem is, as soon as I remove the original .php scripts, IIS complains with "404 file not found", meaning IIS is not loading WebPages.dll, instead it is trying to load the original .php file.

How can I prevent it from doing this?

Re: Using compiled WebPages.dll without source files

PostPosted: December 18th, 2012, 2:42 pm
by Jakub Misek
WebPages.dll has to be placed under /Bin/ folder of your web application root.

Does it work for you?
Thanks,

Re: Using compiled WebPages.dll without source files

PostPosted: December 18th, 2012, 3:14 pm
by papachumba
Yes, the folder is in correct place but still not working?

If I browse to http://server/quotes/myfile.php it executes.
If i remove myfile.php and browse to http://server/quotes/myfile.php i get 404 file not found

this is my directory structure

/quotes (web application)
/quotes/myfile.php
/quotes/web.config
/quotes/Bin/WebPages.dll

Re: Using compiled WebPages.dll without source files

PostPosted: December 18th, 2012, 3:31 pm
by Jakub Misek
Maybe because the file was loaded, recognized as most recent (so the compiled image from webpages.dll was ignored), and then removed ...

Try to remove the file, restart the apppool and request it again ... Phalanger should see the only option in WebPages.dll and use this one for sure.

Also take a look on following options (web.confing/phpNet/compiler) (sample in latest sources at \Deployment\Web.config) which may save some resources and ensures only scripts compiled in your DLL will be loaded:
Code: Select all
<set name="WatchSourceChanges" value="false" />
<set name="OnlyPrecompiledCode" value="true" />


Thanks,

Re: Using compiled WebPages.dll without source files

PostPosted: December 18th, 2012, 3:56 pm
by papachumba
Thank you so much, adding these 2 lines has helped!
I wasnt able to make it work with the .php file totally removed, however, if I edit the php file, and remove ALL code from the file and then save, it seems like IIS is reading the .dll (as it is giving me the output in the browser still)

So, it seems to be working if I manually empty the php file and resave under same name. If i delete the php file, IIS starts complaining...

Re: Using compiled WebPages.dll without source files

PostPosted: December 18th, 2012, 4:03 pm
by Jakub Misek
Well
<set name="OnlyPrecompiledCode" value="true" />
disallows reading scripts from file system for sure.

However you should be able to delete .php files, and still get requests served - this would be some IIS settings, maybe set mime type, or something. Once it gets into Phalanger, it will be loaded from webpages.dll.

Anyway I'm glad it works for you!

Re: Using compiled WebPages.dll without source files

PostPosted: December 18th, 2012, 4:48 pm
by papachumba
Thanks for your prompt help Jakub.
I have managed to sort it all out, my mistake.

When I setup the handler mapping under this new site, I put in a "request restriction" to only invoke the handler when a request is mapped to file/folder.

As soon as I removed this restriction, the website would serve the file even when I removed the PHP source files...

All working beautifully now!

Re: Using compiled WebPages.dll without source files

PostPosted: December 18th, 2012, 5:07 pm
by Jakub Misek
Great! Thanks for letting us know!