Re: [PHP] Feisty Fawn and apt-get

2007-05-05 Thread Travis Doherty
Skip Evans wrote:

 Hey all,

 I've installed Feisty Fawn on the curmudgeon barber's machine, but it
 won't get any of the outside packages I've tried to get. I've tried an

 apt-get install {package}

 ...on digikam, kate, gftp, and others. All stuff I had no trouble
 getting with Edgy.

 I checked the sources.list file and it has both universe and
 multiverse enabled.

 Is there something with the FF repositories or something I'm missing?

 Thanks,
 Skip

Wrong list?
T

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



Re: [PHP] Bounce composition

2007-05-02 Thread Travis Doherty
Richard Lynch wrote:

On Wed, May 2, 2007 2:57 pm, Oliver Block wrote:
  

Am Mittwoch, 2. Mai 2007 20:11 schrieb Richard Lynch:


Does anybody have or know of a good simple PHP script that can take
an
email as an input, and compose a Bounce email as output?

I need something that does just that, without a huge framework or a
zillion other features...
  

please try this:

$env['from'] = '[EMAIL PROTECTED]';
$env['to'] = '[EMAIL PROTECTED]';
$env['remail'] = imap_fetchheader($stream, $msgno);



I don't think that's what a bounce looks like, is it?...

I guess I was hoping somebody had worked out the minutiae of composing
a bounce message in PHP from the input headers.

I don't need help with the IMAP part of it, just the RFC bit about
making up a bounce message, without actually having to spend hours
poring over RFCs, which is not my idea of a Good Time... :-)

Or maybe I'm making a mountain out of a molehill, and that IS what a
bounced email looks like...

  

Hey Richard,

DJB's bounce format is pretty popular:
http://cr.yp.to/proto/qsbmf.txt

Best case would be to give a 400 for temp failure (plz try later) or a
500 for perm error right at the mail server.  Not sure if you can get
your logic in up the stream though before it gets to you.  If you can
you never have to deal with bounce messages and the entire queuing
process that goes along with it, mail server maintenance, etc..

Bounce to the enveloper sender, not the From header.  I also believe
bounces are supposed to have an envelope sender of  to avoid bounce
loops... not sure on that though.

Cheers
Travis Doherty

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



Re: [PHP] SQL Source Control

2007-04-11 Thread Travis Doherty
Richard Davey wrote:

 Hi all,

 I know a lot of you use various means for PHP source control (CVS,
 SVN, etc), which is all well and fine, but how do you manage source
 control on your databases?

 Say you've got an upgrade to a site, all of the new PHP files are
 controlled by SVN, so you can rollback at any time, but say the
 upgrade includes several key modifications to a MySQL table and
 perhaps the changing of some core data.

 How (if at all?!) do you handle the versioning of the database and
 data itself, so you can keep both PHP and SQL structure in sync?

 Cheers,

 Rich


One thing we do is add a table called 'versions' to each application,
this table just has one row and a column for the schema version (and
sometimes other stuff less important.)

When the app runs it checks to ensure that its defined constant
DBVERSION matches that of the database it is running against.  This has
actually helped out more than once, though not a solution to the actual
problem.

Travis Doherty

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



Re: [PHP] MD5 bot Question

2007-04-09 Thread Travis Doherty
Robert Cummings wrote:

On Mon, 2007-04-09 at 12:51 -0400, tedd wrote:
  

At 9:58 AM -0400 4/9/07, Robert Cummings wrote:



Hi Tedd,

Put down the crack pipe please... captcha images are usually generated
on the fly. Their image repository is 0. Their image universe is all of
the permutations of an image containing all of the range of serial codes
embedded in the images according to their morphing routine. I highly
doubt the US Government could afford the space required to store all of
the permutations. Considering the number of bytes available to a
dynamically generated image, it is highly likely that the images would
be capable of exhausting the entire md5 universe.

Cheers,
Rob.
  

Rob:

Duh -- put down the joint and stay on the subject. We were talking 
about M$'s picture captcha where they show pictures and ask a 
question like Pick the picture that shows a kitty and NOT an on 
the fly graphic captcha. There are different types of captchas.



Ah, I see. I was too lazy to go check since I don't use Microsoft except
insofar as to make things work in their crappy browser. Either way, can
you verify the images are static? See if getting two kitty cats produces
the same md5 signature :) Just because it's a picture doesn't invalidate
what I said.

Cheers,
Rob.
  

Steganography has been able to hide text in images for quite some time
now.  Basically you cram whatever info you want into the 'unused' or
'less used' bytes of the image.

With this in mind I imagine even if you did have an image repository of
only 8 images you could add some random bytes to the right spots in the
image without distorting it beyond recognition/corrupting it, and
therefore get a hybrid of static/on-the-fly images, that hashing
couldn't break so simply.

2 cents...

Travis Doherty

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



Re: [PHP] keeping credit card info in session

2007-04-08 Thread Travis Doherty
Jochem Maas wrote:

unless you are a payment gateway or a bank don't touch credit card numbers.
there are plenty of threads in the archive of this list that give good reasons
not to e.g. being sued out of existence.
  

100% agreed.  Never touch credit card numbers.  You can't just take
credit card numbers and manually process them in 'card not present'
transactions (or MOTO in more archaic terms.)  You need a merchant
account that allows for this -- usually at a higher discount rate. 
Check the merchant agreement.

Your client should get an account like this, or better yet, provide you
with the instructions on how to integrate his site with the payment
providers so that you never have to worry about credit cards.

As an additional note... Maybe your SSL cert secures the numbers from
the client to the server, and just maybe your PHP scripts have no
security flaws in them, but you must remember the server itself and
everything else outside of PHP.  What if someone found a flaw in the FTP
server for example, or the mail server even, and used that to get the CC
info.   I would hate to be explaining to a list of 1000 clients that I
was responsible for their card numbers being stolen.

Travis Doherty

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



Re: [PHP] PHP4 vs PHP5

2007-04-07 Thread Travis Doherty
Fernando Cosso wrote:

 Hi
 I know this topic has to be discussed several times but I have a
 situation I
 need some advices.

 I am working in a small company. The company does everything you need.
 Computer service, sell computers, install servers, web page, etc. I am in
 the web department. The guys from the server installation and that
 stuff are
 using a modified debian, which for default in his stable release has php4
 and apache 1.33.
 I am new at the company and I have to decide what I need and what I am
 going
 to do. My choice is to use the CMS Mambo and make the modification
 that each
 client would ask.
 So I've seen that php5 has a lot of cool staff, like mysqli and the
 new (and
 faster) object oriented thing. I would like to know if it is safe to
 use
 this version. I know that mambo use objects so I think that php5 will
 do a
 better job running it. I also think php5 (or php6) is the future we
 can use
 php4 for ever.
 So whats your opinion?
 Thanks

 A last comment: I apologize for my English, please let me know you didn't
 understand something

