Re: [PHP] Convert UTF-8 to PHP defines

2010-05-31 Thread Angus Mann

Dear Sir/Madam

Please unsubscribe Angus Mann angusm...@pobox.com from your database.  My 
husband passed away 6 May 2010.


Thank you
Sonya Mann


- Original Message - 
From: tedd tedd.sperl...@gmail.com

To: php-general@lists.php.net
Sent: Monday, May 31, 2010 12:20 AM
Subject: Re: [PHP] Convert UTF-8 to PHP defines



At 10:20 PM +0200 5/29/10, Nisse =?utf-8?Q?Engstr=C3=B6m?= wrote:

On Sat, 29 May 2010 10:16:39 -0400, tedd wrote:


 At 7:15 AM +0200 5/29/10, Nisse =?utf-8?Q?Engstr=C3=B6m?= wrote:


No. There are no glyphs in Unicode. This is spelled out for
you in chapter 2, figure 2-2. Characters versus Glyphs.



 Code points are simply unique numbers assigned to specific characters
 in an approved char set. To better understand which character is
 represented a representative Glyph is used -- what else would we use,


Right. I should have phrased that differently.


 a chicken?


U+9e21 ? U+540D ?


LOL

I forgot that the word chicken appears in several other languages as a 
single character. Interesting to note that in the Chinese Dictionary, the 
character U+9e21 Chicken (ji) is interchangeable with prostitution.


Cheers,

tedd

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

--
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] Need login suggestions

2010-05-02 Thread Angus Mann

We're building a large site for a school district, to be used by both
students and parents.  When a student logs in, they gain some access to 
the

site, and when a parent logs in, they gain access to other sections on the
site.  That's all fine and dandy, it's the actual registration process 
that

I'm having a hard time with.

How to determine if a registration is a student or a parent.  Do I simply
give them a check box (or other method) to pick from (student or parent) 
and

hope they're being honest?  Has anyone here have to deal with that in the
past, and would you be willing to give me some ideas of what you did?
Thanks!

It sounds like it really doesn't matter how you do it. Nothing bad happens 
if a student registers as a parent or vice-versa and the only person 
inconvenienced is the end-user. I would just take some simple steps to ask 
the person if they want to view as a student or as a parent. Have you 
considered the option of just letting people register, and then allowing 
them to select a radio-button labelled Show me information important to 
parents or Show me information relevant to students or Show me 
information relevant to both.


Some users might quite legitimately want to see both sets of content.

That will be 2 cents, please.





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



Re: [PHP] FPDF passing values into header and footer?

2010-04-26 Thread Angus Mann


- Original Message - 
From: Angus Mann angusm...@pobox.com

To: php-general php-general@lists.php.net
Sent: Monday, April 26, 2010 2:46 PM
Subject: [PHP] FPDF passing values into header and footer?


Hi all. Whilst this question relates to fpdf (www.fpdf.org) I think it 
really is a PHP question, because it involves passing values into classes 
and functions.


Here's the problem .. I need to pass a PHP variable like $number into the 
header of a PDF.

I have extended the FPDF class as follows

class PDF extends FPDF{
   function Header(){
   $this-SetFont('Arial','BU',12);
   $this-Cell(0,5,'User notes for invoice number '.$number,0,'1','L');
   }
}


I hate it when I ask a question prematurely, because I could have figured it 
out myself. Getter and Setter functions are the answer.


function setNumber($number){
   $this-number = $number;
}

$pdf-setNumber('12345');




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



[PHP] Recommendation for online PHP editor please....

2010-04-25 Thread Angus Mann
HI all. I'm looking for a recommendation for an online PHP editor.

Here's what I mean

I mean a PHP program I can install on my web-server, then log in and use it to 
browse and edit other PHP files on the server.

The idea is that I could make changes and bugfixes to a web app while I'm away 
from home/office.

Ideally it would be more than just a text editor, but also have syntax 
highlighting and formatting for PHP built in.

Any recommendations would be much appreciated.

Thanks,
Angus



[PHP] FPDF passing values into header and footer?

2010-04-25 Thread Angus Mann
Hi all. Whilst this question relates to fpdf (www.fpdf.org) I think it really 
is a PHP question, because it involves passing values into classes and 
functions. 

Here's the problem .. I need to pass a PHP variable like $number into the 
header of a PDF.
I have extended the FPDF class as follows

class PDF extends FPDF{
function Header(){
$this-SetFont('Arial','BU',12);
$this-Cell(0,5,'User notes for invoice number '.$number,0,'1','L');
}
}

The problem is, I can't figure out how to pass a value from the rest of the PHP 
script so it can be seen within the function above.

I'm sure the problem is one of the scope of the variable but this sort of thing 
is new to me and I can't figure out the syntax to make it work.

Before anybody suggests something like ...
function Header($number){}
Please recognize that the Header function is called automatically by FPDF and 
not by my code, so unless I totally hack the FPDF class I can't do this easily.

Any suggestions please?

 

Re: [PHP] Does PHP support multi-thread ?

2010-04-18 Thread Angus Mann

Oh No !

Not again !

Please !!

This was the subject of a very long and heated discussion a while ago.
No - it does not support multi threading.


