PHP or WAMP not sure what - php

I have installed WAMP server 2.0 with (PHP 5.4.3). After installing WAMP I have restarted all the services and can open
phpinfo() - it is showing up fine
phpmyadmin - it is also showing up fine.. i can play with database..
however when run simple php file in chrome I could see the code rather than result. below is the code i am trying..
<?php
echo "hello world";
?>
below is the link to file which I am trying to access via chrome.
file:///C:/WAMP/www/hello%20world.php

Make sure you have started apache
Try http://localhost/hello_horld.php

To run this script, start a browser use URL http://localhost/your_file.php or http://127.0.0.1/your_file.php
PHP is a server-side technology (instead of client-side technology like JavaScript). The PHP statements <?php ... ?> are processed in the server, and the results returned to the client (browser). so you need to use it through server not direct

Related

Unix sockets doesn't work with PHP on Apache

I wrote a following short script in PHP:
<?
$s = socket_create(AF_UNIX,SOCK_STREAM,0);
socket_connect($s,"/tmp/tmpsock");
socket_write($s,"test");
socket_close($s);
>
I user this code to connect to a simple server that prints everything it receives onto terminal output.
The script works fine when I opened it from terminal using php index.php, however I want it to be a part of a webapp, and I try to run it on apache2 server opening the index.php page in web browser (on server of course). The script doesn't work then - the socket_connect function returns nothing, the error description is "Success()" and the message doesn't appear on server.
I use Ubuntu 16.04, Apache 2.4 and PHP 7.0

How to launch an application from the browser using PHP?

I have installed .exe file using wine in my linux machine. Using shell_exec I could launch the exe file via command prompt using php. When I try to run php program from the browser am getting a blank page. How to launch the executables from the browser using php?
And also, using ip address I should be able to launch in other system browser which is installed in one system.
php code:
<?php
shell_exec("cd / ; wine /home/quads/.wine/drive_c/Program\ Files/MathType/MathType.exe");
?>
If I run this through command prompt it could launch an application but via browser it
doesn't work.It it works via browser then I can access that application from other system using
myipaddress/phpprogram
Please try this
<?php
shell_exec("wine MathType");
?>
It will work only in Internet Explorer and ActiveX control should be enabled in the browser
code:
function openapp(){
var obj=new ActiveXObject("WScript.Shell");
obj.Run("file_exe_path",1,true);
}
<input type="button" onclick="openapp();" />

issue with PHP on IIS 7.5

So I've done a bunch of research and tried a bunch of things that it'll be difficult to try and explain everything i've already done but here's my issue.
My website isn't interpreting PHP code, whether I try to use an include 'file.php'; or just input the code directly into the HTML it doesn't matter.
I'm running Windows 7 with IIS 7.5 with PHP installed from php.iis.net. I'm going to keep it simple rather than go into the specifics of exactly what I'm trying to do, and hopefully once I get the simple things working the more complex stuff I'm working on will work.
Here's the HTML piece:
Weather condition is currently <?php echo '<p>Hello world</p>'; ?>
The output is
Weather condition is currently Hello world '; ?>
The beginning bracket of the PHP is hidden, after World its showing the rest on a new line under the text.
I also have
<?php
phpinfo();
phpinfo(INFO_MODULES);
?>
That returns nothing on the webpage, and if you look at the source code you see the full PHP code. Same with the Hello world example, the text doesn't show the ?php portion but viewing the page source you see the full php.
There's something I'm missing somewhere in the IIS config or the PHP config and I'm just not finding it.
Any insights or ideas I'm open to try. This is a fresh IIS and fresh PHP install, I installed IIS on this workstation specifically to get this PHP script to work so it is doing nothing else but hosting this web page.
thanks!

Can't connect to localhost using Chrome with Uniform Server

I'm trying to run a .php web application on Google Chrome, using Uniform Server. I thought that just having that installed would make PHP run, but clearly there's a lot I don't know. First off, when I opened the file from file:///C:/Users/... etc the PHP didn't execute properly. Here's the code:
<html>
<body>
Hello to you, good sir.
<?php
echo "</br> Hello there yourself.";
?>
</body>
</html>
Here's the output on the website:
Hello to you, good sir. Hello there yourself."; ?>
And here's how the <body> code looks from Chrome:
Hello to you, good sir.
<!--?php
echo "</br-->
Hello there yourself.";
Then, when I tried accessing the file from localhost, Chrome wouldn't even connect, saying:
Oops! Google Chrome could not connect to localhost
I'm aware of this question, but the OP didn't appear to have software needed to run PHP. I'm pretty sure I have the right software, but I don't know how to use it. How do I get Uniform Server to run PHP, and how do I connect to localhost from Chrome?
PHP wont work if opened directly in browser, thats not how PHP works, it needs to be run through the PHP parser.
A Step by step:
Download the Latest package
Unpack it onto desktop or C:, (somewhere your find it)
Open up the UniServerZ folder, where you unpacked it
Double click UniController.exe
Click Start Apache button - it should go green like below
Remove the junk files in UniServerZ/www
Put your PHP files inside that www folder.
Visit http://localhost to view your PHP files

Server side script for launching application

I have been trying unsuccessfully so far to write a php script that will run when a page is opened and that will launch metasploit!
I ve tried shell_exec and exec and all the other alternatives but although I can get it to do simple things (i.e. ls, cds etc) if I try msfconsole it doesnt do anything!
I have also tried a different script that launches firefox and again nothing happens!
Now i know that php runs on the server and I m not expecting to see a console or firefox opening in the clients machine! Instead in order to check if it works I am trying to echo out the output of the shell_exec!But anyway since im hosting the files on my machine (i.e. this is the server and a VM is the client) if it could actually launch firefox i should be able to see the app opening here in the same way as by just doing this from the command line!
What am I missing?
Is there any other way to do this?(i.e. Launch metasploit everytime a user opens up my page)
NOTE: I've tried specifying the full path for msfconsole but that didnt work either!
Heres what I have so far:
$output = shell_exec('/opt/local/libexec/metasploit3/msfconsole;show');
echo "<pre>$output</pre>";
The ";show" bit was used in order to actually make it run something and print some stuff but didnt make any difference!
When you run a gui application from the command prompt in a X window system, it will use the default display. When you run it using php which is embedded in apache webserver, the program may not know where to display the gui application.
there are 2 things to make this work.
The program that executes the gui application must have permission to use display
you need to tell the program which display to use.
I used the following in my php script
<?php
$cmd = `export DISPLAY=:0; gedit`;
shell_exec($cmd);
?>
and ran the script from terminal using php -f test.php
I got the gedit up and running.
You can test the same with the script in apache too.
Please add apache user with privileges to access display server
update: I just added the following in /etc/apache2/apache2.conf (I am using ubuntu)
User poomalai
Group poomalai
and restarted the web server
sudo service apache2 restart
now I accessed localhost/test.php
and Presto!! I got the gedit :)
Hope this helps

Categories