What about the argument that PHP4 is dead.  It's done.  It's over. 
There is no reason anyone should be using it, less perhaps a lack of
time to tweak scripts for an upgrade from 4 to 5.  Even if that is the
case, get to work :p

Support for PHP 4 will be dropped at the end of the year, 8 months from
now. So now is the time to start upgrading all your scripts as we won't
be releasing new versions after December 31st, 2007.

http://derickrethans.nl/php_quebec_conference_rip_php_4.php

Travis Doherty

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



Re: [PHP] PHP4 vs PHP5

2007-04-07 Thread Travis Doherty
Myron Turner wrote:

 Travis Doherty wrote:

 

 What about the argument that PHP4 is dead.  It's done.  It's over.
 There is no reason anyone should be using it, less perhaps a lack of
 time to tweak scripts for an upgrade from 4 to 5.  Even if that is the
 case, get to work :p

 Support for PHP 4 will be dropped at the end of the year, 8 months from
 now. So now is the time to start upgrading all your scripts as we won't
 be releasing new versions after December 31st, 2007.

 http://derickrethans.nl/php_quebec_conference_rip_php_4.php

 Travis Doherty

   

 This is fine, as long as the newer versions are backwardly
 compatible.  If , in particular, if the next version or version 6 does
 not support the PHP 4 object oriented model, it could present real
 problems for some software.  PHP isn't used only for scripts but for
 large projects.  For example, I just began to configure a DokuWicki
 installation, writing code for various features which are not included
 in the install.  DokuWicki uses the PHP 4 object oriented model
 throughout, and user plugins, such as mine, are written to the same
 model.  DokuWicki contains over 300 php files and more than 3 megs of
 code.  It would be no small task to convert such a project over to the
 PHP 5 OO model.

DokuWiki should run just fine under PHP5.  It may throw some E_STRICT
errors warning of things that will be deprecated in a later major PHP
release.  I doubt DokuWiki needs register_globals, and magic_quotes
shouldn't be a question.  Use the strict level warnings as hints to help
you find what needs to be modified in your own code.

Travis Doherty

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



Re: [PHP] Re: PHP4 vs PHP5

2007-04-07 Thread Travis Doherty
Robert Cummings wrote:

Or... there's some strong arming happening to force the move. PHP4
userbase greatly outnumbers the PHP5 userbase. I think the userbase
speaks louder than the support timeframe.

Cheers,
Rob.
  


Damien Seguy's latest stats showing the adoption rates of PHP5 show what
Rob said.

http://www.nexen.net/chiffres_cles/phpversion/16814-php_stats_evolution_for_march_2007.php

I'm sure many of the polled domains are shared hosts, who have users,
which exponentially complicates the task of migration.

Travis Doherty

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



Re: [PHP] Date/time format?

2007-03-28 Thread Travis Doherty
Jason Pruim wrote:

 Hi Everyone,

 First off, I'm using PHP 5.2.0 and apache 1.3.33

 I am trying to figure out what format a string is in in a database. 
 It's a timecard system that I have found on-line and I am attempting 
 to figure out how to write a script that would give me everyones 
 timecard for the month on one screen I can print out for accounting 
 to use. Below is an example of one of the lines in the database, What 
 I'm really interested in is how it represents the day.

 user   dayjob_name  
 minutes sequence

 root   1171774800   Production  technology Manager 
 990 3

Looks like epoch time.

Use date(Y-m-d,$epochtime); to get a standard date string out of it.

www.php.net/date/

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



Re: [PHP] Date/time format?

2007-03-28 Thread Travis Doherty
Zoltán Németh wrote:

2007. 03. 28, szerda keltezéssel 15.35-kor Jason Pruim ezt írta:
  

Hi Everyone,

First off, I'm using PHP 5.2.0 and apache 1.3.33

I am trying to figure out what format a string is in in a database.  
It's a timecard system that I have found on-line and I am attempting  
to figure out how to write a script that would give me everyones  
timecard for the month on one screen I can print out for accounting  
to use. Below is an example of one of the lines in the database, What  
I'm really interested in is how it represents the day.

user   dayjob_name   
minutes sequence

root   1171774800   Production  technology Manager  
990 3

I have not been able to find ANY info about that format, other then  
other people using it in blogs. I think I can figure out the rest as  
I go if I know how to decode the day. Any help or pointers to the M  
would be GREATLY appreciated! :)






what does strtotime return for that string?

  

It's already a time, strtotime should return FALSE.  It probably can't
parse that string to a time.

Travis D

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



Re: [PHP] PHP Upgrade: 5 or 6

2007-03-28 Thread Travis Doherty
Tijnema ! wrote:

 On 3/28/07, Davi [EMAIL PROTECTED] wrote:


 Hi all.

 I've reading on some sites [1,2] that PHP 6 is comming soon...

 What should I do?
 Migrate my server and apps to PHP 5 now and, later to PHP 6, or wait
 some more
 time and migrate all to PHP 6?

 TIA


 I think you should migrate to PHP5 now, as i think it will take some
 time before a real PHP6 release is coming. I don't know where you
 useit for. Is it development or productional? For development you
 could work with a CVS Snapshot, but that's not recommended for
 productional.
 But of course if you don't have any problems with the PHP you are
 currently using (I guess PHP 4.x), then it's not really needed to
 upgrade.

