php-general Digest 21 Sep 2009 22:15:31 -0000 Issue 6351

Topics (messages 298222 through 298247):

Re: Best Practice to Create Dynamic URL's- With Username
        298222 by: Tommy Pham
        298223 by: Tommy Pham
        298224 by: Ashley Sheridan

Re: Random Flash Movies
        298225 by: Gary

Touch screen programming help
        298226 by: Manish - dz - PHP
        298227 by: Tommy Pham
        298228 by: Andrea Giammarchi
        298229 by: Bob McConnell
        298230 by: Robert Cummings
        298231 by: Bastien Koert
        298232 by: Tommy Pham
        298233 by: Ralph Deffke

Usage of strlen(tuf8_decode()) and "/u" regex modifier
        298234 by: GoForThisWorld
        298235 by: Andrea Giammarchi

Extract links from strings
        298236 by: Jônatas Zechim
        298237 by: Paul M Foster
        298238 by: tedd
        298239 by: Mattias Thorslund
        298240 by: Ashley Sheridan
        298246 by: Jônatas Zechim

wrong time stamp in log filewrong time stamp in log file
        298241 by: Struzik Wojciech
        298242 by: Andrea Giammarchi
        298247 by: Tommy Pham

webpage link validation
        298243 by: Al
        298244 by: Ashley Sheridan
        298245 by: Andrea Giammarchi

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 ---
----- Original Message ----
> From: Ralph Deffke <[email protected]>
> To: [email protected]
> Sent: Monday, September 21, 2009 1:31:05 AM
> Subject: [PHP] Re: Best Practice to Create Dynamic URL's- With Username
> 
> be aware if you do not have full control of your server setup, this type of
> parameter handling is not possible on most shared hostings.
> 
> however url encoded it is never a problem. so be clear where yout page will
> be hosted.
> 
> [email protected]
> 

If your hosting service company doesn't permit/use URL rewrite (mod_rewrite for 
Apache), then ask them to specify a 404 error page for you.  You can then do an 
ugly hack of URL rewrite in your (PHP)  404 error page so the URL will be SEF ;)

Regards,
Tommy

> "Gaurav Kumar" wrote in message
> news:[email protected]...
> > Hi All,
> >
> > I am creating a social networking website. I want that every user should
> > have there own profile page with a static URL like-
> >
> > http://www.abcnetwork/user/username
> >
> > Where username will be dynamic userid or something else.
> >
> > This is something very similar to www.youtube.com/user/kumargauravmail
> (this
> > is my profile page).
> >
> > So what should be the best practice to create such DYNAMIC URL's OR what
> > kind of methodology youtube is following?
> >
> > Thanks in Advance.
> >
> > Gaurav Kumar
> > OSWebstudio.com
> >
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
----- Original Message ----
> From: Ashley Sheridan <[email protected]>
> To: Gaurav Kumar <[email protected]>
> Cc: Andrea Giammarchi <[email protected]>; [email protected]
> Sent: Monday, September 21, 2009 2:55:20 AM
> Subject: Re: [PHP] Best Practice to Create Dynamic URL's- With Username
> 
> On Mon, 2009-09-21 at 15:20 +0530, Gaurav Kumar wrote:
> > I totally agree with this architecture. 
> > 
> > You are correct, I am just in the starting phase of the project and in
> > fact still need to define the architecture in detail.
> > 
> > Now the question I asked in my last reply is still to be answered?
> > 
> > Gaurav Kumar
> > OSWebstudio.Com
> > 
> > On Mon, Sep 21, 2009 at 3:06 PM, Andrea Giammarchi
> > wrote:
> >        
> >        
> >         > 
> >         > Question I was Asked by Andrea- "mod_reqrite or .htaccess is
> >         the answer, but
> >         > I wonder why you choose /user/username rather than
> >         just /username a la
> >         > twitter."
> >         > 
> >         > I will be using many other aspects of my users something
> >         like
> >         > "/projects/username/"; "/gallery/username/".
> >        
> >        
> >         well, it does not matter if this service is user based.
> >        
> >         /username/ #as user home page
> >         /username/projects/ #as user projects
> >         /username/gallery/ #as user gallery
> >         /username/etc ...
> >        
> >         it's just a silly point but from user home page you isntantly
> >         know if user exists and you instantly know subsections
> >        
> >         In your way you assume that there is a gallery for that user
> >         while he could have created only projects, without galleries.
> >         So one search failed, while to go in the user page I need to
> >         digit /user/ before, not a big deal but we are in tinyurl and
> >        bit.ly era
> >        
> >         Google Code put simply a /p/ as prefix plus the project name
> >         plus subsection
> >        
> >         /p/myprojname/
> >         /p/myprojname/wiki
> >        
> >         since you are starting now, maybe you could consider this
> >         semantic alternative, if it suits your requirements.
> >        
> >         Regards
> >        
> >         > > Thanks,
> >         > > Ash
> >         > > http://www.ashleysheridan.co.uk
> >         > >
> >         > >
> >         > >
> >         > >
> >        
> >        
> >        
> >         ______________________________________________________________
> >         check out the rest of the Windows Live™. More than mail–
> >         Windows Live™ goes way beyond your inbox. More than messages
> > 
> For help with the mod_rewrite, a Google search never goes amiss, first
> result I found for 'mod_rewrite example' is
> http://www.workingwith.me.uk/articles/scripting/mod_rewrite . I looked
> at it quickly and it does cover what you need.
> 
> As for what you get as $_GET parameters, that's entirely up to you, and
> as you will see from the above link, it's fairly simple to mess about
> with.
> 
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 

