Iam new to WebServer and iam using NanoHttpd , Everything work fine and i can connect to my phone using my web browser on my Computer, my problem is that iam trying to run a Php file manager app, called 'fsmanager' , work fine on my website i can browse my files etc, in my index.html i have a simple tag that target fsmanager.php, when i click it, im asked to download the php file, i have tried to add mime type php application/php etc with no luck, source code is same as NanoHttpd,
Any help would be appreciated, Thanks.
Take a look at "Quercus" (http://quercus.caucho.com/) from the folks who make the Resin App-Server. Its a complete implementation of PHP version 5 that runs on the JVM, as a servlet.
While NanoHttpd doesnt support the servlet API specifically, I am sure that you could write hooks to and from Quercus to get something running with NanoHttpd. That would be a fabulous extension to the existing webserver code! :-)
nanohttpd is purely an HTTP server, it will not execute PHP files on it's own.
Related
I'm trying to connect a simple contact form to send emails using React and PHP.
The problem I have is that every tutorial or article I've found either leaves out key parts that probably seem simple yet to a complete PHP beginner are all the difference between a working app or not. I have basically no experience with PHP and connecting a PHP file to a React app, I've downloaded Docker and Apache (yet have no idea how they fit into the picture), where to place the PHP file (if it even matters), how to host the PHP development server, etc...
I'm aware I should ideally spend some time reading through and actually learning PHP, it's something I plan to do, yet I'm pressed for time so that isn't currently an option.
The code I'm using is from this article https://blog.bitsrc.io/how-to-build-a-contact-form-with-react-js-and-php-d5977c17fec0
I currently have the PHP file placed like so: projectfolder -> php-folder -> index.php
and the React like so: projectfolder -> react-folder -> src --> (all the react files)
again, all the code is from the tutorial I linked and all I did was place the PHP from the article into the index.php file like above, and the same thing with the React code from the article (with the path names corrected) so I'm sure it's something I'm missing with the backend like setting up Docker or Apache, or possibly the file placement.
Sorry if this seems like a really broad question, essentially I just need to know the steps for correctly connecting a PHP file with a React app to send emails from a contact form.
Thanks
Before this question gets closed, I know the setup above is possible. I just want clarification on some things.
I just started learning Aurelia because I want to convert one of my projects into a web app. My project is built with html+css+JavaScript(jQuery)+ PHP(MySql).
I havent used any sort of framework before.
In the guide, they mention a few ways to setup a web server. I used the http server with node. Now this is where I need some help understanding a few things.
I dont want to use node.js. I want to use PHP on the server. Will that work and how?
When using Apache server, I know any PHP page is sent to the interpreter that renders the final html. I use XAMPP and its apache comes bundled with PHP. Does the http server used by node come with PHP? Is this even a sensible question?
Now I know Aurelia is purely front end. If it used to make single page applications, it uses Ajax. So now I made the following assumption:
Using Aurelia, the user accesses the root page of the app that the web server sends. After that, Aurelia makes various Ajax requests to the server which will use my PHP files to do database query stuff.
Is that right or am I missing something. And can I just use xampp(apache) to host my app instead of server from node?
Aurelia is a framework that, after you export it to any server, does not rely on any back-end software at all. This means that with the help of the http- / fetch-client API, you can just call out to your php script.
I have an example in my github:
https://github.com/rjpvroegop/randyvroegop.nl-made-with-aurelia
Here I use the http-client to post data to my php script wich has a very simple email functionality.
You can see the action inside my view-model in src/pages/contact/index.js.
You can see the PHP script in src/assets/components/contactengine.php.
These work the way they should. Note: you have to change your gulp build if you want your PHP served the way I serve mine, from the dist folder after gulp-watch or gulp-export.
Next to that you can use any back-end functionality you would like, as long as it returns the proper data. This PHP script does that. If you would download my distribution to test this you can simply do the following:
gulp export from your terminal in the root folder
copy everything from the export folder to your PHP webserver.
I have written a .php script. When there is some event, it writes to a file. It's working perfectly!
Now I want to open Windows Media Player or any other player using this php script as I also want to play a sound when the event occurs. I tried embedding the sound file as follow:
echo "< embed src =\"$file\" hidden=\"true\" autostart=\"true\">";
But it only writes to the file n do not play the audio, when the event occurs.
I came across 'exec' command which didnt work. (I am not sure about how it works. An example would be a great help!)
Does anyone know how to start a windows application using php script?
EDIT REMOVED
Thanks,
Sagar.
You can play a wave file in your server side folder in a php file by adding this
<?php exec('c:\windows\system32\cmd.exe /c START C:\website\beep.wav');
?>
and this would play the beep.wav usually through whatever sound appy is installed on your machine, like windows media player.
You cannot start console based application through Apache+PHP application. The reason is, as Apache webserver is running as a system service in a separate logon session, it cannot start UI based applications which requires a login console session.
Anyway, you can embed the audio inside the html page. Refer the http://www.w3schools.com/html/html_sounds.asp page to get more details.
Comment about running Windows GUI programs using PHP: http://www.php.net/manual/en/book.exec.php#87943
But, I think you only need to embed player on your page using some HTML tag as Aravind described.
SagarJ,
You can embed the audio file in html and will be executed by the browser/browser plugin application already installed in the system.
So, you need not to worry about that.
Let me start by saying PHP isn't my forte, I'm usually reluctant to try working with it because of problems exactly like this. The code works fine on my local machine under MAMP and on my server, but doesn't on the clients server :'(
So what am I trying to do, well - save an image from Flash onto the server, simple right?!
I'm using the method described on this site here: http://designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed-saving-images-from-flash/ but have made a small alteration so that instead of echoing the jpg causing the browser to download it locally, I do an fwrite and an fclose to save it to the server.
Here is my PHP:
I've dona a phpinfo() on my clients server and it's running 5.2.2 my host is running 5.2.11 I don't know if much can have changed in those 9 minor revisions?
I've also read another question on here which suggests making suer always_populate_raw_post_data is set to ON, but it's set to OFF on all of the server environments I've been testing in. I'm doing some XML saving using file_get_contents('php://input') which I've tried but failed to get working with images.
Any help would be gratefully received, I'm happy to post the AS3 as well but it's EXACTLY the same as example I've linked above and works locally. As far as I can tell the problem lies with the PHP.
Cheers.
Is there any reason you're using the HTTP_RAW_POST_DATA? If Flash is sending the file via the POST method, it'd be by far easier to use the $_FILES array. There'd be no need to fopen/fwrite, as the file's already been stuck into a temp dir by PHP. All you have to do is use [move_uploaded_file()][1] to put it wherever you want on the server.
I am trying to create a script that will display the contents of a folder, onto a newsticker, and I was wondering if anyone had a script that could run this. I was thinking probably php, but it has no been working for me.
Thanks for the help
The software I am using is dreamweaver cs4
I'm guessing that you have written some PHP, but are trying to run it locally without a server - for PHP to work you need a server. XAMPP is a good bet to do this locally, or you'll need to upload your file to some hosting that supports PHP.
I'm thinking why you're having trouble with it is because you just copy and pasted the code in a .html file and opening it on your local environment.
With that said, in order for it to run locally, you have to install php and a http server. The code is done on server side, not client side. So either get a hosting service that supports php or download and install your own server and php.
Also, if you already have the above, the code has to be surrounded by a < ?php and ? > tags(without spaces). If you're running it on cli, then you need to make sure you give it execution permission with the path to php, OR execute php < name of script >.
Last, the code you presented provides major security flaws. The first of which is where will the "$dir_path" variable be set? Will that be user given, or will you specify the variable?
Whenever you allow users to view your file system, always make sure you give limitations to it. For example, let's say you did this:
www.example.com/newsticker.php?path=/www/files/newsticker
looks innocent enough, but a clever hacker could say let me try....
www.example.com/newsticker.php?path=/
And so fort.
So be careful and don't allow users to specify directories or execute code.