phpinfo() is working and echo is not - Why would this be? - echo

Obviously I was looking to do something else but as it wasnt working, I have stepped back to a very fundamental test:
<?php
phpinfo();
?>
<?php
echo "Test";
?>
Can anybody give me any ideas as to why the first script works, and the second doesnt. Nothing else in the file, just one or the other! A .php extension.
Not sure why I am having to iterate over this - thanks alot phaberest!
The resolution in the suggested duplication talked about having a php file extension - well this has a php file extension. On the other points that #rene pot, put forward - phpinfo() is outputting, so yes there is php installed on the server. I am not using localhost but servername.co.uk/phpinfo.php

Related

PHP script works from browser but not from Windows Server Task Scheduler or from CMD/PS

I have this simple script called webcam.php to acquire some screenshot from webcams
<?php
$d=date('YmdHis');
$url = 'http://xxx:40801/snap.jpeg?'.$d;
$img = 'camera_east.jpg';
echo file_put_contents($img, file_get_contents($url));
$url = 'http://xxx:40802/snap.jpeg?'.$d;
$img = 'camera_west.jpg';
echo file_put_contents($img, file_get_contents($url));
echo $d;
?>
and if I call http://xxx/webcam.php from browser, everything's OK:
I find the two pictures in the folder, and the script returns the length of the files and the timestamp as echoes.
I tried to make this script to be executed by the windows scheduler, but although it returns 0x0 the pictures are not updated.
(I tried also unlinking the images, and also using curl but nothing changes)
Then I tried to run the PHP script from command line (also from PowerShell):
something like:
C:\Program Files\PHP\v7.2\php.exe -f C:\\webcam.php
but again, although it seems working, since it returns the length of the two files and the timestamp, the pictures are not updated and if I add unlink command, files are not cancelled:
Clearly folder has all permissions...
I've not big experience in PHP... :-(
what can be wrong?
Thanks!
obviously from cmd/ps/scheduler requires the full path,
while from browser can accept relative path

Unable to open .php file on browser using http://localhost/dirname

On Ubuntu 16.04 when I try to open .php file on browser using http://localhost/vish+all it show blank page and a word 'yes' written on it . And due to this I am unable to acess php file on browser.
And I have php7.0 installed on it. What does word 'yes' means.
And how can I find solution for this?
You must need to verify if the php is a index.php and if is inside the command echo 'yes';
because echo <--- prints any character.
Example:
<?php
echo 'yes';
?>
also check your php.ini and check if your short_open_tag=On is ON because if is not your code will not work instead of
Also try to remove "+" from your directory or try to upload a new php called info.php and copy inside there the following code
<?php
phpinfo();
?>

Symfony 3 - The CSRF token is invalid. Please try to resubmit the form

So first of all, I already tried to find another topic related to my issue as it already exists a lot :p.
But I can't figure out why Symfony keeps telling me that ... :
The CSRF token is invalid. Please try to resubmit the form
I'm using a regular form, and the weird part is that it works on another computer but not on this one (the files are the same except the cache/session/log files).
I use both {{ form_rest(form) }} and {{ form_end(form) }} twig variables. I increased both max_input_vars and upload_max_filesize properties of my php.ini .
My database is up to date.
The hidden _token input is displayed in the html.
I cleared my app and browser caches.
Since this is a local website, I just granted all my folders/files with the 777 permission..
EDIT : If I replace (app/config/config.yml) :
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
with
save_path: ~
It works.. But I have no idea of what are the consequences of this? Sessions are stored based on the php.ini file right? So can I use this setting instead of the previous one without any problems?
Otherwise, I have absolutely no idea of what could cause the error.
Thank you for your help! :)
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
should be fine. Just make sure that your var/sessions folder exists and it is writable
mkdir -p var/sessions
chmod 755 var/sessions
The same must be true for var/cache and var/logs.
i had the same pb
1st i worked with xampp that is using apache(works fine -no changes required)
2nd i moved on ubuntu with nginx(here was the pb)
i deleted sessions/cache ->nothing
instead i changed "save_path: ~ " and it's work