Ash,

What's the IP that the link you gave resolve to?  I'm getting timed out for the 
DNS lookup on my end ... 

Thanks,
Tommy

> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
On Mon, 2009-09-21 at 03:42 -0700, Tommy Pham wrote:
> ----- Original Message ----
> > From: Ashley Sheridan <[email protected]>
> > To: Gaurav Kumar <[email protected]>
> > Cc: Andrea Giammarchi <[email protected]>; [email protected]
> > Sent: Monday, September 21, 2009 2:55:20 AM
> > Subject: Re: [PHP] Best Practice to Create Dynamic URL's- With Username
> > 
> > On Mon, 2009-09-21 at 15:20 +0530, Gaurav Kumar wrote:
> > > I totally agree with this architecture. 
> > > 
> > > You are correct, I am just in the starting phase of the project and in
> > > fact still need to define the architecture in detail.
> > > 
> > > Now the question I asked in my last reply is still to be answered?
> > > 
> > > Gaurav Kumar
> > > OSWebstudio.Com
> > > 
> > > On Mon, Sep 21, 2009 at 3:06 PM, Andrea Giammarchi
> > > wrote:
> > >        
> > >        
> > >         > 
> > >         > Question I was Asked by Andrea- "mod_reqrite or .htaccess is
> > >         the answer, but
> > >         > I wonder why you choose /user/username rather than
> > >         just /username a la
> > >         > twitter."
> > >         > 
> > >         > I will be using many other aspects of my users something
> > >         like
> > >         > "/projects/username/"; "/gallery/username/".
> > >        
> > >        
> > >         well, it does not matter if this service is user based.
> > >        
> > >         /username/ #as user home page
> > >         /username/projects/ #as user projects
> > >         /username/gallery/ #as user gallery
> > >         /username/etc ...
> > >        
> > >         it's just a silly point but from user home page you isntantly
> > >         know if user exists and you instantly know subsections
> > >        
> > >         In your way you assume that there is a gallery for that user
> > >         while he could have created only projects, without galleries.
> > >         So one search failed, while to go in the user page I need to
> > >         digit /user/ before, not a big deal but we are in tinyurl and
> > >        bit.ly era
> > >        
> > >         Google Code put simply a /p/ as prefix plus the project name
> > >         plus subsection
> > >        
> > >         /p/myprojname/
> > >         /p/myprojname/wiki
> > >        
> > >         since you are starting now, maybe you could consider this
> > >         semantic alternative, if it suits your requirements.
> > >        
> > >         Regards
> > >        
> > >         > > Thanks,
> > >         > > Ash
> > >         > > http://www.ashleysheridan.co.uk
> > >         > >
> > >         > >
> > >         > >
> > >         > >
> > >        
> > >        
> > >        
> > >         ______________________________________________________________
> > >         check out the rest of the Windows Live™. More than mail–
> > >         Windows Live™ goes way beyond your inbox. More than messages
> > > 
> > For help with the mod_rewrite, a Google search never goes amiss, first
> > result I found for 'mod_rewrite example' is
> > http://www.workingwith.me.uk/articles/scripting/mod_rewrite . I looked
> > at it quickly and it does cover what you need.
> > 
> > As for what you get as $_GET parameters, that's entirely up to you, and
> > as you will see from the above link, it's fairly simple to mess about
> > with.
> > 
> > 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> > 
> > 
> 
> Ash,
> 
> What's the IP that the link you gave resolve to?  I'm getting timed out for 
> the DNS lookup on my end ... 
> 
> Thanks,
> Tommy
> 
> > 
> > 
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

