Search found 303 matches

by tr0gd0rr
Mon Oct 29, 2012 2:35 pm
Forum: PHP - Code
Topic: XPATH question load, loadXML, loadHTML
Replies: 5
Views: 1500

Re: XPATH question load, loadXML, loadHTML

Weirdan wrote:...because you're querying for non-namespaced P elements, while in the document you have xhtml:p elements...
Awesome bit of insight! Thanks for sharing.
by tr0gd0rr
Thu Oct 25, 2012 1:38 pm
Forum: PHP - Code
Topic: XPATH question load, loadXML, loadHTML
Replies: 5
Views: 1500

Re: XPATH question load, loadXML, loadHTML

The HTML parser that PHP uses with loadHTML is more forgiving than the XML parser. By nature, HTML is more permissive than XML. And in practice, browsers are very good at dealing with invalid markup. I'd wager that vast majority of HTML served on the Internet is not valid XML. And much of the Intern...
by tr0gd0rr
Wed Oct 17, 2012 1:47 pm
Forum: PHP - Code
Topic: ORDER BY...ASC
Replies: 10
Views: 1474

Re: ORDER BY...ASC

- It is weird without a space between the second apostrophe and "ORDER" but it works.
- You should escape $User_Id or cast it to an integer.
- It seems like the query would only ever return one result so the ORDER BY would have no effect.
by tr0gd0rr
Tue Oct 09, 2012 1:29 pm
Forum: PHP - Security
Topic: Checking page is call by Ajax
Replies: 2
Views: 7143

Re: Checking page is call by Ajax

Most JavaScript Ajax libs like jQuery and Prototype use the non-standard header HTTP_X_REQUESTED_WITH which you can test like `if (strtolower(@$_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')` but as requinix says, anybody can send any request headers they want so HTTP_X_REQUESTED_WITH cannot...
by tr0gd0rr
Mon Sep 17, 2012 1:09 pm
Forum: PHP - Code
Topic: Show external images - best/fastest way?
Replies: 7
Views: 1928

Re: Show external images - best/fastest way?

At that point maybe start looking at the server load? Maybe you need a beefier server.
by tr0gd0rr
Thu Sep 13, 2012 1:39 pm
Forum: PHP - Code
Topic: Show external images - best/fastest way?
Replies: 7
Views: 1928

Re: Show external images - best/fastest way?

If you are going to create a copy of the image you can use copy() as long as remote url fopen is enabled. If you do need to use gd for some reason, cache the resulting image instead of creating it every time. But maybe the simplest solution is to just send a 302 or 303 header: header('HTTP/1.1 303 S...
by tr0gd0rr
Tue Sep 04, 2012 1:57 pm
Forum: PHP - Code
Topic: Reading email files
Replies: 6
Views: 1474

Re: Reading email files

I don't think you can define a custom email header that will get returned in a bounced email. What you'll need to do is use a "Message-ID" header that uniquely identifies the email. The Message-ID will get passed around when the message is returned, forwarded, or replied to. It depends on ...
by tr0gd0rr
Fri Aug 24, 2012 1:54 pm
Forum: PHP - Code
Topic: curl doesnt quite cut it
Replies: 3
Views: 782

Re: curl doesnt quite cut it

is there a way to simulate browser rendering? CasperJS is an awesome way to use a virtual browser to open a site, manipulate dom, take screenshots, click elements, submit forms, etc. On Ubuntu, you can install it with `sudo apt-get install casperjs` or OSX `brew install casperjs`. It uses a full V8...
by tr0gd0rr
Fri Aug 24, 2012 1:49 pm
Forum: PHP - Code
Topic: Reading email files
Replies: 6
Views: 1474

Re: Reading email files

Reading emails manually is very complicated because of all the MIME rules etc. I'm using Zend_Mail right now and it works great. You can use it to connect via pop/imap and read emails or you can read from a file like you are wanting: $message = new Zend_Mail_Message(array('file'=>'/home/myaccount/ma...
by tr0gd0rr
Tue Aug 21, 2012 1:05 pm
Forum: Job Hunt
Topic: Dynamic PDF Creation
Replies: 2
Views: 2519

Re: Dynamic PDF Creation

You might be underestimating how complex it is to build a html to pdf renderer from scratch. If you need one from scratch, it would take a single programmer many years to develop. I would recommending starting from dompdf or using casperjs to take screenshots and convert the png files to PDF files u...
by tr0gd0rr
Mon Aug 13, 2012 1:11 pm
Forum: PHP - Code
Topic: date time displayed are minus one day
Replies: 5
Views: 1247

Re: date time displayed are minus one day

Also note that there are not 24 time zones, there are over 400 ! When I say time zone, I mean "America/Denver" or "Europe/Oslo". This is because different countries and cities have different start and end date for daylight savings changes. If you store a user's time zone as -04:0...
by tr0gd0rr
Fri Aug 10, 2012 2:04 pm
Forum: PHP - Code
Topic: date time displayed are minus one day
Replies: 5
Views: 1247

Re: date time displayed are minus one day

The ideal is to store all dates in the database as UTC! In your a PHP include file, do `date_default_timezone_set('UTC');` and it won't matter what time zone your database is in. Then when you do `$now = date('Y-m-d H:i:s');`, for example, the date will be in UTC. When you get a date input from the ...
by tr0gd0rr
Fri Aug 10, 2012 1:51 pm
Forum: PHP - Code
Topic: Using PHP cURL To Click Button
Replies: 1
Views: 3349

Re: Using PHP cURL To Click Button

Instead of PHP you can use CasperJS which will run a full V8-based browser on the server. Example usage (JavaScript):

Code: Select all

casper.start(url, function () {
	casper.click('#recruit_link');
});
by tr0gd0rr
Fri Aug 10, 2012 1:44 pm
Forum: PHP - Security
Topic: Hide URL in status bar
Replies: 13
Views: 22595

Re: Hide URL in status bar

From Stack Overflow: "window.status has been disabled in most (if not all) browsers for security reasons".

You can't change it.
by tr0gd0rr
Thu Aug 09, 2012 1:43 pm
Forum: Swift Mailer
Topic: Swift Mailer and Newsletter Stats
Replies: 2
Views: 20856

Re: Swift Mailer and Newsletter Stats

To track those things, you need to embed links that go to a web site you control. Email opens can be tracked using a 1x1 pixel gif with a special URL that ties that newsletter to that recipient. For example: `http://example.com/open/abcdefghijklmnopqrstuvwxyz`. You look up the abc... part in your da...