Issues with batch write to txt

I am working on a fancy Zip archive cracker and its working perfectly.
And I successfully made it write the output to a log file. however my problem is:
if I run a crack on the same file again just couple of seconds later, it will overwrite the already existing log, but what I want to do is:
if the log file already exist. it will not overwrite the log file. but it will ADD in the new output of the new crack to the already existing file so when I open the log I will then see both of the cracks that I have done in same log file.
heres the code:
(
echo ==============================================
echo Crack log
echo ==============================================
echo.
echo PASSWORD FOUND!
echo Date/time log for decryption: %Date%\%time%
echo FILE = %NAME%
echo CRACKED PASSWORD = %PSWD%
echo Tests: %PSWD1%
echo.
echo Time Spendt to crack Archive: %hh%:%mm%:%ss%,%cc%
echo Hours: %hh%
echo Minutes: %mm%
echo Seconds: %ss%
echo Centisecods: %cc%
) > %Date%_Cracklog_%NAME%.txt
if exist %Date%_Cracklog_%NAME%.txt >> %Date%_Cracklog_%NAME%.txt
ok this problem has now been solved by:
#Aacini and #mofi
Solution: Change ) > %Date%Cracklog%NAME%.txt by ) >> %Date%Cracklog%NAME%.txt and delete the next line
==========================================================================
however now I got another problem.
i managed to add in on bottom line a function that creates a directory for each crack log. wich looks like this:
"MKDIR Logs\%name%
) >> %Date%Cracklog%NAME%.txt"
the mkdir works perfectly. the point with it is creating a subdirectory under the logs folder with the name of the cracked zip archive.
and the problem that is still there is that I got no idea how to make the script to create the actual log file inside that directory,
ive been googling and testing several things but I find nothing that really works. and at the same time. if I decide to crack another file, well yeh then the scripts makes a new sub directory but then I also want the new log file into its belonging folder.
anyone got any idea how to fix that?
(thanks for all help so far<3 I love ya guys)
if you choose to help me futher. please write an example or a helping answere by clicking the answere question button so i can give you reputation :D)
==============================================================================
Edit:
Managed to find out the last problem myself, I just took a break from all thinking then went back with a cup of coffee and then voila solution popped up in my head... I guess I was just a bit tired. however this is how I solved the problem:
(
echo ==============================================
echo Crack log
echo ==============================================
echo.
echo PASSWORD FOUND!
echo Date/time log for decryption: %Date%\%time%
echo FILE = %NAME%
echo CRACKED PASSWORD = %PSWD%
echo Tests: %PSWD1%
echo.
echo Time Spendt to crack Archive: %hh%:%mm%:%ss%,%cc%
echo Hours: %hh%
echo Minutes: %mm%
echo Seconds: %ss%
echo Centisecods: %cc%
MKDIR Logs\%name%
) >> Logs\%name%\%Date%_Cracklog_%NAME%.txt

How to write php so that the correct file can be downloaded over linux command line?

So basically i have a problem where the user will send a request to test.php?getnextfile=1, and i need to process the request and figure out what is the next file in line to be downloaded, and deliver it to the user. The part that i'm stuck on is how to get the correct filename to the user (the server knows the correct file name, user doesn't).
Currently i've tried to use wget on the test.php?getnextfile=1, and it doesn't actually save with the correct filename. Also tried to header redirect to the correct file, and that doesn't work either.
Any ideas?
Thanks a lot!
Jason
Since Jul 2010, this is impossible in default wget configuration. In process of fixing security bug, they switched "trust-server-names" option off by default. For more information, see this answer:
https://serverfault.com/questions/183959/how-to-tell-wget-to-use-the-name-of-the-target-file-behind-the-http-redirect
In your php script you need to set the 'Content-Disposition' header:
<?php
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="myfile.zip"');
readfile('myfile.zip');
?>
Use curl instead of wget to test it.
curl --remote-name --remote-header-name http://127.0.0.1:8080/download