I get 80.82.121.153 for it. You might have an issue with your DNS
server. There are a lot of freely available alternative DNS servers
about the world that you can use instead. I had to do that myself one
time, when the DNS server issued by my ISP was misbehaving and I was
getting lots of timeouts just like you are getting.

Thanks,
Ash
http://www.ashleysheridan.co.uk




--- End Message ---
--- Begin Message ---
As always, thanks for your help.

Gary


""Gary"" <[email protected]> wrote in message 
news:[email protected]...
>A question was posted on another board that the poster wanted random flash 
>movies to display as the page is reloaded.  I posted the script below and 
>said I thought it could be adapted but that the echo would probably need to 
>change. Can someone offer some guidance on this?  Thanks
>
> Gary
>
> <?
> //Chooses a random number
> $num = Rand (1,6);
> //Based on the random number, gives a quote
> switch ($num)
> {
> case 1:
> echo "";
> break;
> case 2:
> echo "";
> break;
> case 3:
> echo "";
> break;
> case 4:
> echo "";
> break;
> case 5:
> echo "";
> break;
> case 6:
> echo "";
> }
> ?>
>
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 4441 (20090919) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
>
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 4442 (20090921) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
> 



__________ Information from ESET Smart Security, version of virus signature 
database 4442 (20090921) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--- End Message ---
--- Begin Message ---
Hi 
    Is it possible to do touch screen programming  in PHP ? If it is then, how ?
   Please specify th specs with code.

Thanks in advance,

Regards,
Manish

  

--- End Message ---
--- Begin Message ---
---- Original Message ----
> From: Manish - dz - PHP <[email protected]>
> To: [email protected]
> Sent: Monday, September 21, 2009 5:32:59 AM
> Subject: [PHP] Touch screen programming help
> 
> Hi 
>     Is it possible to do touch screen programming  in PHP ? If it is then, 
> how ?
>    Please specify th specs with code.
> 
> Thanks in advance,
> 
> Regards,
> Manish

Did you research on 'touch screen'?  How it works? The hardware & software 
involved?

Regards,
Tommy


--- End Message ---
--- Begin Message ---
Unless PHP Gtk has a module able to create an interface able to capture 
coordinates in a touchscreen device ... PHP is a web server programming 
language and it usually works in the server specially suited for web based 
applications.

Regards

> From: [email protected]
> To: [email protected]
> Date: Mon, 21 Sep 2009 18:02:59 +0530
> Subject: [PHP] Touch screen programming help
> 
> Hi 
>     Is it possible to do touch screen programming  in PHP ? If it is then, 
> how ?
>    Please specify th specs with code.
> 
> Thanks in advance,
> 
> Regards,
> Manish
> 
>   