I agree and disagree - I agree with you should migrate to PHP5 *NOW*
(my emphasis added) and I disagree with then it's not really needed to
upgrade. (unless you don't care about security.)

Ilia Alshanetsky gave a great talk on this topic recently,
http://ilia.ws/talks/ scroll to the bottom to (PDF) Migrating to PHP
5.2.1. 

Travis Doherty

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



Re: [PHP] Performance: While or For loop

2007-03-26 Thread Travis Doherty
Jake Gardner wrote:

 He said if you run the /script/ itself 1000 times, not a loop with 1000
 iterations. This is quite possible; I am fairly certain there are
 websites
 out there that get accessed well over 1000 times a minute, yes?

 So every minute, that website is saving a total of 2.6 seconds to do...
 whatever it is websites do in their free time.

 In reality, scripts rarely get executed once and then are deleted;
 they are
 used repetitively, and the more a script is used, the more significant
 the
 gain. Claiming to look practically on a small gain /within one
 execution of
 a script/ is impractical in itself.

I still wouldn't go around telling people to re-write all of their code
to use for loops instead of while loops (or whatever was faster for
whatever architecture.)

Keep in mind that .000xx seconds in performance improvement certainly
does make a difference on a site that is accessed millions of times a
day, however, one bug caused by writing code that reads poorly instead
of writing clean code can cost a *lot* more in the end.

- Use what reads easier when deciding if a for/while loop is best.
- Profile your code and find the right places to optimize.

Optimizing code that takes .0001 seconds to run down to .1 seconds
is great, 10x improvement!  Who cares. Find the chunk that takes 0.5
seconds to run and optimize that to 0.05 seconds. 10x improvement still,
except that this time it actually makes a practical difference.

Travis Doherty

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



Re: [PHP] Important Design Patterns

2007-03-25 Thread Travis Doherty
Tijnema ! wrote:

 On 3/25/07, PHP Developer [EMAIL PROTECTED] wrote:

 hello all,
 As we know, there are a lot of php design patterns(more than 20). I
 want to know that which patterns are important and necessary for ZCE
 exam.
 PHP5 Study Guide only covers Singleton,Factory,Registry,MVC and
 ActiveRecord. But i still feel that more patterns are necessary for
 the exam.
 Cheers,
 Daniel


 I'm not able to give an answer, but was it really needed to post this
 message three times??

 Tijnema

Taking the Zend ZCE exam puts you under a strict NDA.  Nobody can tell
you what you will see on the exam.

Study the exam guide and if design patterns really interest you then
take it to the next level out of personal interest.  Since patterns are
not PHP-only you can really study these from any language, or even
grab a language-agnostic design pattern book.

Travis Doherty

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



Re: [PHP] Computing and calculating dates

2007-03-24 Thread Travis Doherty
Otto Wyss wrote:

 This probably has been asked several times yet I can't find a
 satisfying solution. What's the simplest way to compute dates like

   local_formated_date + 7; // days
   local_formated_date  local_formated_first_day_next_month;
   local_formated_date  (current_date + 14)

 etc. Which functions are best suited for such calculations?

 O. Wyss

www.php.net/strtotime is probably a good start.

Travis Doherty

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



Re: [PHP] Passing variables

2007-03-22 Thread Travis Doherty
itoctopus wrote:

Since you're new to this, always be sure to clean up the output you get from
$_GET or $_POST to avoid sql injection.

Fore example: $search_value = htmlentities($_GET['search_value'],
ENT_QUOTES);
If you're casting to something other than a string (such as int) than you're
safe and you don't have to use htmlentities.

  

Good call. One better is prepared statements.  Avoid the problem all
together.

Travis Doherty

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



Re: [PHP] close session when browser is closed

2007-03-22 Thread Travis Doherty
Juergen Wind wrote:

Travis Doherty wrote:
  

By default the session cookie expires when the browseris closed.


this is not always true: f.e. FF requires *all* open windows to be closed to
forget that session.
  

Personally I think this does make sense.  I fully expect the browser to
maintain cookies Until it is closed -- If I have closed one tab that
had set a cookie, re-opening that URL in a new window/tab should still
cause the browser to send in my cookie.

  

If the browser refuses the cookie, sessions won't work anyway.  


again: this is not always true. Only if  session.use_only_cookies = 1
otherwise the session id can alternatively propagate using the query string
or hidden input fields.
(if session.use_trans_sid = 1)
  

That is correct - as I mentioned (unless its in the URL...) ... It's
kind of weird to pass sessions through URLs though, I prefer clean,
simple URLs such as www.example.com/resource/topic.html, instead of
something like
www.example.com/?x=resourcey=1113this=44PHPSESSID=123124124124124bookmarkable=not_really

Travis

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



Re: [PHP] Performance: While or For loop

2007-03-22 Thread Travis Doherty
Tijnema ! wrote:

 On 3/22/07, Jon Anderson [EMAIL PROTECTED] wrote:

 Your test isn't exactly fair. The for loop has no statements in it, and
 the while loop has one. Your tests show while as approx 7% faster, while
 a modified test shows an approximate 30% speed improvement:

 Do this:

 for ($i=0;$i1000;$i++) {}

 v.s.:

 $i = 0;
 while ($i++  1000) {}


This has been asked many times, probably likewise for every language. 
Search for the same question on the C programming language for a more in
depth discussion of this and to find out why one way is faster than the
other...

Major factor: Don't forget the difference between pre and post increment
operators.  $i++ and ++$i.

For reference this is my PHP test script and results:

{{{
[EMAIL PROTECTED] tdoherty $ cat ./forwhile.php
?
$i=0; $start = microtime(TRUE);
for ($i=0; $i10; ++$i) {}
echo sprintf(For pre-increment ($i): %0.3f\n,microtime(TRUE) - $start);

$i=0; $start = microtime(TRUE);
for ($i=0; $i10; $i++) {}
echo sprintf(For post-increment ($i): %0.3f\n,microtime(TRUE) - $start);

$i=0; $start = microtime(TRUE);
while (++$i  10) {}
echo sprintf(While pre-increment ($i): %0.3f\n,microtime(TRUE) - $start);

$i=0; $start = microtime(TRUE);
while ($i++  10) {}
echo sprintf(While post-increment ($i): %0.3f\n,microtime(TRUE) - $start);
?
[EMAIL PROTECTED] tdoherty $ php ./forwhile.php
For pre-increment (10): 0.035
For post-increment (10): 0.060
While pre-increment (10): 0.029
While post-increment (11): 0.056
}}}

After multiple runs I see that the for pre-increment loop is fastest. 
Note that the while loop with a post-increment runs once more than with
a pre-increment.

Everytime I run, the results are *very* different, though still fall
within similar comparitive domains.

Travis Doherty

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



Re: [PHP] Creating an FTP account on the fly from PHP

2007-03-22 Thread Travis Doherty
PHP Fusebox wrote:

 I built a CMS that lets a super user create and manage basic users
 (among lots of other things). I want basic users to get an FTP account
 that is automatically associated with their website user account, and
 managed from my add/edit user form. For example if I create a user
 named [EMAIL PROTECTED] for him to login to my web app, I want my
 users to be able to use their same login name and password to access
 their web folder via FTP.

 I am running on LAMP on a CPanel server with ProFTP as the FTP server
 software, but I have no clue how to get PHP to be able to create,
 edit, or delete an FTP account. Can someone point me in the right
 direction?

ProFTPd?  It can authenticate against MySQL tables...  It gets
authentication from your database.  We used to do this many many years
ago... It worked fine and was probably choke full of security problems.

Setting up ProFTPd for MySQL authentication was a pain, I'm sure its
easier today.  Once you have that setup, its just a simple matter of
CRUD SQL queries.

Travis Doherty

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



Re: [PHP] Sessions timing out, php5

2007-03-21 Thread Travis Doherty
Paul Nowosielski wrote:

Dear all,

I'm having an issue where sessions timeout after inactivity.

I have session.cache_expire set to 1440.

But some users have reported sessions timing out after a couple hours.

  

Are you storing sessions in /tmp?

Possible that your OS has a cron job running that clears out that
directory, especially if these complaints are usually around midnight
when these types of jobs typically run.

Travis Doherty

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



Re: [PHP] close session when browser is closed

2007-03-21 Thread Travis Doherty
Alain Roger wrote:

 Hi,

 I would like to know what is the best solution for my problem.

 When a user is connected to a https page and a session is open, if user
 close his browser, the session ID is still active in the browser
 history.
 It means that next time when user will start his browser, the browser
 will
 re-use the same session ID and will work with php pages without any
 problem.

 I was thinking to use cookie to solve this issue, but what should i do
 when
 user browser refuse cookies ?

 thanks a lot,

This seems odd.  By default the session cookie expires when the browser
is closed.  You can change this by changing ini setting
session.cookie_lifetime to something other than default value of zero,
in number of seconds.

I don't believe using HTTPS changes any of this, I have more than one
app that use HTTPS for session cookies and have no problems with it
persisting after the browser is closed (well, some browsers can do weird
things sometimes... you never really know.)

If the browser refuses the cookie, sessions won't work anyway.  The
session key is sent to the browser as a cookie (unless its in the URL...)

www.php.net/session/
Take a look at cookie_lifetime and you might like the cache_expire docs
on the same page too.

Travis Doherty

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



Re: [PHP] close session when browser is closed

2007-03-21 Thread Travis Doherty
Alain Roger wrote:

 Hi Brad,

 yes this is one possibility, but since i use https, i should not be
 afraid
 by storing data in $_SESSION variables.


Just a note that while SSL may help to protect the session id from being
packet sniffed you should still be concerned about storing sensitive
data in _SESSION.  Anyone local to the system can probably read
plaintext session data from the session cache.

HTTPS only protects communications between the client and the server at
best, do be afraid!

Travis Doherty

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



Re: [PHP] reverse http authentication

2007-02-18 Thread Travis Doherty
Chris W wrote:

 I want to read a page that is protected with http authentication.  How
 do I pass the user name and password to be authenticated with my php
 code?

Have you tried to just put the username and password in the URL?  I'm
not sure if this works, its so simple its worth a try.  Instead of using
(whatever function you use) like the first example try changing it like
the second:

x('http://example.com/protected/page.php');
x('http://username:[EMAIL PROTECTED]/protected/page.php');

Of course it depends on the 'x' you are using...  I'm really not sure if
PHP's functions will take care of moving that username/password
information into the header of the HTTP request or just leave it there.

Travis Doherty

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



[PHP] Filtering _REQUEST.. Why is this bad?

2007-02-12 Thread Travis Doherty
Hello.

Came across some code that startled me.  Mostly because it goes against
the generally accepted idea of detecting and rejecting bad input instead
of trying to escape it, secondly because it just feels wrong.

The only technical case I have so far is for inserting a double/single
quote into the database. It will get inserted as its htmlentities equiv
of 'quot;' for example.  In the future if they wanted to display the
data in the database in a format other than html it will be messy.

So... the question is: What else is wrong with this? or.. Why is this so
bad?


?php
// blindly run everything in _REQUEST through htmlentities
function recursiveFilter($array)
{
foreach ($array as $key = $val)
{
if (is_array($val))
{
$return[$key]= recursiveFilter($val);
} else {
$return[$key] = htmlentities($val,ENT_QUOTES);
}
}
return $return;
}
$_REQUEST= recursiveFilter($_REQUEST);

// queries directly inserting from $_REQUEST
// echo'ing of data directly from $_REQUEST

?

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



Re: [PHP] How to make Browse Folder Dialog

2007-01-23 Thread Travis Doherty
Aslam Bari wrote:

Dear All,
I m new in this Forum. I m making a project in which i need to show user a
Browse Folder Dialog Box, In which he can select a folder and after this i
will do some manipulation on that folder's content. So the problem is that i
could not found any sample on Web , how to show Folder Dialog in any way
(HTML, JavaScript, PHP etc). Plz has anybody some idea how to do some work
around this.

Thanks...
  

PHP won't let you edit files on your users' computer.  Ever.

Maybe it would be worth your time to look into a different language to
do whatever it is you want to do, something like Visual Basic might suit
you well (last time I used it there was a control that would popup the
standard windows 'Select Folder' dialog.)

Travis Doherty

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



Re: [PHP] Splitting long text

2007-01-23 Thread Travis Doherty
Anas Mughal wrote:

 I have been using the below function successfully. Hope it works for you.
 -- Anas



 // textwrap 1.1 Brian Moon [EMAIL PROTECTED]
 // This code is part of the Phorum project http://phorum.org
 // $String The string to be wrapped.
 // $breaksAt   How many characters each line should be.
 // $breakStr   What character should be used to cause a break.
 // $padStr Allows for the wrapped lines to be padded at the begining.

Short of string padStr in that function, and bool cut in the native PHP
one, I don't see why someone wouldn't just use http://php.net/wordwrap/ .

Travis Doherty

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



Re: [PHP] How to make Browse Folder Dialog

2007-01-23 Thread Travis Doherty
Børge Holen wrote:

On Wednesday 24 January 2007 07:32, Travis Doherty wrote:
  

Aslam Bari wrote:


Dear All,
I m new in this Forum. I m making a project in which i need to show user a
Browse Folder Dialog Box, In which he can select a folder and after this i
will do some manipulation on that folder's content. So the problem is that
i could not found any sample on Web , how to show Folder Dialog in any
way (HTML, JavaScript, PHP etc). Plz has anybody some idea how to do some
work around this.

Thanks...
  

PHP won't let you edit files on your users' computer.  Ever.

Maybe it would be worth your time to look into a different language to
do whatever it is you want to do, something like Visual Basic might suit
you well (last time I used it there was a control that would popup the
standard windows 'Select Folder' dialog.)

Travis Doherty



Ouch, this is close to swearing in the church...

  

:p  I suppose it is.  Use the right tool for the job right?  PHP on a
server won't ever let the OP manipulate the content of a folder on his
users computer.

T

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



Re: [PHP] How to make Browse Folder Dialog

2007-01-23 Thread Travis Doherty
Aslam Bari wrote:

Hello,
Just a minute. I know the php script will run on server. Suppose i m working
on server machine and i need to make a project for myself. The machine is
only one and same. Also there are a lot of file and directory methods
available in PHP, Whats that? Actually i want to show the files of selected
folder on screen.
Thanks...
  

Yes, PHP has file handling functions for use on the server it is running
on.  As long as we're clear that it can't touch the filesystem of the
user of the application :D

If you just wanted to make a list of folders and let them select one you
could build the list using an HTML SELECT box.  Once they have selected
an item and click on submit, you would use similar code that you used to
populate your directory list to show a list of all files in that directory.

The code at Example 2 on the php.net readdir documentation is probably
one good place to start: http://www.php.net/readdir

A hint from another thread today to save yourself trouble: Always use
full paths when working with files.

T

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



Re: [PHP] Detecting naughty sites

2006-11-28 Thread Travis Doherty
Tom Chubb wrote:

 On 28/11/06, Dave Goodchild [EMAIL PROTECTED] wrote:

 Hi all. I am building a web app and as part of it advertisers can upload
 their ad image and website URL to go with their ad. Is there a good
 way to
 detect whether that site is a porn site via php?

 -- 
 http://www.web-buddha.co.uk


 I remember seeing something that used GD to detect colours similar to
 flesh within an image and thinking it was funny that someone had taken
 so much time to to it, but I can't remember where it was.
 I think it was on phpclasses.org but can't find it. Maybe someone else
 remembers it?

And more recently a commercial vendor is performing something along the
lines of 'curve recognition' to the same effect.  That's fine for any
vector graphics (banner ads might fall here.)  False positives will be
high with beach photos from family vacation, for example.

Travis

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



Re: [PHP] Ftp a file--errors in rendered page, Ftp the file again--works fine. Huh?

2006-11-23 Thread Travis Doherty
Nicholas Crosby wrote:

Hello:

I would appreciate any help on this that someone might have. A student of
mine found this issue. He ftp's a file to a server and looks at it through a
browser, there are errors. He uploads the file again, it works fine. I am
stumped. Any ideas? Here is the text of the file that he is uploading.
Basically, if you add some more text to the bottom and upload it, the page
will not generate the proper output.
  

The file is uploaded using an FTP client or it is uploaded using PHP's
FTP functions?

If I understand correctly, it sounds like the FTP client is having
troubles uploading the file.  Try to minimize the script and see if you
can still reproduce:

?php
echo htmlbodyHello/body/html;
?

If you upload a script like that, does it get something simple done
correctly or does that also require a second upload?

Travis

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



Re: [PHP] Attaching File to be Emailed

2006-11-23 Thread Travis Doherty
[EMAIL PROTECTED] wrote:

 I need to take a word document or pdf file from either a MySQL db or
 from a
 directory, which will then be sent via php script.  How can I go about
 doing
 this?  Can anyone provide sample code or point me in the right direction.

Brian Dunning started a thread about nine minutes before you on sending
a file to the browser. Serving out a file to Firefox ... headers?
That's pretty much all you need to do to read from a file (adding in
whatever fixes the problem he is experiencing with FireFox of course.)