- Original Message - 
From: ttplayer f...@qq.com

To: php-general php-general@lists.php.net
Sent: Sunday, April 18, 2010 11:17 PM
Subject: [PHP] Does PHP support multi-thread ?



Hello, everyone, please answer me. Thank you.
Does PHP support multi-thread ?


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



[PHP] Database design

2010-02-24 Thread Angus Mann
Hi all. I know this is not strictly a PHP question but the code will be written 
in PHP, and I figure the folks here will be well versed in the questions I 
raise. Please feel free to contact me off the list if appropriate.

I need some assistance with database design for a project I'm coding in PHP. 
I'm willing to pay for the advice, since I think it will be a bit complex. I 
plan to use MySQLi

If anybody feels they can assist, or can point elsewhere please feel free to 
contact me off list, or reply to the list if you think appropriate.

Thanks,
Angus

Re: [PHP] Re: UK Project Opportunity

2010-02-17 Thread Angus Mann

This thread's getting a bit tired but here's my $0.02 worth.

I've always found the phpclasses website a bit confusing to navigate and 
I've never had much success finding what I want. But it's free and as a 
non-paying customer I don't feel entitled to complain, when probably a bit 
more work from me would find what I was looking for.


As for advertising, well so what. It's there and my eye is pretty well 
trained to ignore it. No big deal to me, and if it's a necessary thing to 
pay for a free site, then so be it.


The site could do with an easier interface and I look forward to seeing it 
in action, but I think it's a bit too much to complain and swear and 
criticize the owner if you're not paying for what he provides. And if you 
are paying, then you can't honestly say you didn't know what you were 
signing up for. The information is all there if you take the time and 
trouble to find it.


Angus 



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



[PHP] Strange behaviour with str_ireplace()

2010-01-26 Thread Angus Mann
Hi all. I found some unexpected behaviour with str_ireplace.

To summarize, if the $replace term is a number, but formatted as currency with 
trailing zero's (34.50) the function drops the trailing zero.

Example :