_________________________________________________________________
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

--- End Message ---
--- Begin Message ---
From: Manish
> 
>     Is it possible to do touch screen programming  in
> PHP ? If it is then, how ?
>   Please specify th specs with code.

If the touch screen is attached to the server, yes. But you probably
need to specify which touch screen and drivers you are using.

If it is attached to the browser, no. All PHP does is generate HTML to
send to the browser. It is up to whomever manages that machine to
install the drivers for the touch screen and integrate it into the OS.

You need to be more specific about what you are trying to do.

Bob McConnell

--- End Message ---
--- Begin Message ---


Tommy Pham wrote:
---- Original Message ----
From: Manish - dz - PHP <[email protected]>
To: [email protected]
Sent: Monday, September 21, 2009 5:32:59 AM
Subject: [PHP] Touch screen programming help

Hi Is it possible to do touch screen programming in PHP ? If it is then, how ?
   Please specify th specs with code.

Thanks in advance,

Regards,
Manish

Did you research on 'touch screen'?  How it works? The hardware & software 
involved?

You forgot to include "specs" and "code" in your response.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---
--- Begin Message ---
On Mon, Sep 21, 2009 at 9:29 AM, Robert Cummings <[email protected]> wrote:
>
>
> Tommy Pham wrote:
>>
>> ---- Original Message ----
>>>
>>> From: Manish - dz - PHP <[email protected]>
>>> To: [email protected]
>>> Sent: Monday, September 21, 2009 5:32:59 AM
>>> Subject: [PHP] Touch screen programming help
>>>
>>> Hi    Is it possible to do touch screen programming  in PHP ? If it is
>>> then, how ?
>>>   Please specify th specs with code.
>>>
>>> Thanks in advance,
>>>
>>> Regards,
>>> Manish
>>
>> Did you research on 'touch screen'?  How it works? The hardware & software
>> involved?
>
> You forgot to include "specs" and "code" in your response.
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

php|arch magazine had an article about this some years back, search
their archives. Its more than possible, but you will likely need to
install apache/php/mysql on the machine that run the device (assuming
its a kiosk type machine)

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
----- Original Message ----
> From: Robert Cummings <[email protected]>
> To: Tommy Pham <[email protected]>
> Cc: Manish - dz - PHP <[email protected]>; [email protected]
> Sent: Monday, September 21, 2009 6:29:01 AM
> Subject: Re: [PHP] Touch screen programming help
> 
> 
> 
> Tommy Pham wrote:
> > ---- Original Message ----
> >> From: Manish - dz - PHP 
> >> To: [email protected]
> >> Sent: Monday, September 21, 2009 5:32:59 AM
> >> Subject: [PHP] Touch screen programming help
> >> 
> >> Hi     Is it possible to do touch screen programming  in PHP ? If it is 
> >> then, 
> how ?
> >>    Please specify th specs with code.
> >> 
> >> Thanks in advance,
> >> 
> >> Regards,
> >> Manish
> > 
> > Did you research on 'touch screen'?  How it works? The hardware & software 
> involved?
> 
> You forgot to include "specs" and "code" in your response.
> 
> Cheers,
> Rob.
> -- http://www.interjinn.com
> Application and Templating Framework for PHP
> 
> -- PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

You know that's what happens when the brain process too fast for the fingers to 
keep up :D


--- End Message ---
--- Begin Message ---
well, I would say a touch screen usualy is just another 'pointing device'
like the mouse is. it depends on the operating system and the driver setup
for it. then u simply can use any browser and just adjust the pointing
receiving elements like buttons and links a bit bigger and with images
rather then with just text. However this is not realy a PHP related issue.
more like a designers issue.

I think its realy simple

[email protected]

""Manish - dz - PHP"" <[email protected]> wrote in message
news:013c01ca3ab7$a9524dd0$5e01a...@manish...
Hi
    Is it possible to do touch screen programming  in PHP ? If it is then,
how ?
   Please specify th specs with code.

Thanks in advance,

