php-general Digest 7 Jun 2007 11:35:54 -0000 Issue 4834
Topics (messages 256254 through 256265):
Re: Parse domain from URL
256254 by: Stefan Wixfort
256264 by: Robin Vickery
Re: More include issues
256255 by: Robert Cummings
256256 by: Jared Farrish
256257 by: Robert Cummings
256259 by: Jared Farrish
256263 by: Stut
register_globals and magic_quotes_gpc (again)
256258 by: Afan Pasalic
XSLT and DocBook
256260 by: Larry Garfield
Re: cannot make directory at remote host
256261 by: ross.aztechost.com
directories - again
256262 by: ross.aztechost.com
256265 by: itoctopus
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
> From: Brad Fuller [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 06, 2007 5:44 PM
> Subject: [PHP] Parse domain from URL
>
> Hey guys,
>
> I'm faced with an interesting problem, and wondering if there's an easy
> solution.
>
> I need to strip out a domain name from a URL, and ignore subdomains (like
> www)
>
> I can use parse_url to get the hostname. And my first thought was to take
> the last 2 segments of the hostname to get the domain. So if the URL is
> http://www.example.com/
> Then the domain is "example.com." If the URL is http://example.org/ then
> the domain is "example.org."
>
> This seemed to work perfectly until I come across a URL like
> http://www.example.co.uk/
> My script thinks the domain is "co.uk."
>
> So I added a bit of code to account for this, basically if the 2nd to last
> segment of the hostname is "co" then take the last 3 segments.
>
> Then I stumbled across a URL like http://www.example.com.au/
>
> So it occurred to me that this is not the best solution, unless I have a
> definitive list of all exceptions to go off of.
>
> Does anyone have any suggestions?
>
> Any advice is much appreciated.
>
> Thanks,
> Brad
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
Maybe use some regexp like this:
$url = http://www.a-domain.co.uk;
$domain = preg_match( "!^(http://)([-a-z0-9]+(?:\.[-a-z0-9]+)*)$!i" ); //
you will get www.a-domain.co.uk // So u can search for "www." In front of
the string to replace it or // you could edit the search for ignoring the
'www.'
Echo $domain[2];
Greetings,
Stefan
Note: this is untested.
--- End Message ---
--- Begin Message ---
On 06/06/07, Brad Fuller <[EMAIL PROTECTED]> wrote:
Daniel Brown wrote:
> On 6/6/07, Brad Fuller <[EMAIL PROTECTED]> wrote:
>>
>> I need to strip out a domain name from a URL, and ignore subdomains
>> (like www)
>>
>> I can use parse_url to get the hostname. And my first thought was to
>> take the last 2 segments of the hostname to get the domain.
> So if the
>> URL is http://www.example.com/
>> Then the domain is "example.com." If the URL is
>> http://example.org/ then the domain is "example.org."
>>
>> This seemed to work perfectly until I come across a URL like
>> http://www.example.co.uk/ My script thinks the domain is "co.uk."
>>
>> So I added a bit of code to account for this, basically if the 2nd to
>> last segment of the hostname is "co" then take the last 3 segments.
>>
>> Then I stumbled across a URL like http://www.example.com.au/
>>
>> So it occurred to me that this is not the best solution, unless I
>> have a definitive list of all exceptions to go off of.
>>
>> Does anyone have any suggestions?
>>
>> Any advice is much appreciated.
>
> Well, it's not very clean, but if you just need to remove
> the subdomain/CNAME from the domain....
>
> <?
> $hostname = parse_url($_SERVER['SERVER_NAME']);
> $domsplit = explode('.',$hostname['path']);
> for($i=1;$i<count($domsplit);$i++) {
> $i == (count($domsplit) - 1) ? $domain .= $domsplit[$i] :
> $domain .= $domsplit[$i]."."; }
> echo $domain;
>>
>
> There's probably a much better way to do it, but in the
> interest of a quick response, that's one way.
Yes, that's basically what my code already does.
The problem is that what if the url is "http://yahoo.co.uk/" (note the lack
of a subdomain)
Your script thinks that the domain is "co.uk". Just like my existing code
does.
So we can't count on taking the last 2 segments. And we can't count on
ignoring the first segment. (The subdomain could be anything, not just www)
In that case you can't do it just by parsing alone, you need to use DNS.
<?php
function get_domain ($hostname) {
dns_get_record($hostname, DNS_A, $authns, $addt);
return $authns[0]['host'];
}
print get_domain("www.google.com") . "\n";
print get_domain("google.com") . "\n";
print get_domain("www.google.co.uk") . "\n";
print get_domain("google.co.uk") . "\n";
print get_domain("google.co.uk") . "\n";
print get_domain("google.com.au") . "\n";
print get_domain("www.google.com.au") . "\n";
/* result
google.com
google.com
google.co.uk
google.co.uk
google.co.uk
google.com.au
google.com.au
*/
?>
--- End Message ---
--- Begin Message ---
On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
> >
> > I try not to bother the list and figure things out by myself as much as I
> > can, but it's hard when I was "volunteered" to become the guinea pig to
> > convert some of our apps from ColdFusion to PHP...especially when nobody I
> > work with has ever touched PHP before. I have nobody to turn to except
> > google/forums/this list.
>
>
> I feel ya brotha! I think Stut might be having a bad day...
Bad day?? Did you read the same posts I read?
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
On 6/6/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
> I feel ya brotha! I think Stut might be having a bad day...
Bad day?? Did you read the same posts I read?
Cheers,
Rob.
Sure I did. Let's not take this too seriously, ok?
--
Jared Farrish
Intermediate Web Developer
Denton, Tx
Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$
--- End Message ---
--- Begin Message ---
On Wed, 2007-06-06 at 20:26 -0500, Jared Farrish wrote:
> On 6/6/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> >
> > On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
> > > I feel ya brotha! I think Stut might be having a bad day...
> >
> > Bad day?? Did you read the same posts I read?
>
> Sure I did. Let's not take this too seriously, ok?
You forgot a winkie ;) :)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
On 6/6/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
On Wed, 2007-06-06 at 20:26 -0500, Jared Farrish wrote:
> On 6/6/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> >
> > On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
> > > I feel ya brotha! I think Stut might be having a bad day...
> >
> > Bad day?? Did you read the same posts I read?
>
> Sure I did. Let's not take this too seriously, ok?
You forgot a winkie ;) :)
Cheers,
Rob.
Ach! YOU ARE SOOOO RIGHT!
Now I need a twinkie... ;)
--
Jared Farrish
Intermediate Web Developer
Denton, Tx
Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$
--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
On Wed, 2007-06-06 at 20:26 -0500, Jared Farrish wrote:
On 6/6/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
I feel ya brotha! I think Stut might be having a bad day...
Bad day?? Did you read the same posts I read?
Sure I did. Let's not take this too seriously, ok?
You forgot a winkie ;) :)
Hey, leave my winkie out of this!
-Stut
--- End Message ---
--- Begin Message ---
hi,
this question is already posted thousand times. but, after I tried for 2
hours to figure it out, I gave up and posted the question here.
I'm rebuilding one site. php 4.4.4
as usual, register_globals on, as well as magic_quotes.
I tried to turn it off using .htaccess but what ever I change in the
(already existing) file, I would get 500 Internal Server Error
this is content of the .htaccess file:
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName mkl1332
AuthUserFile /u/web/afan/_vti_pvt/service.pwd
AuthGroupFile /u/web/afan/_vti_pvt/service.grp
and I tried to add
php_flag register_globals Off
and it doesn't work (500 internal server error)
I tried with register_global 0 - same thing.
could you please point me where to look after?
thanks for any help.
-afan
--- End Message ---
--- Begin Message ---
Hi all. I have a DocBook source[1] that I am processing into XHTML using the
DocBook XSL[2] toolchain. That is, XSLT. I'm not doing a huge amount of
customization on top of the default setup, either. Right now, I'm using the
standard XSLT Java toolchain; Xalan, Xerces, XIncluder, and all of the
various other Apache projects[3]. The problem is, well, it's Java, which
means the classpaths and build environment and such break if I so much as
sneeze at the wrong time. I'd love to be able to replace it with PHP's XSL
parser[4], since I actually know PHP and its chances of breaking on every
other Tuesday are slimmer, but I don't know if it has all of the
functionality I'd need.
Specifically, I need multi-file output and support for <xinclude: />
directives. Right now I'm using the Xalan multi-file output extensions, but
I'm happy to switch to something else if it means eliminating the huge gobs
of touchy Javascript I have.
Does anyone know if that's doable with PHP's XSLT support (circa PHP 5.2, I
run the server so can install whatever I need)? Has anyone tried doing this
before? It's all offline processing, so performance isn't a huge issue.
Thanks.
[1] http://www.docbook.org/tdg/en/html/docbook.html
[2] http://www.sagehill.net/docbookxsl/
[3] http://xml.apache.org/
[4] http://us.php.net/manual/en/ref.xsl.php
--
Larry Garfield AIM: LOLG42
[EMAIL PROTECTED] ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
--- End Message ---
--- Begin Message ---
Hi,
I can make the files now after setting the permission to my images folder
but I cannot delete the folder or images in it. I have tried unlink and
rmdir with no success. Even with filezilla cannot delete it
The problem seems to be the images that are set to chmod of 600 and cannot
be changed. I upload the file with this
move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $img_url)
is there a way to set the permissions of the images on upload to anything
other than 600?
R.
From: "Chris" <[EMAIL PROTECTED]>
To: "blueboy" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, June 07, 2007 12:08 AM
Subject: Re: [PHP] cannot make directory at remote host
blueboy wrote:
This work localy but not on my remote host. How can I debug it?
if(!(is_dir('images/$customer_id')))
{
mkdir("images/$customer_id", 0700);
}
The file is in the main public_html folder and there is a images folder.
First tip - always use full paths instead of local ones so you know
*exactly* where it's going.
If it goes under the current folder (and I hope you have some basic
checking here somewhere for customer_id):
$customer_id = (int)$customer_id;
if ($customer_id <= 0) {
die("Bad customerid!");
}
$dir = dirname(__FILE__) . '/images/' . $customer_id;
if (!is_dir($dir)) {
mkdir($dir, 0700);
}
What should the permissions be?
Depends on the host (whether they are running php in cgi mode or as an
apache module).
Check if safe-mode is on or off.
Check the parent folder to make sure that the webserver user has write &
execute access to be able to get into the base folder.
display errors and turn error reporting up to work out why it's not
working.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Hi,
I can make the files now after setting the permission to my images folder
but I cannot delete the folder or images in it. I have tried unlink and
rmdir with no success. Even with filezilla cannot delete it
The problem seems to be the images that are set to chmod of 600 and cannot
be changed. I upload the file with this
move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $img_url)
is there a way to set the permissions of the images on upload to anything
other than 600?
R.
--- End Message ---
--- Begin Message ---
use the function chmod
chmod($img_url, 0777); //note the leading 0, it should be there
I hope this is what you want:
--
itoctopus - http://www.itoctopus.com
""Ross"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> I can make the files now after setting the permission to my images folder
> but I cannot delete the folder or images in it. I have tried unlink and
> rmdir with no success. Even with filezilla cannot delete it
>
>
> The problem seems to be the images that are set to chmod of 600 and cannot
> be changed. I upload the file with this
>
> move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $img_url)
>
> is there a way to set the permissions of the images on upload to anything
> other than 600?
>
> R.
--- End Message ---