If you wanted to store the data in a MySQL database it would be the same
procedure, except you would query the database (BLOB column type) and
echo that data instead of using readfile() to get your data.

Travis

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



Re: [PHP] Serving out a file to Firefox ... headers?

2006-11-23 Thread Travis Doherty
Brian Dunning wrote:

 Sorry to revisit this issue YET ONE MORE TIME...  :)  :)

 My online store sends out the file for download upon purchase. Below 
 are the headers I send, and I understood that it should work for all 
 browsers. It does not work for Firefox. Suggestions?

 header('Content-Type: application/octet-stream');
 header('Content-Disposition: attachment; filename='.$filename);
 $size = filesize('../../store/files/'.$filename);
 header('Content-Length: '.$size);
 readfile('../../store/files/'.$filename);

Pretty sure Richard already squared this one away, I think this is the
article you are looking for:

http://richardlynch.blogspot.com/

Travis

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



Re: [PHP] Smart Quotes not so smart

2006-11-15 Thread Travis Doherty
Robert Cummings wrote:

On Wed, 2006-11-15 at 20:36 -0600, Larry Garfield wrote:
  

I've run into this sort of issue a few times before, and never found a good 
solution.  Now a client has been hit with it and is asking for a solution, 
and I'm not convinced there is one. :-)