Regards,
Manish




--- End Message ---
--- Begin Message ---
Hello,

  As indicated below, the "strlen(tuf8_decode())" and the "/u" regex
  modifier do not work as per my understanding.  

  1) What is my misunderstanding?  

      <?php
      
          $the_string = '&#1052;&#1072;&#1088;&#1080;&#1085;&#1072; 
&#1054;&#1088;&#1083;&#1086;&#1074;&#1072;';
          echo "<p>author (85 bytes):$the_string," . strlen($the_string) . ',' 
. strlen( utf8_decode( $the_string ) ) . ',' .
strlen( utf8_decode( utf8_encode($the_string) ) ) . ',' .  "</p>";
          // all the number echoed are 85, I expected at least one to be 13

          
          $max_length = 20;
          $is_short = preg_match( '/^.{1,$max_length}$/u', uft8_encode( 
$the_string ) ) );
          // expect the above to return 1
          
          $max_length = 10;
          $is_short = preg_match( '/^.{1,$max_length}$/u', uft8_encode( 
$the_string ) ) );
          // expect the above to return 0
      
      ?>

  More generally, given a string $the_string:

  2) how to determine what encoding is being used?

  3) how to determine the number of visible characters?

  4) if it has more than N visible characters, how to 
     truncate it after N visible characters?

  Thanks!


--- End Message ---
--- Begin Message ---



>           $the_string = '&#1052;&#1072;&#1088;&#1080;&#1085;&#1072; 
> &#1054;&#1088;&#1083;&#1086;&#1074;&#1072;';

did you actually wrote this or i tis the PHP ml that converted utf-8 chars?
I can read only an ASCII string with length 85 ... please tell me you are not 
confusing HTML entities with UTF-8 encoded characters ...

_________________________________________________________________
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/

--- End Message ---
--- Begin Message ---
Hi there, i've the following strings:

$string1 = 'Lorem ipsum dolor http://site.com sit amet';
$string2 = 'Lorem ipsum dolor http://www.site.com/ sit amet';
$string3 = 'Lorem ipsum dolor http://www.site.net sit amet';

