php string is appened to every request [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I've got a problem. After moving a project to another server I get strange string "192" which is inserted before every response from server. I did no changes into source code and it works fine on another server. I've only copied project... Really. That's all.
This is how it looks:
It can be beared when dealing with generated pages. but json reponse is not correct so it gets broken because of this number "192".
In the root folder /var/www/html I have only this project. Nothing else.
I guess it must be something with php settings. Thanks in advance!

The problem is with the code off course. Check the configuration files you are adding before executing any file of the view.
If you want to verify there is something wrong with the code, you may just put an empty hello world file and execute it from the browser. See if 192 comes there also or not.
Something like this on /var/www/html/test.php
<?php echo "Hello World"; ?>
Now run your website http://yourwebsite.com/test.php and share the output.

If the 192 is not in your code (and since it doesn't show on a different server, it certainly seems so), another very strong contender from where it is coming from is the php.ini option, auto_prepend_file.
auto_prepend_file string
Specifies the name of a file that is automatically parsed before the
main file. The file is included as if it was called with the require
function, so include_path is used.
The easiest way to find out if there is a file being included before all of your requested pages is by searching the phpinfo() output for auto_prepend_file, and editing the php.ini file to remove it if it is there.

Related

Making php script executable [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm filling out a job application which has asked me to write a function which you submit to them as a .php file. The last line of the specification says:
Make sure your file can be executed from the command line: php meats.php (this helps us to check if the code works before even looking at it)
Does anyone know what that means? I've checked that function works fine on my hosting environment but I'm just not sure there is something else I need to do??
Thank you
Without seeing your code, you'll need to make sure it's not using anything that's dependent on being run rendered in the browser executed on the server via a client browser's HTTP request to a webserver, which may send data back to the browser for rendering. These include $_GET,$_SERVER['DOCUMENT_ROOT'] (for relative web paths), and other such variables. You may need to convert these to use magic constants or otherwise work around your limitations.
I'm about to send you down a rabbit hole if you've never been to your command line, but you should SSH into your web server and try to execute your php file just like they said. You'll navigate to the directory with the file and run
php meats.php
Then, the command line will spit out any echos that you've got, or do whatever else your code does.

PHP ini file Setup Linux [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I've recently upgraded to a dedicated server; previously I was on a shared server, so I have no experience with the php.ini file. I've opened it and looked through it, searched Google and SO but nothing is clear to me.
Can someone clear up, for me, the way to add/edit lines in an ini file and what, if any, lines can be removed?
More specifically I'd like to edit the time a session is active for, the default date, etc.
UPDATE: I'm running PHP 5.5 on a Linux server.
EDIT: There is some confusion: I'm not asking "how to edit the file". I'm asking "what parts of the file can I remove and where can I update parts of the file".
Ini format is rather simple: entries are key/value pairs, with an equal sign between each side. Comment lines start with a semicolon.
The php.ini is fairly well commented. I'd suggest commenting any lines out, rather than removing them, and restarting the webserver or running a command line app to see that startup goes okay.
Which lines are needed and which values are okay vary depending on your server config and the php programs you intend to run.
The default timezone setting is http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
There are a few session related config parameters. I suggest reading How do I expire a PHP session after 30 minutes? for info on session lifetime.

Apache file permissions for PHP but not for direct access [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I installed an Apache server and am playing around with it a bit. What I can't figure out is how to properly set permissions for this setup:
I don't want my files to be externally accessible (i.e. ./files/file1.foo) - there are many files in this directory and I don't want people to be able to read them. So far so good. chmod o+r enables reading and vice versa, in my case.
Then I have a PHP script that handles sessions with each user, who owns one of the files and should be able to view it, but only it, not the other files. Let's say the file is a picture. I would write <?php ... echo "<img src=\"files/file5.foo\"> ?> to show this file. But that wouldn't work, because the PHP doesn't have permissions to the file either.
What is the way to handle this?
For those requirements the best solution is to store the protected files outside of the public HTML and use a PHP script to serve them. The PHP can then check if the current user should be allowed to access the requested file or not.
Have a look at this example. For inline images, don't set the file transfer headers, just output the content (you can still output a content-type header but that isn't needed).

Resetting .htaccess in a particular directory [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
This question is directly related to a previous question of mine :
php files are downloaded instead of ran
But I have narrowed down the problem so that answering one question technically answers both.
I have made many changes to .htaccess in a certain directory above the root. We'll just call it /dir. Somewhere along the way, I made a change that broke the way php runs files. My overall goal is to get php to run .php files again; however my question is about resetting the .htaccess for /dir. I created php files in the directory before /dir (previous/dir) and they run fine, so I just need to reset whatever changes are being held onto for that directory.
How can I clear all .htaccess for that directory.
Keep in mind, I have cleared the .htaccess file already. Whatever changes happened are being stored somewhere in apache that I can't get to. I just want to reset them and go back to where php was working in that directory.
Thanks.
The problem was that the original .htaccess had changed permissions to the directory because of password protecting. After I deleted the .htaccess file and the pwd, the permissions were still altered. After fixing the permissions I was easily able to fix everything.

Automatically saving doc file after 20 secs [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i am doing a php program which requires doc file to be saved after every 10 secs.msword should not ask the path to be saved. actually i have written a program which opens a doc file. the file should be auto saved to the exact location from where the file is opened.
If I understand you correctly, what you want to do is not possible (sadly).
There is no standard or protocol for live editing of remote files that have been downloaded from a web page in a browser. The file will be downloaded to a temporary location and opened from there.
Hence, any notion of providing an auto-save mechanism from PHP or JavaScript is completely impossible. The client application will have to do that.
If you want to upload the downloaded and locally edited file back to the web site, you will need to provide an upload form for the user to do it manually. (Which is a shame and completely unintuitive, but that's the way technology is at the moment.)
Not possible due to security reason in web technology.

Categories