Client has a large MS SQL database with lots of data.  Some of that data 
includes smart quotes, aka curly quotes, but not real ones.  They're the MS 
Word character encoding standards?  What's that? smart quotes.  On their old 
setup (SQL Server 2k, OpenLink ODBC driver, IIS, PHP 4.0.6), they actually 
worked just fine.  On our old devel setup (the same but with a different ODBC 
driver), it worked fine.  

On our new devel setup (SQL Server 2k, OpenTDS ODBC driver, Apache, PHP 
5.1.6), it works fine.  On their new live setup, however, (same, but again 
not sure of the ODBC driver) they're getting the dreaded squares or question 
marks or accented characters that signify a garbled smart quote.  I know 
they're not unicode characters because Windows, the DB server, and the driver 
are all set to either UTF-8 or UTF-16.  

We've tried eliminating middle-men to no avail.  I've also tried doing a 
find-replace on the smart quote characters before they're inserted into the 
database, copying and pasting them from Word, and PHP skips right past them 
and enters them into the database.  

All we're left with is MAYBE telling them to dry a different ODBC driver or 
else fixing the data by hand.  I don't like either option, myself.  Does 
anyone have any better ideas to suggest?  Any idea what those smart quotes 
actually are, and if they exist in ANY valid character set other than Word 
itself?



There's a few different charsets that support them. Either way, can you
open up some content that has them using a hex editor and tell us the
hex codes for the bytes? That will help determine what charset.

Cheers,
Rob.
  

John Walker's insight might be a good lead on some more information on
exactly what these are, even if it doesn't directly solve the problem.

I can only guess that their 'smart quotes' exported to HTML from Office
apps are the same 'smart quotes' in your database... who knows :p

http://www.fourmilab.ch/webtools/demoroniser/

Travis Doherty

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



Re: [PHP] Time-Zone juggling