How can I extract the URL from these strings?
They can be [http:// + url] or [www. + url].

Zechim


--- End Message ---
--- Begin Message ---
On Mon, Sep 21, 2009 at 12:52:12PM -0300, Jônatas Zechim wrote:

> Hi there, i've the following strings:
> 
> $string1 = 'Lorem ipsum dolor http://site.com sit amet';
> $string2 = 'Lorem ipsum dolor http://www.site.com/ sit amet';
> $string3 = 'Lorem ipsum dolor http://www.site.net sit amet';
> 
> How can I extract the URL from these strings?
> They can be [http:// + url] or [www. + url].
> 

Use the preg_match() function (see
http://us2.php.net/manual/en/function.preg-match.php ) and a good
regular expression from a place like http://www.regexlib.com/ .

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
At 12:52 PM -0300 9/21/09, Jônatas Zechim wrote:
Hi there, i've the following strings:

$string1 = 'Lorem ipsum dolor http://site.com sit amet';
$string2 = 'Lorem ipsum dolor http://www.site.com/ sit amet';
$string3 = 'Lorem ipsum dolor http://www.site.net sit amet';

How can I extract the URL from these strings?
They can be [http:// + url] or [www. + url].

Zechim


Not tested:

<?php

$textString = 'orem ipsum dolor sit amet, consectetuer adipiscing
elit. Proin et urna. Duis quam. Suspendisse potenti. Etiam sem tortor,
ultricies nec,  http://example.com  imperdiet nec, tempus ac, purus.
Suspendisse id lectus. Nam vitae quam. Aliquam ligula nisl, vestibulum
vulputate, tempor nec, https://www.example.com  tincidunt sit amet,
libero. Suspendisse a justo. Cum sociis natoque penatibus et.';

$url_regexp = '<(?:(?:https?)://(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::(?:(?:[0-9]*)))?(?:/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9\\-_.!~*\'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\\-_.!~*\'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\\-_.!~*\'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\\-_.!~*\'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?](?:(?:(?:[;/?:@&=+$,a-zA-Z0-9\\-_.!~*\'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)>';

$output = preg_replace($url_regexp, '<a href="$0">$0</a>', $textString);

print $output;
?>

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Jônatas Zechim wrote:
Hi there, i've the following strings:

$string1 = 'Lorem ipsum dolor http://site.com sit amet';
$string2 = 'Lorem ipsum dolor http://www.site.com/ sit amet';
$string3 = 'Lorem ipsum dolor http://www.site.net sit amet';

How can I extract the URL from these strings?
They can be [http:// + url] or [www. + url].

Zechim

Simple:

function RemoveLorem($string)
{
return str_replace(array('Lorem ipsum dolor ', ' sit amet'), '', $string);
}

$url1 = RemoveLorem($string1);
$url2 = RemoveLorem($string2);
$url3 = RemoveLorem($string3);

Cheers :-)

Mattias

--- End Message ---
--- Begin Message ---
On Mon, 2009-09-21 at 11:06 -0700, Mattias Thorslund wrote:
> Jônatas Zechim wrote:
> > Hi there, i've the following strings:
> >
> > $string1 = 'Lorem ipsum dolor http://site.com sit amet';
> > $string2 = 'Lorem ipsum dolor http://www.site.com/ sit amet';
> > $string3 = 'Lorem ipsum dolor http://www.site.net sit amet';
> >
> > How can I extract the URL from these strings?
> > They can be [http:// + url] or [www. + url].
> >
> > Zechim
> 
> Simple:
> 
> function RemoveLorem($string)
> {
>     return str_replace(array('Lorem ipsum dolor ', ' sit amet'), '', 
> $string);
> }
> 
> $url1 = RemoveLorem($string1);
> $url2 = RemoveLorem($string2);
> $url3 = RemoveLorem($string3);
> 
> Cheers :-)
> 
> Mattias
> 
Erm, I think the Lorem Ipsum was just filler text in this example, and
may not actually occur in the final content ;)


Thanks,
Ash
http://www.ashleysheridan.co.uk




--- End Message ---
--- Begin Message ---
I don't think so, but I've found this (from PT-BR LIST):

$string = 'Lorem ipsum dolor http://site.com sit amet lorem www.google.com
';

preg_match_all('!(?:http://|www)[^ ]*!',$string,$links);

print_r($links);

Zechim

-----Mensagem original-----
De: Mattias Thorslund [mailto:[email protected]] 
Enviada em: segunda-feira, 21 de setembro de 2009 15:07
Para: 'PHP-General List'
Assunto: Re: [PHP] Extract links from strings

Jônatas Zechim wrote:
> Hi there, i've the following strings:
>
> $string1 = 'Lorem ipsum dolor http://site.com sit amet';
> $string2 = 'Lorem ipsum dolor http://www.site.com/ sit amet';
> $string3 = 'Lorem ipsum dolor http://www.site.net sit amet';
>
> How can I extract the URL from these strings?
> They can be [http:// + url] or [www. + url].
>
> Zechim

Simple:

function RemoveLorem($string)
{
    return str_replace(array('Lorem ipsum dolor ', ' sit amet'), '', 
$string);
}

$url1 = RemoveLorem($string1);
$url2 = RemoveLorem($string2);
$url3 = RemoveLorem($string3);

Cheers :-)

Mattias

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
I have updated a php to version 5.2.11. the timestamp in php log is
incorrect. the time differs from local time with 2 hours. In changelog
I can find the following information:
Updated timezone database to version 2009.13 (2009m) (Derick)
Is it related with my problem ???

When I run the following script:
<?php
print date('d M Y, H:i');
?>
It's returns a correct time.

I appreciate any help

--- End Message ---
--- Begin Message ---

> I have updated a php to version 5.2.11.
you should update the keyboard as well, it fires CTRL+V twice (subject, and I 
am joking ..)


> When I run the following script:
> <?php
> print date('d M Y, H:i');
> ?>
> It's returns a correct time.

correct accordingly with your local time zone, 'cause I am pretty much sure 
that if you do
<?php
print *gmdate*('d M Y, H:i');
?>
the time will be exactly the same reported in the log file.

You would have known this if you were developing with E_STRICT since date is a 
warning, even in the phpinfo, if you do not set it correctly.

It's a good idea in any case, for obvious portability reasons across websites, 
countries, and hosts, to use gmdate for time operations, otherwise if I use 
date I could have stuff from the future in another host, and stuff from past in 
another one.

Regards

_________________________________________________________________
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

--- End Message ---
--- Begin Message ---
----- Original Message ----
> From: Andrea Giammarchi <[email protected]>
> To: [email protected]; [email protected]
> Sent: Monday, September 21, 2009 11:41:01 AM
> Subject: RE: [PHP] wrong time stamp in log filewrong time stamp in log file
> 
> 
> 
> > I have updated a php to version 5.2.11.
> you should update the keyboard as well, it fires CTRL+V twice (subject, and I 
> am 
> joking ..)
> 
> 
> > When I run the following script:
> > > > print date('d M Y, H:i');
> > ?>
> > It's returns a correct time.
> 
> correct accordingly with your local time zone, 'cause I am pretty much sure 
> that 
> if you do
> > print *gmdate*('d M Y, H:i');
> ?>
> the time will be exactly the same reported in the log file.
> 
> You would have known this if you were developing with E_STRICT since date is 
> a 
> warning, even in the phpinfo, if you do not set it correctly.
> 
> It's a good idea in any case, for obvious portability reasons across 
> websites, 
> countries, and hosts, to use gmdate for time operations, otherwise if I use 
> date 
> I could have stuff from the future in another host, and stuff from past in 
> another one.
> 
> Regards
> 
> _________________________________________________________________
> Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.
> 
> http://www.microsoft.com/windows/windowslive/products/photos.aspx

Did you set 'Default timezone' in php.ini or use the function 
date_default_timezone_set() in your app?

--- End Message ---
--- Begin Message ---
What's the simplest way to test if a link is valid?

I've got a script that throughly checks the dns, etc. But, I'd also like to check to see if the user has inputted a valid link to a webpage.

File_exists() and etc. seem to have a lot of caveats.

E.g., foo.com/bar/file.txt

Most things I've looked at are gross overkill.

Al........

--- End Message ---
--- Begin Message ---
On Mon, 2009-09-21 at 14:42 -0400, Al wrote:
> What's the simplest way to test if a link is valid?
> 
> I've got a script that throughly checks the dns, etc. But, I'd also like to 
> check to see if the user has inputted a valid link to a webpage.
> 
> File_exists() and etc. seem to have a lot of caveats.
> 
> E.g., foo.com/bar/file.txt
> 
> Most things I've looked at are gross overkill.
> 
> Al........
> 

Several ways that I can think of:

      * use the file_get_contents() which like you said, could be
        overkill
      * shell out to wget to retrieve just the headers for the path.
        You'd be looking for a 200 return code, which indicates the URI
        exists.
      * lastly, you could use fopen() to open the file, and use the
        return from the fopen() call to indicate a success of failure

Thanks,
Ash
http://www.ashleysheridan.co.uk




--- End Message ---
--- Begin Message ---
 
> Several ways that I can think of:
> 
>       * use the file_get_contents() which like you said, could be
>         overkill
>       * shell out to wget to retrieve just the headers for the path.
>         You'd be looking for a 200 return code, which indicates the URI
>         exists.
>       * lastly, you could use fopen() to open the file, and use the
>         return from the fopen() call to indicate a success of failure
> 
> Thanks,
> Ash

you forgot probably the best one, an HEAD call via curl library ( 
http://uk3.php.net/curl ) if present

Regards

_________________________________________________________________
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

--- End Message ---

Reply via email to