
Helmet
Members-
Posts
88 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Helmet's Achievements

Member (2/5)
0
Reputation
-
Using cURL to verify existence of URL always returns 302 Found / OpenDNS
Helmet replied to Helmet's topic in PHP Coding Help
I guess these OpenDNS guys have a wildcard in the DNS system redirecting bad requests to their search page or something, so I changed my code to look for the term "opendns" and smack it down. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); //follow up to 10 redirections - avoids loops $data = curl_exec($ch); curl_close($ch); preg_match_all("/HTTP\/1\.[1|0]\s(\d{3})/",$data,$matches); $code = end($matches[1]); if(!$data) { return false; } if(stristr($data,'opendns')){ return false; } return $code==200 ? true : false; -
Hi, DNS is not my strong point, but I don't know why I would be having this problem anyway. I want to use cURL to check URL's entered by my users to make sure they exist. Testing this, if I enter a garbage URL like "asdfsfdfsfdf ", I always get the following response: HTTP/1.0 302 Found Location: http://guide.opendns.com/?url=asdfsfdfsfdf Content-type: text/html Connection: close Date: Wed, 08 Jul 2009 18:06:05 GMT Server: OpenDNS Guide HTTP/1.0 200 OK Cache-Control: no-cache, must-revalidate Expires: Mon, 26 Jul 1997 05:00:00 GMT Content-Type: text/html; charset=utf-8 Pragma: no-cache Set-Cookie: t=x-1247076706; expires=Fri, 07-Aug-2009 18:06:46 GMT Connection: close Date: Wed, 08 Jul 2009 18:06:46 GMT Server: OpenDNS Guide This is the code (not mine) that I'm using to check the URL: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); //follow up to 10 redirections - avoids loops $data = curl_exec($ch); curl_close($ch); preg_match_all("/HTTP\/1\.[1|0]\s(\d{3})/",$data,$matches); $code = end($matches[1]); if(!$data) { echo "Domain could not be found"; } else { if($code==200) { echo $data; echo "Page Found"; } elseif($code==404) { echo "Page Not Found"; } } What on earth is going on here? Is this something I can fix, or am I up the creek? I'm on shared hosting with private nameservers and my domain is registered with GoDaddy if that information is of any help. Thanks!
-
[SOLVED] External email text file template with variable interpolation
Helmet replied to Helmet's topic in PHP Coding Help
Thanks for your reply I ended up doing it like this: mail_template.txt: Hello {first_name}, Thank you for your interest in {product_name}. A sales associate will contact you shortly. Sincerely, process.php: //$_POST variable names from form are same as variable names in curly braces in template.txt $input = file_get_contents('mail_template.txt'); $output = preg_replace('/\{(\w+)\}/e',"\$_POST['\\1']",$input); //send output to mail script -
If your new host uses a different default character set for for their MySQL and your input apostrophes are curly or something crazy like that (I'm not an expert on character encoding, but I have encountered a similar issue) then this could be causing an error.
-
No, you can't do that with Javascript alone because you need to save the values. Javascript runs on a user's browser and would need to interact with a server-side script to get the latest number. You need a php script that queries the database for the total number of rows in the registration table. You can use asynchronous javascript to get that value from the php script and update the number on the screen at regular intervals if the user is sitting on the page long enough. I suggest you use a javascript library for this, like Mootools. Look into Request and Periodical.
-
Maybe try converting to different character sets? Shot in the dark.
-
I meant this: http://advertise.vgbetting.com/adpeeps.php?bfunction=showad&uid=100000&bmode=off&gpos=center&gwidth=616&bzone=homepage&bsize=616x176&btype=3&bpos=default&ver=2.0&btotal=1&btarget=_blank&brefresh=5&bborder=0&showhorizontally=1 Try loading that file: blank page. View source: blank. It's not working because there's no javascript in it, and you're trying to load it as a javascript file.
-
There's something weird going on with your two quotes (single or double) at the beginning of the string. This should work: echo substr($row['description'],0,50).'<span class="style666"><a href="http://xxxxxxxxx.com/viewitem.php"> ...View</a></span>';
-
It looks like you're asking MySQL to format it, then you're asking PHP to format it. You should pass the raw value to the PHP date function.
-
You're passing Product_ID in the querystring, so that one is part of the _GET array. The others are _POST (if the form method is set as such). Either make Product_ID a hidden field in your post form or change the code on the second page to look for $_GET['Product_ID']
-
Is the php file served up with a javascript content-type header?
-
http://us3.php.net/manual/en/features.file-upload.multiple.php
-
I'm looking at this problem for the first time and wondering the best way to approach it. I have to create a couple of editable text files containing the contents of an auto generated email for my client's site. They want to be able to edit it, which is why I want to put the content in a text file which would be processed and then sent to the mail script, like PHPMailer or Swiftmailer. Example: automail.txt -------------------------- Hello %first_name%, Thank you for your interest in %product_name%. A sales associate will contact you shortly. Sincerely, etc etc Is there an established "right way" to do this? I've been looking for information using keywords "text file interpolation php" but finding only general variable interpolation in code, not like this type of basic template stuff. I might not be searching on the right keywords. I have looked at eval, but I wouldn't want to rely on php variables with dollar signs since at some point when they're editing the template they could add one to the content and break the script. How should I be approaching this, or does anyone know of a good place to find an example?
-
[SOLVED] Update date month year selects from next day of the week select
Helmet replied to Helmet's topic in Javascript Help
I resolved this using Mootools new Date.Extras extension: http://www.clientcide.com/wiki/cnet-libraries/03-native/01-date.extras -
That was probably a confusing title, sorry. I have drop downs for entering date information into a form select 1: monday/tuesday/wednesday... select 2: month select 3: date select 4: year These all default on load to today's values, but I'd like selects 2-4 to update with the values corresponding to the next select 1 if the user changes it. I know how to change the values, but I'm drawing a blank on how to calculate what to change them to. Any suggestions?