2006-11-08 Thread Travis Doherty
David Giragosian wrote:

 Does Daylight Savings alter Zulu time? (I'm guessing yes). How did the
 military deal with that?

 I use a date-time field as a primary key in db tables that get an
 insert a
 minute. I had to jump through a number of hoops to turn off DST on the
 (RH
 Linux) server.

 David

UTC (or GMT, or Zulu, or Z) does not observe Daylight Savings Time.  In
any database that you store timestamps and need to know exactly what
that timestamp means you should use UTC, then use application logic to
translate to the users time zone.

Another option would be to store epoch time (seconds since the OS's
epoch) and work the same result from that, I prefer storing
human-readable timestamps even if you have to do the datemath in your
head to read them in your own timezone.  Epoch does not count
leap-seconds like UTC so it can be off by a tiny bit at any given time. 
Epoch time also differs on different operating systems - Unix is
1970-01-01 at 00:00:00 UTC, Windows seems to use 1601-01-01 at 00:00:00
UTC... I don't know if that would ever matter though - I imagine the
database server would mask this and the application would port to
windows without problems (no idea.)

UTC has no DST from: http://en.wikipedia.org/wiki/Time_zone

Due to daylight saving time, UTC is local time at the Royal Observatory,
Greenwich http://en.wikipedia.org/wiki/Royal_Observatory%2C_Greenwich
only between 01:00 UTC on the last Sunday in October and 01:00 UTC on
the last Sunday in March. For the rest of the year, local time there is
UTC+1 http://en.wikipedia.org/wiki/UTC%2B1, known in the United
Kingdom http://en.wikipedia.org/wiki/United_Kingdom as British Summer
Time http://en.wikipedia.org/wiki/British_Summer_Time (BST). Similar
circumstances apply in many places.

**
Travis Doherty
TixTime

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



Re: [PHP] Time-Zone juggling

2006-11-07 Thread Travis Doherty
Richard Lynch wrote:

What is the least-stupid way to fix this, and get 20:00 in the
Portland OR server to turn into:
Mon, 03 Apr 2006 20:00:00 CDT
which is what time it really was.

E.  Without changing the schema which means having to re-do
everything else in the application.  That's probably the RIGHT way to
fix it, but that ain't happening.
  

Yeah...  I ran into the same stuff a few weeks ago with the DST change. 
The quickest solution that is *almost* OK is using
putenv(tz=america/montreal) or putenv(tz=america/san_diego) etc..
(should really be the date_default_timezone_get/set functions)

Datetime fields do not have timezone stored (mysql too.)  The only real
solution to this problem is to always store datetimes in GMT/UTC.  That
is the correct thing to do, and until that is done our workaround still
has one problem (that isn't big enough to warrant reworking the
ticketing code that inserts to the db...)

The remaining problem is that until we store in UTC we will never know
which 01:30:00 a timestamp refers to, EDT or EST (Eastern Daylight, or
Eastern Standard.)  In UTC this doesn't happen.  Of course there is no
problem for spring, only in the fall time change.

This can be a big problem to some apps, and others might be fine with
the workaround like we've done where you loose a tiny bit of data (It's
08:00 on the day after the timechange, is this ticket from 01:30:00  6.5
or 7.5 hours old? who cares.. just reply.)

Travis Doherty

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



Re: [PHP] Month in a numeric form

2006-10-15 Thread Travis Doherty
Ron Piggott (PHP) wrote:

Is there a way I am able to use the DATE command to convert January to
1, February to 2, etc.

  

What is wrong with date()?
www.php.net/date

