I went to edit this PHP file - it's supposed to generate those captcha security images on contact forms - the images werent working, so I was going to see if there was a broken path or something i could fix simply.
But when I opened the file it looked like this:
http://mydomainsample.com/explosion/screenshots/Screen%20Shot%202012-05-17%20at%209.34.14%20AM.png
complete gibberish.
Is it possible this happened somehow while downloading the file from the server? I did not have ftp access to the site originally - we got control of the domain and transferred it from one host to another.
I used site sucker to backup the site before transferring, but it downloads php files as html files. you end up with filename.php.html.
in the past this has never turned the php into incomprehensible gibberish, so i dont understand why it did now.
The problem is, you cannot use programs like "site sucker" to get PHP files. This is because when you get a PHP file from a URL, the file is executed, and you're getting the output of the script. That's why you get .php.html.
It doesn't "turn the php into incomprehensible gibberish", the server runs the script and you're getting the output. Most of the time the output is HTML, which you can open as text. In this case, the script's output is a PNG file, thus why you see "gibberish". Rename the file to .png, then you'll see the image.
You need to get FTP access in order to get the PHP source.
That's a PNG image, not PHP source code.
The file actually looks like a PNG image, maybe you just downloaded output the PHP script has generated?
Related
I have a php upload script. And it is working fine. I only want to know if the way i am saving my picture is safe and it will display on all browsers. Let say i uploaded: image.gif then i saved it to upload folder as: 2ad25adt4mt2 i.e <img src="/upload/2ad25adt4mt2" alt="pho"> notice that there isn't an extension. Though It displays on my current browser. Just want to know if it will display on all browser if my site is viewed.
You can try using browsershots.org to see what your site looks like on other browsers and computers, however it is typically considered best practice to include file extensions as they are what tell the computer "hey this is an image/text/whatever file and you need to open it with program X".
As far as I know, there are no security benefits that leaving off the file extension gives you.
I'm having a problem when I try to open files that were generated by my CMS on my windows machine. It has an upload function that saves the file on a given location (it is on my user folder, where I'm supposed to have all the write and read permissions).
All I can see in that folder is a generic thumbnail, the ones generated by windows for each image type, PNGs and JPEGs in this case. I tried to change de image permissions and set it to the current computer user but it doesn't work. And I'm unable to move these files to another location (upload them to the server via FTP).
I wonder if there is a way to change this behavior.
One thing I noticed is that if I copy and paste those files, I can see its contents normally. I know I can do that to each of them and rename, but there are dozens of images in that folder... don't wanna do the same thing everytime I upload a new image.
Update
This is happening only to the images that were moved (I'm using php's move_uploaded_file function, btw), not to the ones that where generated (croped, resized and so on).
It`s happening because Windows keep file permissions of TEMP folder (usually c:/windows/temp) when moving a file.
To prevent it you need to change "upload_tmp_dir" in "php.ini" to your server directory or set wide permissions to your windows temp folder.
You probably have an error in some php file which is preventing the image from being displayed correctly.
What i would do in order to detect the problem is to comment out the header() calls in the php file responsible for displaying the image and see if there is any output other than the image data.
Inspect the whole output, it only takes a character to break everything, so check if there are no blank lines at the top or bottom of the output. And in case you have an error log, consult that, it will help you trace the problem quickly.
When i have this problem, it's usually a notice or a warning showing up during the process of the image generation, and if you haven't disabled errors from being output to the screen, the notice text will be considered as part of the image data which makes the browser unable to interpret your image.
If you'd like i can take a look closely for you but i would need to see what you are doing in that php file to be able to tell you for sure.
I am a beginner at both Actionscript3 and PHP, and I'm trying to get Henry Jone's movie clip to jpeg code to work for me, as seen here:
http://henryjones.us/articles/using-the-as3-jpeg-encoder
I downloaded the source and then uploaded the .swf and the .php in the same directory. However, when I click "download your sketch," it downloads the .php file instead of a jpeg.
The .swf I uploaded can be seen here:
http://www.snut.org/storage/scrntest/sketch.swf
I didn't change any of the code from the source I downloaded, so I can't figure our what the problem is. Can anyone help?
Rule of thumb - any time your web server downloads .php files instead of rendering the output of the file it is a good sign that your server isn't set up to handle PHP. You need to tell Apache to use PHP, google around for "install PHP on Apache web server" and that should get you started.
Basically .php files are just text files, so unless you have something telling your web server to treat .php files different from normal text files then it'll just assume the user wants to download the file that's being linked.
I made a class that converts a string of text into a png image and uploads on the server:
http://testing.mehhh.org/php/png.php (you can view php source on the page)
http://testing.mehhh.org/php/phg.php <-- shows php version
this one works great.
now I am trying to get this to work on a clients server
http://autoxplorer.com/~tameem/png.php This doesn't work!
http://autoxplorer.com/~tameem/php.php <-- also using same php version
what gives? I thought it's a permission thing.. but the png folder has full access.. and I tried a super simple uploading script and it runs and saves files to that folder. What is going on here?
You have just put online some PHP scripts that link to images. The link to the images actually is different.
http://testing.mehhh.org/php/png/4de9441d68cf8_1307132957.png
http://autoxplorer.com/~tameem/png/4de9424d41208_1307132493.png
While the first link returns actually an image, the second image link gives a 404 error. Looks like you have not configured your server properly to actually execute the PHP in the second case to return an image.
I have a weird unexplainable phenomenon going on.
I downloaded some source code from a website, a basic PHP script. It came with an SQL to reference numbers as part of the script.
I uploaded the file called post.php and SQL file to my server and ran it - but - instead of executing the code in the PHP file, it loads the content of the webpage of the author of the source code. and stays on my server URL.
The code in the file has nothing to do with the author's site, or graphics or links or redirects or anything.
EVEN IF I delete the entire contents of the post.php file, run the empty file and it STILL LOADS CONTENT from the author's website, where I downloaded it from.
Refreshed browser, restarted, reloaded, you name it. How is this physically possible?
-----UPDATE
In addition when I try renaming PHP files on my server, they become permanently broken "oops broken link" error.
It would be very helpful if you could post some more specific details about what the script was, etc. But, here is my guess. Firstly, make sure that your web server is not doing any caching. If the problem persists, try getting rid of the post.php file itself. Then, I would check to see if the PHP script has created any HTML/PHP files on its own. If all else fails, try going into the code that you downloaded and see what its doing.