php-general Digest 1 Mar 2008 13:42:30 -0000 Issue 5323

Topics (messages 270789 through 270801):

php and google
        270789 by: Nathan Rixham
        270790 by: Robert Cummings

PHP on Windows
        270791 by: Erik SJMN

Re: Making sure an include file works
        270792 by: Richard S. Crawford

Calculating dates
        270793 by: Ron Piggott
        270794 by: Jim Lucas
        270800 by: Ron Piggott
        270801 by: Brice

RewriteRule help
        270795 by: Shelley
        270799 by: Richard Heyes

Re: simple command help
        270796 by: Shelley

Re: Get country from Phone number
        270797 by: Satyam

Re: string effect
        270798 by: Richard Heyes

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 --- I think that I may be correct in saying that google blog search uses / is made in PHP [which I never realised]

try googling for site:blogsearch.google.com you should get back a page with an all revealing PHPSESSID

am I speculating?

--- End Message ---
--- Begin Message ---
On Sat, 2008-03-01 at 01:50 +0000, Nathan Rixham wrote:
> I think that I may be correct in saying that google blog search uses / 
> is made in PHP [which I never realised]
> 
> try googling for site:blogsearch.google.com you should get back a page 
> with an all revealing PHPSESSID
> 
> am I speculating?

You are speculating that the search is done by a PHP script when all
that can really be ascertained is that the results are presented by a
PHP script. It's akin to presenting results in a PHP page retrieved via
Lucene or htdig.

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 ---
I'm completely new to php and I'm trying to setup an online trouble ticket
system.  After the user logs in and submits the ticket, they're supposed to
receive an email confirmation with the ticket number.  I have my Exchange
server setup on another server in the same domain that I'm trying to use to
send these emails - this server requires SMTP authentication.  So I've
installed the PEAR Mail package, as it was my understanding that this would
allow me to do the authentication for the SMTP server - I installed it in
the C:\PHP5\PEAR directory.  Do I need this mail package for the
authentication?  In any case, where do I setup the authentication variables
to send this email?  I tried adding the authentication vars to the
smtp.phpfile in the  C:\PHP5\PEAR\Mail directory, but still not
authenticating.  I'm
completely lost, any help is greatly appreciated.

; PHP 5.2.5 installed on Windows Server 2003 with IIS 6
; Mail-1.1.14 mail pkg with Net_SMTP-1.2.11 pkg

--Erik

--- End Message ---
--- Begin Message ---
On Friday 29 February 2008 11:58:16 Daniel Brown wrote:
>     Get a new host that knows how to administer a web server.  PHP 4.3
> was released 27 December, 2002, with the latest from the 4.3 branch
> (4.3.11) being released 31 March, 2005.  The CHANGELOG should give you
> an idea of how *horrible* this is: http://www.php.net/ChangeLog-4.php

Ah, if only I could.  The choice of host was made by my boss, and he loves 
them.