$month = 'Jan';
$numericMonth = date('m', strtotime($month 01 2000);

Travis Doherty

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



Re: [PHP] Date calculation

2006-10-15 Thread Travis Doherty
Ron Piggott (PHP) wrote:

I have one more date based question.

I have a month field ( $month ) and a day field ( $day ) being submitted
by a form.

I have a third field to be used as a date reminder for the information
which was submitted as part of the form.  It is a reminder to complete a
task for the date was which was submitted as part of the form.  

How do I calculate the $reminder date based on $month and $day and have
it output in the -MM-DD format?  $reminder is the number of days
before $month $day  (I want to use $reminder in a date format to SELECT
records from a mySQL table)  This is why I am wanting put $reminder into
a date format

If $month was 6 and $day was 7 and $reminder was 6 then I would want the
output to be 2007-06-01 --- We have already passed June 1st in 2006.
However if $month was 11 then I would want the output to use this years
date --- 2006-11-01

Any suggestions?  

Ron

  

I think it would be easier to ask the user to enter his reminder in the
standard date format of -mm-dd and use a JavaScript date picker box
to prompt for it.  Anyway, you could do something like this:

$reminderStamp = strtotime(+{$addMonths} months,time());
$reminderStamp = strtoTime(+{$addDays} days,$reminderStamp);
$date = date(Y-m-d,$reminderStamp);

$date should have a string like -mm-dd that is $addMonths and
$addDays into the future.  I didn't test this.

Travis Doherty

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



Re: [PHP] Working with overly aggressive anti-spam measures

2006-10-10 Thread Travis Doherty
Dave M G wrote:

 PHP List,

 I run a few various social groups, and with each one I keep in contact
 with members by emailing them short newsletters.

 All my user information is stored in a MySQL database. I use PHP to
 get the relevant contact information, and use the mail() command to
 send out the emails one by one, so that each email is a little
 personalized.

 I've used this system for many years now with no problems up until now.

 What has changed, though, is that in recent years, anti-spam measures
 have become so aggressive that more and more people who sign up to my
 groups complain that they never receive the emails.

 A lot of the times, after they alert me to the issue, I can educate
 them a little about the anti-spam measures they most likely have on
 their system, and walk them through how to make it so that my
 newsletters go through.

 However, that is clearly not enough.

 To shorten a story that has already gone on a little long, it's come
 to my attention that part of the reason that my emails may not be
 getting through are because the headers are not sufficiently
 legitimate looking enough to bypass some server side anti-spam
 measures. Things like Return-Path are being set so that they look
 like they come from an email address that begins with the username
 nobody.

 If possible, can anyone help me with creating the PHP code that will
 make an email as legitimate as it can be? I know I can't totally
 prevent my email from being marked as spam (after all, if it were
 possible, all the spammers would do it). But as much as I can prevent
 anti-spam measures getting a false positive when testing my email, the
 better.

 Here is the PHP code I currently use (trimmed for clarity):

 while ( $member = mysql_fetch_row($mysqlResult) )
 {
 $subscriber = $member[0];
 $email = $member[1];
 $subject = Report for  . date('l jS F Y');
 $mailContent = This is an email to  . $subscriber .  at  . $email
 . .;
 $fromAddress = [EMAIL PROTECTED]
 mail($email, $subject, $mailContent, $fromAddress);
 }


 And here is what the headers for an email from that code looks like:

 -Account-Key: account5
 X-UIDL: UID497-1152485402
 X-Mozilla-Status: 0001
 X-Mozilla-Status2: 
 Return-path: [EMAIL PROTECTED]
 Envelope-to: [EMAIL PROTECTED]
 Delivery-date: Sun, 03 Sep 2006 14:22:42 -0700
 Received: from nobody by server.myhostingservice.com with local (Exim
 4.52)
 id 1GJzQQ-0005pA-Mz
 for [EMAIL PROTECTED]; Sun, 03 Sep 2006 14:22:42 -0700
 To: [EMAIL PROTECTED]
 Subject: Report for Monday 4th September 2006
 From: [EMAIL PROTECTED]
 Message-Id: [EMAIL PROTECTED]
 Date: Sun, 03 Sep 2006 14:22:42 -0700

 Which parts are key to change, and how?

 Thank you for any and all advice.

 -- 
 Dave M G
 Ubuntu 6.06 LTS
 Kernel 2.6.17.7
 Pentium D Dual Core Processor
 PHP 5, MySQL 5, Apache 2


If it is sendmail it would be the -f parameter to set the Envelope-From
address.  ie... php.ini would have 'sendmail_path = /pathto/sendmail -f
[EMAIL PROTECTED]'.  Since PHP 4.0.5 you can also set the
additional_parameter like php.net/manual/function.mail.php (the example
there is specifically for this use.)

What you actually should be doing: install SpamAssasin on your
workstation and run the message through it in test mode...  Figure out
what rules get hit and work to resolve those.  Run it like `spamassassin
-t  message_with_headers`

So, you'd copy your complete message (as you have above) into
message_with_headers and run it through SA.  Maybe SA is giving you
points for things like too many exclamations, certain ratio of HTML... 
I doubt that having a return-path of 'nobody' is the lowest-hanging
fruit you can pick up here to make yourself look less spammy.

Also make sure the sending mail server isn't listed in any blacklists
(yahoo for RBL lookup tool to check.)

Travis Doherty

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



Re: [PHP] Working with overly aggressive anti-spam measures

2006-10-10 Thread Travis Doherty
Dave M G wrote:

 1. Spamassassin says:

 Spam detection software, running on the system homebase, has
 identified this incoming email as possible spam.  [...]

 Content analysis details:   (0.3 points, 5.0 required)

 pts rule name  description
  --
 --
 0.3 AWLAWL: From: address is in the auto white-list

 I looked up about auto white-lists on the net, and it says that it's a
 comparison between the current and previous emails. But for testing
 purposes, I don't really want it to compare against previous emails,
 since previous test emails would be spammier and bias spamassassin
 the wrong way.

 How can I compensate for this?

Yup, as you mentioned the AWL (auto-white-list) is a comparison to
previous messages.  If that is the only rule that gets hit it looks like
you are doing pretty good.  You did include the body of the message in
the test right?  Not just the headers?

I expected you would have hit more rules than that.  Of course, that is
an 'out-of-the-box' install of SA, most people have special rules in
there, bayes training done, etc...  I believe there is also a website
that you can copy paste the message into to perform the same test (see
message on this list, Peter Lauri - PHP Mailer and SMTP = SPAM?)  That
site might have other rules configured (SARE... etc) that you might be
hitting.  Worth a shot.

Travis Doherty

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



Re: [PHP] strange errors from command line vs. web

2006-09-28 Thread Travis Doherty
blackwater dev wrote:

 Ok, dumb question but how do I do that?  I know how to re-compile the
 standard php.  My code also uses mssql via freetds, does that somehow
 need
 to be enabled as it doesn't seem to fail there.

 Thanks!

 
  echo about to connect;
  $this-connectionID= @mysql_connect($this-host, $this-user,
  $this-password);
  echo after connect;
 

Just to verify that this is in fact the problem you should remove the
'@' sign from mysql_connect.  '@' is a way of supressing errors, you
specifically WANT that error.  Is there a reason you have the '@' there?

If the error is 'Undefined function mysql_connect' then you do need to
get MySQL support compiled in...  If it is available on the apache
module it should be available to the CLI as well.

If there is no 'undefined function' error then you should also be
calling 'echo mysql_error()' to see what the error is after connecting. 
That error is going to give you more info than any of us can.

Travis

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



Re: [PHP] Mail Problem

2006-09-26 Thread Travis Doherty
Richard Lynch wrote:

if(!mail($to,$subject,$msg,$headers)) { die(Unable to send); }



*IF* you are using PHP5 (?) and *IF* your security settings allow it,
the optional fifth argument will let you specify the real sender of
the message, which the responder may or may not be using to bounce to.

http://php.net/mail
  

Richard is correct on that. The fifth argument isn't only for the
envelope sender, so ensure you include the '-f' for sendmail and compat.
wrappers.

php.net/mail: ChangeLog:
4.0.5 The additional_parameters parameter was added.

... which the responder may or may not be using to bounce to.
  

They should *always* be sending to the envelope from address (SMTP `MAIL
FROM` command), with an empty envelope sender (SMTP `MAIL FROM:`) to
avoid loops.

The RFC's are a rather in depth, so here is an excerpt from Wikipedia
that pretty much sums up what the RFCs do contain:
[http://en.wikipedia.org/wiki/Bounce_message]

 The Return-Path is visible in delivered mail as header field
 Return-Path inserted by the final SMTP mail transfer agent
 http://en.wikipedia.org/wiki/Mail_transfer_agent (MTA), also known
 as mail delivery agent
 http://en.wikipedia.org/wiki/Mail_delivery_agent (MDA). The MDA
 simply copies the *reverse path* in the SMTP MAIL FROM command into
 the Return-Path. The MDA also removes bogus Return-Path header fields
 inserted by other MTAs, this header field is generally guaranteed to
 reflect the last reverse path seen in the MAIL FROM command.


Travis Doherty

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



Re: [PHP] Is there a list of all Timezones as an array or someting?

2006-09-20 Thread Travis Doherty
Google Kreme wrote:

 On 20 Sep 2006, at 06:15 , Chris Boget wrote:

  $timeZonesArray = array( 'GMT'= array( 'GMT'   =  +0
 // GMT


 Er... ok, but that seems to be missing quite a lot.  For example, I 
 notice that India Standard Time (IST; UTC +5:30) is missing from your 
 array.  Granted, it's only 1.1 Billion people and the largest English 
 speaking population in the world... (or second most, depending on 
 whom you ask).

 Or did you just forget to paste the Asia portion of the array?

Most Linux boxen have `|/usr/share/zoneinfo/zone.tab`, or grab it from
the database tables in a mysql server (assuming it is setup with
timezones imported) which would be the mysql.timezone* tables.

|http://www.php.net/putenv

The comments have quite a bit on timezones and PHP.  The command you
will use to change the timezone of the running script is:

putenv(TZ=$zone);

The equiv to set a MySQL connection to a certain timezone would be:

SET time_zone = '$zone';

http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html

That URL has the MySQL side of setting timezones.

Travis Doherty

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



Re: [PHP] Reverse of date(w)

2006-09-18 Thread Travis Doherty
Kevin Murphy wrote:

 Not really. If it were always today that would work, but in this 
 case, I was thinking of storing a day of the week in a database 
 (3), and then display the info based on that digit. So assuming 
 that the number was in fact 3, then:

 echo date(D,3);

 Would return Wed.

 Is there any function like that? Oh, and it has to run on PHP 4.


Any reason you wouldn't write it yourself?

?php
function getDayFromInteger($integer)
{

   $days = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');

   if (isset($days[$integer]))
   {
  return $days[$integer];
   }

   return false;

}
?

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



Re: [PHP] Reverse of date(w)

2006-09-18 Thread Travis Doherty


Chris Ditty wrote:

 Another way to do it would be to store the unix epoch and then just
 get the
 weekday name from that?  More overhead than Travis's idea, but just as
 good
 and you could possibly use the date/time later on.


I use the DATETIME fieldtypes in MySQL, same idea... 100% agreed that
keeping that timestamp for later use is a good idea.

For Kevin's original question.. Here is the MySQL function to get that
short weekday name off of a DATETIME column:

Table with datetime column:

mysql SELECT id,effectivetime
- FROM event
- WHERE employee_id ='1001';
+-+-+
| id  | effectivetime   |
+-+-+
| 184 | 2006-09-18 18:50:25 |
| 182 | 2006-09-17 23:12:17 |
| 178 | 2006-09-12 21:59:44 |
+-+-+
3 rows in set (0.00 sec)



Query to get 'weekday':

mysql SELECT id,effectivetime,DATE_FORMAT(effectivetime,%a) AS weekday
- FROM event
- WHERE employee_id = '1001';
+-+-+-+
| id  | effectivetime   | weekday |
+-+-+-+
| 184 | 2006-09-18 18:50:25 | Mon |
| 182 | 2006-09-17 23:12:17 | Sun |
| 178 | 2006-09-12 21:59:44 | Tue |
+-+-+-+
3 rows in set (0.00 sec)

Those DATETIME columns can do some other neat things too:

SELECT * FROM events WHERE starttime BETWEEN '2006-09-18' AND '2006-09-28'
Gives me a list of events happening in a certain period...

SELECT * FROM events WHERE DATE_SUB(CURDATE(), INTERVAL 30 DAY)  starttime
Gets you the last 30 days without needing to make those '2006-09-18'
style strings in PHP code.

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
They should all work on DATETIME type columns, storing seconds since
epoch doesn't quite give you that (you could work it in pretty easily
I'm sure, why not use the native column type!)

Cheers,
Travis


 On 9/18/06, Travis Doherty [EMAIL PROTECTED] wrote:


 Kevin Murphy wrote:

  Not really. If it were always today that would work, but in this
  case, I was thinking of storing a day of the week in a database
  (3), and then display the info based on that digit. So assuming
  that the number was in fact 3, then:
 
  echo date(D,3);
 
  Would return Wed.
 
  Is there any function like that? Oh, and it has to run on PHP 4.
 

 Any reason you wouldn't write it yourself?

 ?php
 function getDayFromInteger($integer)
 {

$days = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');

if (isset($days[$integer]))
{
   return $days[$integer];
}

return false;

 }
 ?

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




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



Re: [PHP] Mail in Spam Box

2006-06-18 Thread Travis Doherty
kartikay malhotra wrote:

 Hi all!

 I've use PHP mail to send mail to my Gmail ID. But it gets delivered
 to my
 Spam box and not the Inbox :(

 Am I missing a header, signature, certificate?

 Thanks
 KM


Is the system you are sending from listed in any RBLs?  If you don't set
a subject line, SpamAssassin hits you hard, make sure you have a real
To:, From:, and Subject: header.  The date header also needs to be set -
with the correct time.

Spam scores come from many different sources of information - two major
sources are the message itself and the server sending the message.  If
you can send mail from this server using a normal mail client and it
does not get blocked as spam then it is probably your message.  If
sending using a normal client still gets blocked as spam in you gmail
account chances are it is the server and not your code.

Travis

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



Re: [PHP] image location hiding techniques

2006-02-07 Thread Travis Doherty
hbeaumont hbeaumont wrote:

Hi,

I have a site with images that I want people to download but not have
the direct path to. ie. I do not want them to be able to just view the
source, find the dir and then download everything or direct link to
them.

However I can see no way to do this other than keeping the images on
disk, having a php script read them and then spit them out. example:

view.php?92348924  where 92348924  is a code that translates to the
image on disk.

  

Doing this would cause an extra hit to disk to load the PHP script and
the image instead of just the image file, if you are concerned about
disk I/O.  You could go the script route as you have mentioned and also
add a check on HTTP_REFERER to ensure they came from your site.  You
might even set a cookie and ensure that exists as well.  Randomize the
image numbers so they are not sequential, add some alpha characters to
make it real fun.  Give a 404 Not Found instead of an error if the
referer or cookie wasn't set to add some obscurity to the mix.

This will deter most people from grabbing all of the images, but if they
are available to the public for download it will always be possible for
someone to figure out your counter measures.  It doesn't mean you can't
make it trivial enough that they move along to the next site.

Travis Doherty

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



Re: [PHP] help plz [Books]

2006-01-16 Thread Travis Doherty
Ligaya Turmelle wrote:

 I personally liked George Schlossnagle's book Advanced PHP
 Programming, published by Sams. 

 I am also assuming you actually do know the basics of MySQL and PHP
 and are looking for that next step - past the beginner stuff.

I agree.  I have seen this book alone take coder to developer.

It is not a beginner's book - but will help you get closer to expert
faster than a two foot stack of beginner level material (again, assuming
you are looking for that next step)  Leave section five
(Extensions) until you are more experienced.

High Performance MySQL by Zawodny  Balling, O'Reilly -- not PHP
specific but essential if your MySQL databases will have heavy load on them.

Travis Doherty

Ligaya Turmelle wrote:

 I personally liked George Schlossnagle's book Advanced PHP
 Programming, published by Sams.

 http://www.amazon.com/gp/product/0672325616/qid=1137394700/sr=2-1/ref=pd_bbs_b_2_1/104-0195316-0794320?s=booksv=glancen=283155


 suresh kumar wrote:

 hi,
i am working as a web designer in PHP  Mysql.i
 know the basics of PHP  Mysql,i want 2 become PHP
 Expert,i am planning to buy one Book,but i dont know
 which book 2 buy.plz give me info .
   A.suresh

 Send instant messages to your online friends
 http://in.messenger.yahoo.com



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



Re: [PHP] how to find the system tmp folder

2006-01-05 Thread Travis Doherty
Samuel DeVore wrote:

How does one find the system temp folder? from php? in a platform
independant way

  

This should help:
http://www.php.net/manual/en/function.tempnam.php

It does return the name of the temp file created (or FALSE), which could
be parsed to get the temp directory as PHP best sees fit.

Travis

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



Re: [PHP] Re: failed to open stream warning

2006-01-04 Thread Travis Doherty
zedleon wrote:

Warning: fopen(home/path/temp) failed to open stream: No such file or
directory
I am trying to write a script to work with GnuPG, but can't get past this
basic problem.
Everything I try gives me the same warning.

I just corrected the code...I had it correct but posted it in correctly.

$fp = fopen(home/path/temp w+);
puts($fp, $msg);
fclose($fp);

Still getting the same warning...
  

There is still an error in that code (missing comma) and the error
message also has an unmatched quote.

The actual error message seems clear No such file or directory - does
home/path/temp exist, did you mean /home/path/temp.

Travis

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