$price=34.5;
$message=You owe me #amount#.;
$message1 = str_ireplace(#amount#,sprintf(%01.2f,$price),$message);
$message2 = str_ireplace(#amount#,$.sprintf(%01.2f,$price),$message);


$message1 will yield You owe me 34.4
$message2 will yield You owe me $34.40

So in other words, if the replace term can be interpreted as a number, it will 
be, including truncation of zero's.
I didn't expect this, because as the function name suggests, it's a *string* 
replace.

Fortunately I can just add a $ to the amount and make it work as a string, not 
a number but this would not always be the case.

Is this by design, or is it a bug?



Re: [PHP] Strange behaviour with str_ireplace()

2010-01-26 Thread Angus Mann

Grrr...please ignore.

After battling with this for a while I now can't reproduce the problem.

Apologies for an un-necessary post.

- Original Message - 
From: Angus Mann angusm...@pobox.com

To: PHP-General php-general@lists.php.net
Sent: Wednesday, January 27, 2010 9:02 AM
Subject: [PHP] Strange behaviour with str_ireplace()


Hi all. I found some unexpected behaviour with str_ireplace.

To summarize, if the $replace term is a number, but formatted as currency 
with trailing zero's (34.50) the function drops the trailing zero.


Example :

$price=34.5;
$message=You owe me #amount#.;
$message1 = str_ireplace(#amount#,sprintf(%01.2f,$price),$message);
$message2 = str_ireplace(#amount#,$.sprintf(%01.2f,$price),$message);


$message1 will yield You owe me 34.4
$message2 will yield You owe me $34.40

So in other words, if the replace term can be interpreted as a number, it 
will be, including truncation of zero's.
I didn't expect this, because as the function name suggests, it's a *string* 
replace.


Fortunately I can just add a $ to the amount and make it work as a string, 
not a number but this would not always be the case.


Is this by design, or is it a bug?



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



Re: [PHP] Creating an Entire .html page with PHP

2010-01-25 Thread Angus Mann
- Original Message - 
From: deal...@gmail.com

To: PHP-General php-general@lists.php.net
Sent: Tuesday, January 26, 2010 11:00 AM
Subject: [PHP] Creating an Entire .html page with PHP



Hi Folks,

I would like to create an entire .html page gathered from database 
content mixed with html etc. and be able to save the page...



like:

--- save all this pre made content as .html page

html
head
...  stuff
/head
body
...  stuff
...  stuff with database query results...
...  stuff
/body
/html

Q: Is there a function that might help with saving the whole content  as 
.html page?




Thanks,
deal...@gmail.com
[db-10]


Not really...no. The fact that you're asking this question makes me think 
you should start with a less ambitious goal than you describe. Terms like 
saving the whole content as a .html page and content mixed with html are 
pretty meaningless, I'm afraid.


Try generating a few ordinary pages before you throw a database into the 
mix.



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



Re: [PHP] If the first four characters are 0000, then do {}

2010-01-25 Thread Angus Mann
- Original Message - 
From: John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca

To: PHP-General php-general@lists.php.net
Sent: Tuesday, January 26, 2010 12:36 PM
Subject: [PHP] If the first four characters are , then do {}



I am reading the manual: http://ca.php.net/manual/en/ref.strings.php

$mydata-restored = -00-00;

How do I express this? If the first four characters are , then do {}

What I am looking for is in strpos(), no?

if ()
{
}



if (substr($mydata,0,4) == {
   Do stuff
}


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



[PHP] Speed of sending email .. can I put them in a queue rather than wait?

2010-01-25 Thread Angus Mann
Hi all.

I'm currently using the phpmailer class from phpmailer.worxware.com to send 
datatbase -populated emails to clients.

At the moment I'm runninng PHP on Windows and using the built-in sendmail 
equivalent packaged with XAMPP. It uses a remote SMTP that authenticates by 
prior logging into a POP account.

The number of emails sent is very small. Each one is only sent after a user 
fills out a form and presses send.

But there is a noticable lag of about 5 or sometimes 10 seconds after pressing 
send before the user sees the Mail sent page. I presume the reason for the 
lag is the time spent logging on and off a remote POP, then SMTP server, 
transferring the data etc.

It would be better if this happened in the background - that is, the user could 
get on with doing his next task while the emails sat in a queue in the 
backgorund, being lined up and sent without PHP waiting for the process to 
finish.

Can anybody recommend a good way of doing this? Is Mercury Mail going to help 
me here?



Re: [PHP] corect way to use mail() function

2010-01-11 Thread Angus Mann

There are only 11 types of people in this world. Those that think binary
jokes are funny, those that don't, and those that don't know binary.

ErUmmm.shouldn't that read ...only 10 types of people... ?



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



[PHP] Luhn (modulo 10) check digit calculator

2010-01-05 Thread Angus Mann
Hi all. Perhaps a lazy request, but does anybody have some cut-n-paste code to 
calculate a Luhn check-digit?

It's a check-digit often added to the end of things like credit card or account 
numbers to make detecting typo's a bit easier.

I found lots of code to validate a number once the check-digit is applied, but 
nothing to calculate the digit in the first place.

Thanks in advance !
Angus



[PHP] strtotime - assumptions about default formatting of dates

2009-12-24 Thread Angus Mann
Hi all. I need to allow users to enter dates and times, and for a while now 
I've been forcing them to use javascript date/time pickers so I can be 
absolutely sure the formatting is correct.

Some users are requesting to be able to type the entries themselves so I've 
decided to allow this.

I'm in Australia, and the standard formatting of dates here is DD/MM/ or 
DD-MM-

I recognize this is different to what seems to happen in the US, where it is 
MM/DD/ or MM-DD-

When I process an entered date using strtotime() it seems to work fine.

But of course I am concerned when dates like January 2 come up.

I find that 2/1/2009 is interpreted as January 2, 2009 on my installation, 
which is Windows 7 with location set to Australia.

But can I be sure that all installations of PHP, perhaps in different countries 
and on different operating systems will interpret dates the same?

I can't find much mention of this question online or in the manual.

Any help much appreciated.
Angus


Re: [PHP] Re: strtotime - assumptions about default formatting of dates

2009-12-24 Thread Angus Mann
I wrote a little AJAX gadget which sent the string typed to a PHP backend 
which parsed it using strtotime and then formatting it out again as 
something unamiguous (like 2 January 2009). Then every time the date entry 
field is changed by the user (with an onKeyUp event), this AJAX call is 
triggered and displays the unambiguous form next to the input box, so 
users can see how their entry is being interpreted.
Of course, there's some overhead in the AJAX calls, and it requires 
JavaScript.


If you wanted to do without JavaScript you could do a similar parse-format 
sequence when the form is submitted and show a confirmation page with your 
server's interpretation of the date.


Cheers
Pete


I took this idea and wrote an ajax so that on keyup or blur, the entry is 
sent to PHP which puts it into strtotime() and if a valid result comes out, 
formats it something like Wed January 23, 2008 6:23pm. If the result is 
invalid, it outputs an Invalid message. This is then displayed in a span 
next to the textbox.


So as the user types they can see if what they entered is valid, and also 
see how the date/time will be interpreted. Works beautifully, and makes the 
form very usable.


For what it's worth, here is the code:
The PHP ajax (called judgedatetime.php:
---
$inp=$_REQUEST['a'];
$a=strtotime($inp);
if ($a  1200103200){
$b=Invalid;
} else {
$b=date(D M j, Y g:ia,$a);
}
echo $b;
?


The Javascript
---
function assessdtime(dTime,putHere){
AjaxRequest.get({'url':'ajax/judgedatetime.php',
 'parameters':{'a':dTime},
 'onSuccess':function(req){
  document.getElementById(putHere).innerHTML=req.responseText;
}
})}

And HTML embedded in the page..
---
input type=text size=14 id=start name=start 
onkeyup=assessdtime(this.value,'startreport'); 
onblur=assessdtime(this.value,'startreport');  /
span id=startreportEnter a date and time/span 



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



[PHP] Checking for internet connection.

2009-12-19 Thread Angus Mann

Hi all.

I'w writing a PHP app that is designed to run over a LAN, so internet 
connection for the server is not really essential. Some users may 
deliberately not connect it to the internet as a security precaution.


But I'd like the app to make use of an internet connection if it exists to 
check for an update, and notify the user.


Is there a simple way for a PHP script to check if it has an internet 
connection?


I thought of this :

if(fsockopen(www.google.com, 80)){
   // we are connected
}

Is this OK or is there something better for the purpose?



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



Re: [PHP] Checking for internet connection.

2009-12-19 Thread Angus Mann

Why can't you put the update on the same LAN server that the app resides?

If that is not possible, what about using CURL, and update if it can connect 
successfully, but don't if it cannot?

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

  Since the LAN is remote (many hundreds of miles away) from the source of 
the update, the only practical way to deliver an update every month or week to 
multiple users is to make it available for download from a central update 
server.

  I'm just trying to maximize efficiency by checking if an internet 
connection exists, and abandoning further attempts to check for update 
availability if it does not.

  The idea to use CURL seems valid, but it pre-supposes that I know the 
answer to my own question. To use your suggestion, I'd have to have some 
mechanism to detect if it can connect successfully. I'm asking what that 
mechanism should be, and if the one I've suggested is good, or flawed in some 
way. 



 


[PHP] PHP sessions, AJAX, authentication and security.

2009-11-21 Thread Angus Mann
Hi all.

A question about PHP sessions and their interaction with AJAX.

I have a database containing sensitive information and users need to log in to 
my PHP script and be authenticated before they are granted access.

For one of the forms I would like to retrieve information using AJAX, and some 
of that information is sensitive also. The request from AJAX is handled by 
another, simpler PHP script.

It occurs to me that the AJAX handler could be used to bypass the user 
authentication and a crafted request sent directly to the AJAX handler to get 
information without authentication.

Can anyone offer some advice about how to piggy-back the session/authentication 
data that the user originally used to the AJAX so that only an authenticated 
user will get a valid response from the AJAX handler? I know I could embed 
authentication information into the web-page and send this with the AJAX 
request but I'm interested to know if there are other methods also.

I hope the explanation is clear.

Thanks in advance. 

Re: [PHP] Re: PHP sessions, AJAX, authentication and security.

2009-11-21 Thread Angus Mann

same as everywhere else in your apps.. ajax is no different in any way
at all, not even slightly. as far as PHP and web server is concerned
it's just a plain old request same as any other; thus..

if( !$_SESSION['is_logged_in'] ) {
 exit();
}
// do stuff




Thanks for that. Sometimes the solution is right there in front of you.
The bit of code below does the job nicely for me :

session_start();
if(!isset($_SESSION['username'])){
echo(Go Away.);
exit();
}
// now work with sensitive data...


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



Re: [PHP] tracking forwarded emails using PHP

2009-11-18 Thread Angus Mann
1. Is possible. Google the term web-bug. Be prepared that it will only work 
if the recipient has a HTML enabled email reader AND allows downloading of 
images. Be prepared also that every time the email (including forwarded 
emails) are viewed your server gets a hit. Might equal alot of hits. Just 
embed an image with a unique filename (tiny or invisible if you want) in the 
email and make it's source your server. Then track requests for that image.


2. Is impossible. It just is. The best you could do is track requests for 
the image as in 1 above and notice the different IP addresses, and *assume* 
it was forwarded but there are lots of other explanations other than 
forwarding.



- Original Message - 
From: Angelo Zanetti ang...@elemental.co.za

To: php-general@lists.php.net
Sent: Wednesday, November 18, 2009 6:32 PM
Subject: [PHP] tracking forwarded emails using PHP



Hi all,

I want to develop a newsletter system, where by users can create 
newsletters

and send them to recipients, that's not a problem.

I want to be able to track certain things:

1. When an email is opened. I think this can be done with an img tag where
the src is a php script. We can then track when that script is called and
from whom.

2. Track if the email was forwarded, not sure how this is done but it 
should

be possible any ideas?

I basically need advice on the second point and to know that the first 
point

I am heading in the correct direction.

Please send any links if you wish, that will help.

Thanks in advance.

http://www.elemental.co.za
http://www.wapit.co.za
http://www.chaperonsa.co.za
http://www.tour2africa.com





--
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



[PHP] uniqid() and repetition of numbers generated

2009-11-12 Thread Angus Mann
Hi all. I'm sure I can't be the first person to ask this question but a search 
of the net leaves me confused.

I need a unique identifier in an SQL table and for complicated reasons I don't 
want to use auto-increment.

So I thought I would use a pseudo-random method instead. I am NOT scared of 
people guessing the unique identifier, it just has to be unique in order for 
the database to work properly.

So I looked at the uniqid() function and see it is based on the current time 
in microseconds and when I test it out I see that it increments (very quickly) 
when run repeatedly.

If it is based on JUST the time, then it should repeat every 24 hours, thus 
making collisions possible, which I don't want.

If it is based on the time AND day, then that's fineI can use it.

So here's the problem
When I calculate the number of microseconds since 1970 I get a 16 digit number.
But uniqid() only gives a 13 digit number.
Calculating the number of microseconds in a day gives 11 digits.

So it seems to me that the numbering sequence will repeat every 100 days, which 
risks collisions also.

Can someone explain how uniqid() is really calculated, so I can make a proper 
judgement about how to use it?

Please don't suggest using a hash of a number generated by uniqid(). Hashing a 
small number into a longer one does not add entropy, it just transforms the 
input number, so it does NOT alter the risk of collisions so there is no net 
advantage.

I had a thought to just append the current date to the uniqid() result but I'm 
interested to know if anyone has a more elegant solution.

Thanks in advance.

Angus






Re: [PHP] uniqid() and repetition of numbers generated

2009-11-12 Thread Angus Mann
 Original Message - 
  From: Ashley Sheridan 
  To: Angus Mann 
  Cc: php-general@lists.php.net 
  Sent: Friday, November 13, 2009 8:31 AM
  Subject: Re: [PHP] uniqid() and repetition of numbers generated


  On Fri, 2009-11-13 at 08:22 +1000, Angus Mann wrote: 
Hi all. I'm sure I can't be the first person to ask this question but a search 
of the net leaves me confused.

I need a unique identifier in an SQL table and for complicated reasons I don't 
want to use auto-increment.

So I thought I would use a pseudo-random method instead. I am NOT scared of 
people guessing the unique identifier, it just has to be unique in order for 
the database to work properly.

So I looked at the uniqid() function and see it is based on the current time 
in microseconds and when I test it out I see that it increments (very quickly) 
when run repeatedly.

If it is based on JUST the time, then it should repeat every 24 hours, thus 
making collisions possible, which I don't want.

If it is based on the time AND day, then that's fineI can use it.

So here's the problem
When I calculate the number of microseconds since 1970 I get a 16 digit number.
But uniqid() only gives a 13 digit number.
Calculating the number of microseconds in a day gives 11 digits.

So it seems to me that the numbering sequence will repeat every 100 days, which 
risks collisions also.

Can someone explain how uniqid() is really calculated, so I can make a proper 
judgement about how to use it?

Please don't suggest using a hash of a number generated by uniqid(). Hashing a 
small number into a longer one does not add entropy, it just transforms the 
input number, so it does NOT alter the risk of collisions so there is no net 
advantage.

I had a thought to just append the current date to the uniqid() result but I'm 
interested to know if anyone has a more elegant solution.

Thanks in advance.

Angus





  Auto increment fields are designed to avoid collisions. I can't think of any 
sensible reason for not using them. If you're worried that users of the system 
will think a number like '65' is a 'silly' value for an id, why not pad it up 
with leading zeros, and maybe add in some text from their name or something. To 
me, one unique number is the same as another, whether it has 11 digits or 2. 
Also, without having numbers with many leading zeros in your 11-digit unique 
number, the value range will be dramatically reduced, thereby increasing the 
chance of you running out of unique values.

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


   

Thanks Ashley. To clarify, the reason I don't want to use auto-increment : 
different users with their own populated databases may wish to merge some or 
all of their data. The unique identifier needs to be carried along with the 
rest of the data, hence be unique not only on the database it currently resides 
in ... it still needs to be unique if it gets copied into another person's 
database, and auto-increment will not meet that requirement. I thought that 
using microtime (hence uniqid()) will solve the problem, and the only chance of 
a collision is the unlikely event that by chance, records are added to 2 
different people's databases at EXACTLY the same time, to within an accuracy of 
a millionth of a second. Possible I realize, but very unlikely, given that each 
user will probably add less than 100 entries per day.

On balance I think I will generate an identifier consisting of a few 
things...uniqid() plus a a few letters from the person's name plus a 
(pseudo)random 3 digit number. Probably there's enough entropy in that for my 
purpose.  

But the question still remainswhat exactly is being returned by uniqid() ? 
It is obviously not random, and not a hash function because it increments 
predictably. It's too short to be the number of microseconds since 1970 and too 
long to be the number of microseconds since midnight. Since it has a fixed 
length, and it increments, it will eventually get to the last possible number - 
when will that be, and what will happen - will an extra digit appear or will it 
go back to zero, or will the generating algorithm crash? 

If it's anything similar to the unix timestamp then we're all in trouble on 
January 19, 2038 !











Re: [PHP] uniqid() and repetition of numbers generated

2009-11-12 Thread Angus Mann

Here's part of the confusion:

If you were to express the number of microseconds since 1970 in a
decimal number, it would indeed take 16 digits.

But uniqid() returns a /13 character string/, not a 13 digit number. The
string is actually a hexadecimal number (and thus can express a greater
range of values than a decimal number within those 13 characters).

-John


Ahh! The moment when the penny drops. I was looking at the result as a 
number, not a string.

Solution to problem = use uniqid()



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



[PHP] Strange behaviour with uploaded files .. XAMPP on Windows

2009-10-26 Thread Angus Mann
Hi all. I'm not sure if this is really a PHP question or specific to XAMPP, 
or windows in general...


I have XAMPP including PHP 4.29 running on a Vista machine.

When I use a form to upload a file, using $_FILES['uploadedfile']['name'] 
and move_uploaded-file($_FILES['uploadedfile']['name'], $targetpath) strange 
effects happen.


The file is uploaded to the target directory just as it should.

But when I access this directory as a network share on a different machine, 
the file is not visible.


When I go to delete the file, or the entire uploads folder, the file is not 
deleted, nor the folder. If the folder contains anything I put there 
manually (ie. not uploaded as above) that is deleted, but the uploaded 
content remains.


This reminds me a bit of symbolic links behaviour but I'm really stumped 
if that's the case.


Any ideas?



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



Re: [PHP] PHP Header issue

2009-09-18 Thread Angus Mann
Your code does not make sense (to me anyway).

It flags an error because you are sending HTML before the header command. Don't 
bother looking for whitespace etc...the htmlheadtitle etc is more than 
enough to produce this error.

Using Location redirects to another URL. It does not make sense to redirect 
in the middle of a page.

I think instead of header, you meant to use include or require (same thing.)

Is your intention to include the file advertise2.php in the body section? 
If so, get rid of the header line, and use this :
?php include(..path..to../advertise2.php); ?

Good luck with it!

 
  - Original Message - 
  From: Ernie Kemp 
  To: php-general@lists.php.net 
  Sent: Saturday, September 19, 2009 2:39 AM
  Subject: [PHP] PHP Header issue


   
  html 

  head 

  titleContact Us/title 

  /head 

  body 

  ?php header(Location: advertise2.php); ?

  /body 

  /html

  The above is just snippet of the code but even this simple example throws the 
Header Warning / Error.

   

  Warning: Cannot modify header information - headers already sent by (output 
started at /home/content/g/t/a /html/yourestate/advertise.php:6) 
in/home/content/g/t/a /html/yourestate/advertise.php on line 6

   

  The anwser may be simple but I have looked a blanks or spaces around the 
?php ? with no success.

  Ready need your help.

   

  Thanks,

  Ernie Kemp   

  Phone: 416 577 5565

  Email:   ek...@digitalbiz4u.com

   

  ...man will occasionally stumble over the truth, but usually manages to pick 
himself up, walk over or around it, and carry on.

  Winston S. Churchill 

   

   

   

   


[PHP] Dan Brown

2009-08-16 Thread Angus Mann
Dan Brown is a frequent poster here and developer on the PHP team.
Dan has not posted to the PHP list for quite a while and is not responding to 
my emails directly to him.
Does anyone know if he's OK?
If anyone has knowledge can they please reply to me directly - off list.
Thanks,
Angus

Re: [PHP] PHP 6 and MySQL 5 for Dynamic Web Sites Book

2009-08-06 Thread Angus Mann

Hi all. I monitor this list and occasionally contribute as an amateur so
please forgive a question that might seem terribly obvious to those in the
know.

I'm confused about all this PHP 6 talk. Until now I thought I was right up
there, because I worked with PHP 5.29 and was ready to upgrade to 5.3.

How does it happen that PHP 5.3 has just been released, but books already
exist about PHP 6 ?

I searched google and so on, but still can't really work out how the PHP
development cycle works. Given that PHP 6 exists, does that mean I'm behind
the times working with 5.29 or 5.3?

I only just figured out that I can get the internet on my *computer*. Up
until now I'd just been accessing it with a pencil and paper but the
computer version is so much better! 



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



[PHP] PHP Manual in PDF format

2009-07-07 Thread Angus Mann
Hi all. I realize this question has been asked before and I've found responses 
in the archive, but none of the links work now, or the files they point to are 
old or unsuitable.

I'd like to print the most recent PHP manual to paper, so I need it in a format 
that's suitable. I've downloaded it from php.net in chm and HTML format but 
neither of them can easily be printed with proper attention to page numbering 
and order.

Any idea where to find a PDF or similar version of the manual?

Thanks,
Angus



Re: [PHP] alpha/beta/gamma TO $var['alpha']['beta'] = 'gamma'

2009-06-07 Thread Angus Mann

??? Huh  ???


- Original Message - 
From: דניאל דנון danondan...@gmail.com

To: PHP General List php-general@lists.php.net
Sent: Sunday, June 07, 2009 8:11 PM
Subject: [PHP] alpha/beta/gamma TO $var['alpha']['beta'] = 'gamma'



I have encountered a problem when trying to turn

--
Use ROT26 for best security




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



Re: [PHP] Directing form to different handlers?

2009-06-01 Thread Angus Mann

Thanks to all posters for their input.

For what it's worth, I'm writing a PHP application for a very specific 
purpose of running my office billing etc so I have total control over the 
JavaScript settings for users. The entire application would break without JS 
so if they turn JS off, all they get is a page telling them to turn it back 
on.


I know I could direct all form submissions to one handler, and easily figure 
out which button was actually used to submit the form and use a SWITCH, but 
I like the idea of having the code in smaller segments. It makes it easier 
for me to find what I'm looking for. Just a personal preference.


I actually found some nice JS to change the form action dynamically using by 
using the button to set the value of  the variable handler to edit.php 
or delete.php etc etc


document.myform.action = handler;
document.myform.submit();

Thanks again.
Angus


- Original Message - 
From: Matthew McKay m...@mattmckay.org

To: php-general@lists.php.net
Sent: Tuesday, June 02, 2009 5:32 AM
Subject: Re: [PHP] Directing form to different handlers?


It would be much simpler and cleaner to use Javascript to modify the 
form's

action attribute onClick.



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



[PHP] Web application design considerations - a good reference ?

2009-06-01 Thread Angus Mann

Hi all.

I'm working on a PHP project for my own personal business use. It will 
handle billing and invoices as well as payments and time management, 
bookings, appointments and a few more. I may add things like personal 
messaging between the various users and a customer login to check on the 
progress of their accounts.


It is a big project and will probably take a year or so to complete in my 
spare time.


I have made a couple of starts but I have no experience in creating such 
large applications and I find I often end up with spaghetti code. I've tried 
using session variables to keep track of where and what the program is doing 
but there are so many permuations and combinations I found myself writing 
endless streams of if's, and's and or's just to figure out what page to 
display.


The code is not the probblem for me...it's the flow and organization of the 
code.


Can anybody point me to a good book or tutorial that lays down the 
principles and gives some suggestions for integrating the many subroutines 
of a large application? I want to make the code readable and logical in its 
flow, and avoid repetition of code segments.


Much appreciated.
Angus






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



[PHP] Directing form to different handlers?

2009-05-31 Thread Angus Mann
Hi all. I realize this is more an HTML question than PHP but I'm sure someone 
here can help.

I have several forms with lots (dozens) of text inputs. If the user presses the 
Update button I want the form handled by update.php but if they press 
Delete it needs to be handled by delete.php or add.php and so-on 
depending on the button they press.

But when establishing the form I can only have form method=POST 
action=delete.php or add.php or whatever.

Is there a way to direct the content of the form do a different handler 
depending on the button?

I know I can use javascript to direct to a constructed URL and append 
?name=smithaddress=hishousetelephone=28376.and so on but this is not 
practical when there are dozens of entriesthe URL becomes massive. I prefer 
to use POST and then use PHP to extract the POST array.

Any ideas?

Much appreciated.
Angus


[PHP] Button id's - firefox and IE different ?

2009-04-02 Thread Angus Mann
Hi all.

I want to have several delete buttons with just one form, and depending on 
which button is pressed, one of several items is deleted.

So I need multiple submit buttons for 1 form, each displaying the same text 
Delete to the user, but each with a different value so the PHP script can 
tell them apart.

I've used this code for the buttons...
centerbutton type=submit name=btid value=1Delete/center
centerbutton type=submit name=btid value=2Delete/center
centerbutton type=submit name=btid value=3Delete/center

And it works just fine with firefox. But IE does not seem to pass the value 
back to the btid so when the script asks 
if $_POST['btid'] == 1 {
}

the value 1, 2, or 3 is not given back to PHP by IE. It is given back correctly 
by firefox and works fine.

Any suggestions ?

Thanks.



Re: [PHP] Button id's - firefox and IE different ?

2009-04-02 Thread Angus Mann
I can do as you suggest below, but then the buttons are labelled Delete 
Cancel and Save to the user.


The essential point is that they all need to say Delete. I know I can 
accomplish this by making multiple forms, each with its own button but for 
my purpose that's a pain is the ***.


IE returns the text displayed in the button regardless of the btid value. 
It seems to just ignore it.


Firefox returns the value assigned to btid as I intended regardless of the 
text in the button that the user sees.




- Original Message - 
From: Richard Heyes rich...@php.net

To: Angus Mann angusm...@pobox.com
Cc: php-general@lists.php.net
Sent: Thursday, April 02, 2009 8:17 PM
Subject: Re: [PHP] Button id's - firefox and IE different ?



Any suggestions ?


Try this:

input type=submit name=btid value=Delete /
input type=submit name=btid value=Cancel /
input type=submit name=btid value=Save /


And then you can check the value of $_POST['btid']. Oh and btw...
center... seriously?
That's so 9 years ago. ;-)

--
Richard Heyes

HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.net (Updated March 28th)

--
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



[PHP] foreach and form submission.

2009-03-28 Thread Angus Mann
Hi all.

I'm writing a script that accepts several different forms with different 
content. Depending on what data is sent with the form the script will do one or 
the other think.

Before the form data is processed I'd like to scrub it of HTML tags.

I can do this manually as below but the form may have dozens of items of data 
so I'd like to automate it.

$_POST['name'] = strip_tags($_POST['name']);
$_POST['address'] = strip_tags($_POST['address']);
$_POST['phone'] = strip_tags($_POST['phone']);

I saw a few lines of code once that used foreach  on the $_POST array 
elements and it did not seem to matter how many or what names the elements had.

Conceptually like this

foreach ($_POST - element) {
$_POST-element = strip_tags($_POST-element)
}

Any ideas please ?

Thanks.


Re: [PHP] foreach and form submission.

2009-03-28 Thread Angus Mann

Thanks Ashley...that did the trick.
After reading about the limitations of strip_tags I decided to just replace 
the bad bits as below...
It still uses your foreach suggestion but replaces  and  with ( 
and ) instead of stripping tags.


I think I will extend the good and bad arrays to deal with magic quotes also 
!


$bad = array('','lt;','#60;', '', 'gt;', '#62');
$good = array('(', '(', '(', ')', ')', ')');
foreach ($_POST as $key = $value) {
$_POST[$key] = str_ireplace($bad, $good, $value);
}






I'd do something like this, so as to preserve the original post data
array:

$data = Array();
foreach($_POST as $key = $value)
{
   $data[$key] = strip_tags($value);
}

Note that strip_tags() will not be able to decently clean up messy code
(i.e. code where the opening or closing tags themselves aren't formed
properly)


Ash
www.ashleysheridan.co.uk





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



[PHP] Proper code formatting

2009-03-23 Thread Angus Mann

Hi all, I'm fairly new to PHP so I don't have too many bad habits yet.

I'm keen to make my code easy to read for me in the future, and for others 
as well.


Are there any rules or advice I can use for formatting (especially 
indenting) code?


for example how best to format / indent this ?

if ($variable = 'this')
{
do this;
and this;
}
else
{
if ($name = 'bill')
{
do something will bill;
and something else with bill;
}
else
{
assume its not bill;
and do the fred thing;
}



I'm using PHP designer 2008 which does syntax coloring but if it has 
something to automatically indent - I haven't found it yet.




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



Re: [PHP] Pricing for PHP programming???

2001-02-01 Thread Angus Mann

At 11:54 1/02/2001 -0800, Terrence Chay wrote:
 We should be prudent when discussing how much we charge for programming.
I'm no lawyer but I believe it's okay to discuss hypotheticals, histories,
and such, but remember that discussing wage rates may run against anti-trust
regulation as evidence of collusion (at least in the United States).

You'd better tell the unions that.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Compiler? (Was Re: [PHP] PHP site on CD-ROM)

2001-01-25 Thread Angus Mann

At 22:35 18/01/01 -0800, Rasmus Lerdorf wrote:

You would need to go through a web server for it to work.

I seem to recall seeing something on the Zend site a while back about a 
"compiler" for PHP that was in the pipeline. After the store was launched I 
can't find anything. Am I imagining things, or does it look like Zend 
pulled the plug? Did anyone else in here see it? :)

Thanks,

Angus.



On Fri, 19 Jan 2001, Philip Apostol wrote:

  Can I run a PHP/Apache/MySQL services on a CD-ROM.  We have PHP scripts 
 that
  handle queries on a large database.  We would like to distribute it on a
  CD-ROM so they could access the database offline.  Is it possible? Or are
  there any similar solutions for this?  Im thinking of a text-file database
  and access it via javascript but have no much time to study on 
 this.  If php
  can be run on the cd-rom, that would be a better solution.   But any
  solution you posted here will be highly appreciated.  Thanks in advance.
 
  Philip


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] (Newbie) String within a string

2001-01-19 Thread Angus Mann

At 13:48 18/01/01 +, jalist wrote:
I'm trying to grab a string from within a string based on a matching word or
phrase. Example...

$string = "This is a string I need to grab the middle out of"
$query_word = "need"

I need to get x amount of characters either side of $query_word, so the
result string would be like...

"string I need to grab the"

And I need the result string to be full words, not like..."ing I need to
grab th"

I've half managed to do it using strpos and substr but the code is really
messy and I'm getting half-formed words back. Anyone got any suggestion on
how to accomplish this?

Thanks very much in advance.

I'd suggest using regular expressions (ereg, or preg_match). It's a little 
too early in the morning on a weekend for me to come up with the best 
example of what would work, sorry :)

Angus.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] identifying clicked link?

2001-01-17 Thread Angus Mann

At 23:10 17/01/01 -0500, andrew wrote:
How can I pass an anchor tag attribute to a page?
e.g. If I want to echo "1" on page_two:


page_one.php contains:

a href="page_two.php"  ? $id="1"?click/a

All you're doing there is setting the variable id to "1". You're not even 
printing it.

page_two.php contains:

? echo($id); ?

but page_two is coming up blank after a delay... what I am doing wrong?

Alot :)

You have to use forms if you want to pass variables along between pages, 
unless you use cookies or PHP4 sessions (which use cookies).

You could use standard URL anchors for moving between pages and passing 
variables along - they'd have to be GET type. e.g.

page_one.php would be: (although it could be shortened or formatted 
differently)

?php
// Below: Set the variable id to 1.
$id  = "1";
// Below: append the id as a GET variable to the url.
echo "a href=\"page_two.php?id=$id\" click /a";
?

and page_two.php would be:

?php
// Below: Make sure that id was actually appended to the URL in page_one.php
if(isset($HTTP_GET_VARS["id"]))
{
// Below: If it was there, set it as a variable
$id = $HTTP_GET_VARS["id"];
echo "$id";
}
?

I suggest you read through the PHP manual some more, especially the section 
on Variables, and the sub-section "Variables from outside PHP" 
(http://www.php.net/manual/en/language.variables.external.php). It would 
also be a good idea to read through some tutorials from some PHP websites, 
such as:

http://www.phpbuilder.com/
http://www.phphelp.com/

Those two should also have some links to other sites.

Good luck!

Angus.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Regex for telephone number

2001-01-15 Thread Angus Mann

At 17:55 15/01/01 +0500, Vikram Vaswani wrote:
Hi!

Can someone help me out with a regex to validate a phone number?

We'd need to know what format of telephone numbers you're looking to 
validate, first.

Angus.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]