-- 
Slainte,
Richard S. Crawford
Editor-in-chief, Daikaijuzine (http://www.daikaijuzine.com)
Personal website: http://www.mossroot.com

--- End Message ---
--- Begin Message ---
Is there an easy way to calculate the number of days between two dates?

Example: 2008-02-27 - 2007-12-03 = 86 days

The dates will be in the format above YYYY-MM-DD

Ron

--- End Message ---
--- Begin Message ---
Ron Piggott wrote:
Is there an easy way to calculate the number of days between two dates?

Example: 2008-02-27 - 2007-12-03 = 86 days

The dates will be in the format above YYYY-MM-DD

Ron


This should do the trick

<?php

$date1 = '2008-02-27';
$date2 = '2007-12-03';

$udate1 = strtotime($date1);
$udate2 = strtotime($date2);

$factor = 86400;


$difference = (($udate1 - $udate2) / $factor);

echo "The difference is {$difference} days";


Jim

--- End Message ---
--- Begin Message ---
Thanks.  That's a nifty way of doing this.  Ron

On Fri, 2008-02-29 at 22:08 -0800, Jim Lucas wrote:
> Ron Piggott wrote:
> > Is there an easy way to calculate the number of days between two dates?
> > 
> > Example: 2008-02-27 - 2007-12-03 = 86 days
> > 
> > The dates will be in the format above YYYY-MM-DD
> > 
> > Ron
> > 
> 
> This should do the trick
> 
> <?php
> 
> $date1 = '2008-02-27';
> $date2 = '2007-12-03';
> 
> $udate1 = strtotime($date1);
> $udate2 = strtotime($date2);
> 
> $factor = 86400;
> 
> 
> $difference = (($udate1 - $udate2) / $factor);
> 
> echo "The difference is {$difference} days";
> 
> 
> Jim

--- End Message ---
--- Begin Message ---
I like this way too but it will not work with a date before the first
January 1901.

Do you have another method?

Brice Favre



On Sat, Mar 1, 2008 at 7:08 AM, Jim Lucas <[EMAIL PROTECTED]> wrote:
> Ron Piggott wrote:
>  > Is there an easy way to calculate the number of days between two dates?
>  >
>  > Example: 2008-02-27 - 2007-12-03 = 86 days
>  >
>  > The dates will be in the format above YYYY-MM-DD
>  >
>  > Ron
>  >
>
>  This should do the trick
>
>  <?php
>
>  $date1 = '2008-02-27';
>  $date2 = '2007-12-03';
>
>  $udate1 = strtotime($date1);
>  $udate2 = strtotime($date2);
>
>  $factor = 86400;
>
>
>  $difference = (($udate1 - $udate2) / $factor);
>
>  echo "The difference is {$difference} days";
>
>
>  Jim
>


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

--- End Message ---
--- Begin Message ---
Hi all,

Anybody knows what apache RewriteRule to use if  I want url:
http://www.aaa.comm/user/aaaa/
be rewritten as:
http://www.aaa.comm/user/index.php/aaaa/

It is not a php question. But now Im not in apache list and it's a little hurry.

Any help, thank you very much.

--
Cheers,
Shelley

--- End Message ---
--- Begin Message ---
Anybody knows what apache RewriteRule to use if  I want url:
http://www.aaa.comm/user/aaaa/
be rewritten as:
http://www.aaa.comm/user/index.php/aaaa/

It is not a php question. But now Im not in apache list and it's a little hurry.

If possible you could:

1. Make "user" a php script
2. Use the <Files> Apache directive to make it be parsed as a PHP script
   (http://www.phpguru.org/article.php/212)
3. Then in the "user" file you can use the $_SERVER['REQUEST_URI']
   to ascertain the correct content to show.

--
Richard Heyes (wondering if he's getting a bit of a reputation...)
Employ me:
http://www.phpguru.org/cv

--- End Message ---
--- Begin Message ---
Daniel Brown wrote:
On Fri, Feb 29, 2008 at 5:22 AM, Shelley <[EMAIL PROTECTED]> wrote:
Hi all,

 What's the command to use if I want to remove all the directories and
 files except 'a.gz' under a directory?

    There isn't a "command" in PHP to do this.  You'd have to write a
script to handle that processing.

    If you're looking for general Unix/Linux commands, you're in the
wrong place, but here's one possible way to do it:

sudo chattr +i /path/to/a.gz
rm -fR /path
sudo chattr -i /path/to/a.gz

    If you have sudo access (or straight root access, in which case
you can su - to root and skip the 'sudo' part of the command), that
will set the file attribute to immutable, which means no one -
including root or the system itself - can modify or delete that file
unless they have the CAP_LINUX_IMMUTABLE capability (such as root) and
issue the 'chattr -i filename' command.

That's what I wanted. Thanks.
I have full priviledge of the directory.

--
Cheers,
Shelley

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

----- Original Message ----- From: "Jim Lucas" <[EMAIL PROTECTED]>
To: "Dani Castaños" <[EMAIL PROTECTED]>
Cc: "PHP LIST" <[EMAIL PROTECTED]>
Sent: Saturday, March 01, 2008 2:36 AM
Subject: Re: [PHP] Get country from Phone number


Dani Castaños wrote:
Hi all!

I'm looking for some piece of code or class which giving a phone number it returns me from wich country is this phone.
Do you know where I can find something like this?

Thank you in advanced!


As a little project, I took the link provided by "the other" Rob and make this little search tool.

It only looks at the beginning numbers. It does no number validation. I don't validate the length of the number. ie: I would have to know the min/max lenth of each phone number for that given country/region, and I didn't search for that information.

You can't check for length, that depends on each national administration and while some countries have all phone numbers exactly the same length, some other countries do it the old style: small phone exchanges have few digits, larger have more, which gets compensated by the smaller exchanges having longer area codes.

The idea is that within small towns, you dial short numbers to reach your neighbour and, if someone dials from outside the area, they have to dial a longer area code prefix, but since the town is small, there is a lesser chance that many people will have any business dialing them anyway so, overall, you get to dial less. Also, in electromechanical phone exchanges, each extra digit (actually couple of digits) requires an extra row of 'selectors', which are (were) expensive.

This still happens at the country level, not because it really matters nowadays but due to the existing technology when it was agreed on it. Large countries in Latin America have two digit country codes (political maneuvering at the time of assignment distorted this somewhat, letting Peru and Cuba get 2 digits which don't fit their actual number of phone lines). Thus, from 51 to 58 they are assigned to the larger countries. The 59x and 50x ranges (in phone numbering the zero is after the nine within the same decade) go to countries with less phone lines.

Satyam



Let me know what you'll think.

http://www.cmsws.com/examples/php/areacodes/countrycodes.php

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

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



--
No virus found in this incoming message.
Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.21.2/1305 - Release Date: 29/02/2008 18:32



--- End Message ---
--- Begin Message ---
Mr. Heyes more or less prompted me to go dig for my other, slightly
heavier version, that doesn't chop words up:

Sorry I hit Reply instead Reply All. Regardless, here's my str_curtail. There is a bug in it that means if the string is all one word then it gets curtailed to nada, but that's easily fixed.

    /**
    * Shortens the given string to the specified number of characters,
    * however will never shorten mid-word (going backwards to find white
    * space). Appends
    * "..." (unless third arg is given).
    *
    * @param  string $str    Input to shorten
    * @param  int    $length Length to shorten to (defaults to 35)
    * @param  string $append String to append (defaults to "...")
    * @return string         Resulting shortened string
    */
    function str_curtail($str, $length = 35, $append = '...')
    {
        // String short enough already ?
        if (strlen($str) <= $length) {
            return $str;
        }

        $str = substr($str, 0, $length);

        // No body intentionally
        for ($i=$length - 1; !ctype_space($str{$i}) && $i > 0; --$i);

        return rtrim(substr($str, 0, $i)) . $append;
    }

--
Richard Heyes
Employ me:
http://www.phpguru.org/cv

--- End Message ---

Reply via email to