php-general Digest 10 Jun 2006 09:22:28 -0000 Issue 4177

2006-06-10 Thread php-general-digest-help

php-general Digest 10 Jun 2006 09:22:28 - Issue 4177

Topics (messages 237711 through 237732):

Re: Skip first 4 array values
237711 by: Richard Lynch

Re: substring with numric values
237712 by: Richard Lynch

Re: mail() function dying half way through.
237713 by: Richard Lynch

Re: transfer file
237714 by: Richard Lynch

Re: remove last comma in string
237715 by: Richard Lynch
237717 by: Paul Novitski
237719 by: Richard Lynch

Re: order of elements in $_POST super global
237716 by: Richard Lynch
237718 by: Richard Lynch
237720 by: Richard Lynch

Re: server sending notifications to clients
237721 by: Richard Lynch

Re: running php method in the background
237722 by: Richard Lynch

Using php4 to manage Apache 1.3 access database
237723 by: Doug Carter

Re: Session puzzle... / why no new session?
237724 by: chris smith

Re: Tables vs. databases
237725 by: chris smith
237729 by: Lester Caine

How to re-order an array
237726 by: jekillen

How to tell if a socket is connected
237727 by: Michael W.

Mail sending program (beginner)
237728 by: aci india
237730 by: Rabin Vincent
237731 by: benifactor

1,600,000 ÃÒª×èÍÍÕàÁÅì ¤Ñ´ÊÃÃàÃÕ§ÅӴѺÍÑ¡ÉÃÊдǡÊÓËÃѺ¢ÂÒ¸ØáԨ¢Í§·èÒ¹ 
¾ÃéÍÁ·Ñé§á¶Áâ»Ãá¡ÃÁ·Ñ¹ÊÁѨҡµèÒ§»ÃÐà·ÈÍÕ¡ËÅÒÂÍÂèÒ§ ÃÒ¤Ò¶Ù¡ÁÒ¡ËÒäÁèä´éÍÕ¡áÅéÇ 
¨Ó˹èÒ¨ӹǹ¨Ó¡Ñ´
237732 by: 1,600,000 ÃÒª×èÍÍÕàÁÅì 
¤Ñ´ÊÃÃàÃÕ§ÅӴѺÍÑ¡ÉÃÊдǡÊÓËÃѺ¢ÂÒ¸ØáԨ¢Í§·èÒ¹ 
¾ÃéÍÁ·Ñé§á¶Áâ»Ãá¡ÃÁ·Ñ¹ÊÁѨҡµèÒ§»ÃÐà·ÈÍÕ¡ËÅÒÂÍÂèÒ§ ÃÒ¤Ò¶Ù¡ÁÒ¡ËÒäÁèä´éÍÕ¡áÅéÇ 
¨Ó˹èÒ¨ӹǹ¨Ó¡Ñ´

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
php-general@lists.php.net


--
---BeginMessage---
 Jonas Rosling wrote:

Is there any way you can skip for example the first 4 array
 values/posisions
in an array no matter how many values it contains?

http://php.net/array_slice


-- 
Like Music?
http://l-i-e.com/artists.htm
---End Message---
---BeginMessage---


$int = (int) $value;

On Fri, June 9, 2006 2:51 am, Jonas Rosling wrote:
 Is there any easy way to trim or pick out the none decimal values in
 a
 numric value? Like:

 1,333 = 1
 5,667 = 5
 12,145 = 12
 15,997 = 15

 Thanks // Jonas



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




-- 
Like Music?
http://l-i-e.com/artists.htm
---End Message---
---BeginMessage---
On Fri, June 9, 2006 12:59 am, Dave M G wrote:
 I have a database of about 120 users. Each weak I send out a
 newsletter.
 So far as I know, it's been working fine for the last couple of years.

 Then recently some users emailed me to let me know that they haven't
 been receiving all the messages. I added extra output to my script to
 echo out the name of each member that got an email sent to them, and I
 can now see that only about 50 of them are getting the email.

 The only think that has changed that I can think of is that I've
 upgraded to MySQL 5.0. However, given the type of problem I'm having,
 I
 don't think it's a MySQL problem, it appears much more likely to be a
 problem with my PHP code.

 This is the script that sends out the message (edited slightly to take
 out irrelevant bits of newsletter content):

 - - - -
 $count = 0;
 while ( $member = mysql_fetch_row($result) )
 {
 set_time_limit(0);
 $subject = Newsletter subject line;
 $mailcontent = This message was sent to  . $member[0] .  at
 {$member[1]}
 Blah, blah, blah - newsletter content goes here.;
 mail($member[1], $subject, $mailcontent, $fromaddress);

mail() returns a value to indicate if it failed/succeeded in queueing
up the email.

Check it.

Also, every call to mail() fires up a sendmail process.

This is expensive.

maybe sleep(1) in between calls

or consider switching to SMTP

or sending ONE email with a Bcc...  Though that has a slightly higher
probability of being labeled as spam.

 $count++;
 echo pNewsletter sent to  .  $member[0] .  at  . $member[1] .
 /p;
 }
 echo pA total of  .$count . emails were sent out./p\n;
 - - - -

 The script actually dies before it gets to the last echo which echoes
 the value of $count. It outputs about 50 lines of Newsletter sent to
 usersname at [EMAIL PROTECTED] and then the cursor is stuck in hourglass
 mode and the browser is continually waiting a response. It stays like
 that indefinitely, and the only way it stops is if I go to another
 page
 or shut down the browser.

 I have heard that the mail() function does have limitations on how
 many
 emails it sends out. But I thought it took hundreds, somewhere between
 500 and a thousand, of individual emails before it would die. And I
 also
 thought the set_time_limit(0) function would alleviate the problem of
 timing out.

 Where have I gone wrong 

php-general Digest 11 Jun 2006 00:22:39 -0000 Issue 4178

2006-06-10 Thread php-general-digest-help

php-general Digest 11 Jun 2006 00:22:39 - Issue 4178

Topics (messages 237733 through 237745):

Curio
237733 by: Dave Goodchild
237737 by: Jay Blanchard
237739 by: tedd

$B$$s$?!B;$7$F$k$h!#(B
237734 by: saki

$B#1#0?M$r?)$($?!$*$$$7$#%5%$%H!*!*!*(B
237735 by: rika

Re: Restrict uploaded scripts
237736 by: Mathias Bundgaard Svesson

Re: Mail sending program (beginner)
237738 by: tedd

Re: Session puzzle... / why no new session?
237740 by: Ryan A

HTML (php page) - PDF recommendation
237741 by: Ryan A
237743 by: Frank Arensmeier

Re: Tables vs. databases
237742 by: tedd

Re: order of elements in $_POST super global
237744 by: Ben Liu

Re: How to re-order an array
237745 by: Rafael

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
php-general@lists.php.net


--
---BeginMessage---

Just a question out of curiousity for the language lawyers out there. Why is
it illegal to begin a variable name with a number in php?

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

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!
---End Message---
---BeginMessage---
[snip]
Just a question out of curiousity for the language lawyers out there.
Why is
it illegal to begin a variable name with a number in php?
[/snip]

This is fairly standard in programming languages. Years ago (sometime in
the 70's) the reasoning was given to me, but I have long since replaced
the data at that address with some other, probably trivial, fact. I
tried a quick Google, but no joy.
---End Message---
---BeginMessage---
At 11:31 AM +0100 6/10/06, Dave Goodchild wrote:
Just a question out of curiousity for the language lawyers out there. Why is
it illegal to begin a variable name with a number in php?


I don't know why in they do it in php, but I would guess that it's one of those 
legacy things.

Back when I was programming with rocks, a language called FORTRAN came along 
(before FORTRAN started having Roman Numerals after its name).

The rules of this new language was that integers could only start with the 
letters I, J, K, L ,M, N (hence our custom to use $i , $j, $k for loops) and 
all other real number could start with any other character but those, and could 
not start numbers -- however, both variables could contain numbers but were 
limited to just six letters total. (But note we didn't have to start variables 
with a $ ).

As far as strings were concerned -- what the hell were those? If you wanted to 
print something, you use a FORMAT statement and therein you might find syntax 
that could start with a number, such as 4F5.0, but that was just to format a 
number for print -- it had nothing to do with a variable name.

In defense of the decision of the time, I doubt that many of you remember IBM 
punch cards (one card for every line of code in your program) but it was a 
*great* deal easier to review and edit your stack of code if you kept numbers 
and letters separate with different meanings.

So, my guess is it's legacy.

My question to you is, what are you passing on that in 40 years some young 
programmer will ask Why is it illegal to...  :-)

tedd

-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com
---End Message---
---BeginMessage---
最近セフレを探す女の子が増えました!
その響きだけ聞けば「なんだかなぁ」って思う人もいると思います。
でも、実際は大多数の人とセックスをしないようになるので衛生的ですし、
恋人だと少々重く感じる人がいるからこういう関係が成り立つわけで、
一緒に買い物にいったり、映画を見たり、恋愛相談をできたりする
「仲のいい友達感覚」でお付き合いしている方が多いみたいです。
お互いの欲望を満たしあえる友達 . . . 。
いけない事なんてなにもない!!
あなたもここで素敵なお相手を見つけてください!!
http://vqlh.com/?hy04







拒否
[EMAIL PROTECTED]




---End Message---
---BeginMessage---
ユーザー体験人気NO.1サイト!女性会員が日本最大級の圧巻サイトです。

恋人、不倫、セフレ、目的に沿って募集が可能。約60%程の女の子が写真を掲載している。

完全無料登録サイト
お試しあれ
http://vqlh.com/?hy03








拒否
[EMAIL PROTECTED]




---End Message---
---BeginMessage---
Would it then be posible to restrict it in some other way, for example
using chroot? Or do I just have to make sure that the modules come from
a source that I trust or look through the code?

fre, 09 06 2006 kl. 10:47 -0400, skrev Jim Moseby:
  
  Wouldn't it even be posible, if the script couldn't be run 
  directly, but
  had to be run through require or something like that?
  
 
 Require just includes the code inline.  It still runs on the webserver as
 the server user as if it were one big script.  I think you would have to
 sanitize the uploaded code before allowing it to run.  Writing the
 sanitation algorithm to perform such a task would be a nightmare.
 
 JM
---End Message---
---BeginMessage---
At 10:54 AM +0530 6/10/06, aci india wrote:
Dear group,

Description:

Following is the code which I tried 

Re: [PHP] Tables vs. databases

2006-06-10 Thread Lester Caine

Antonio Bassinger wrote:

I've a HTTP server. I intend to run a file upload service. There could 
be up

to 1 subscribers. Each saving files up to 10 MB.

I made a proof-of-concept service using PHP  MySQL, where there is a 
single

database, but many tables - a unique table for each subscriber. But I
realize that I may land in trouble with such a huge database. Would it be
better to have a separate database for each subscriber?

Which approach is better, many tables in 1 database, or many databases with
1 or max 2 tables?

Kindly suggest with pros and cons of each.


Take a look at bitweaver
www.bitweaver.org
Fully operational user management and file upload with management that 
allows it to be fully scalable.

It will give you some practical examples at least ;)

--
Lester Caine - G8HFL
-
L.S.Caine Electronic Services - http://home.lsces.co.uk
Model Engineers Digital Workshop - 
http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/

Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php

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



Re: [PHP] Mail sending program (beginner)

2006-06-10 Thread Rabin Vincent

On 6/10/06, aci india [EMAIL PROTECTED] wrote:

NOTE: Sorry for the very long code


Please paste long code snippets in a website like
pastebin.com. Also, the code is hard to read because
of the complete lack of indentation.

I suggest you atleast attempt to debug your code before
posting it here. Sprinkle echo or var_dump statements
throughout your code and try to find out where the problem
is. Make liberal use of the documentation at php.net/manual.

I have placed some comments inline, and pointed
out your infinite loop.


the mail.php file:

^^^

?php

/*mail body file*/

function cnd($fname)

{

$fil = fopen($fname,r);

if(!$fil)

die(fopen error);

while(!feof($fil))

$buffer = fgets($fil);

while($buffer != NULL)

{

if($buffer == \n.) /*a line should not start with .*/


What is this? You are checking if the whole string is
equal to \n., which I think will never happen.

You probably want $buffer{0} == '.'/


$buffer = str_replace(\n.,\n.., $buffer);


As above.


if($buffer == \n  $buffer  70) /*should be less than 70*/


What is this supposed to be? You are checking if
the line is empty, and then checking if it is greater
than 70? And you probably mean strlen in the second
part of the if.


$buffer = '\n';

}

fclose($fil);

return $buffer;

}

/*mail sub file*/

function sub($fname)

{

$fil = fopen($fname,r);

if(!$fil)

die(fopen err in sub file);

while(!feof($fil))

$buff = fgets($fil);

while($buff != NULL)

{

if($buff  15)


strlen here too. Strings don't magically give out their
length.


{

?

script language=javascript

alert(the subject line should not be less than 15, pls check the sub.txtfile);

/script
?php

}

}

fclose($fil);

return $buff;

}

function fetch_names()

{

$var = mysql_connect(localhost,root,);

if(!$var)

die(could not connect.mysql_error());

$db = mysql_select_db(sathya_clon,$var);

if(!$db)

die(could not find the data base.mysql_error());

$result = mysql_query(select name from users,$var) or die(unable to fetch
rows);

$rows = mysql_fetch_array($result);

while($rows)

{


Here's your infinite loop. Review the docs on how to
iterate through returned rows. php.net/mysql_query.



for($i=0; $i= $rows ; $i++)

for($j=0;$j = i-1 ; $j++)

$names[$i] = $rows[$j];

}

return $names;

}

function fetch_emails()

{

$var = mysql_connect(localhost,root,);

if(!$var)

die(could not connect.mysql_error());

$db = mysql_select_db(sathya_clon,$var);

if(!$db)

die(could not find the data base.mysql_error());

$result = mysql_query(select email from users,$var) or die(unable to
fetch rows);

$rows = mysql_fetch_array($result);

while($rows)

{


One more infinite loop.



for($i=0; $i= $rows ; $i++)

for($j=0;$j = i-1 ; $j++)

$email[$i] = $rows[$j];

}

return $email;

}

$var = mysql_connect(localhost,root,);

if(!$var)

die(could not connect.mysql_error());

$db = mysql_select_db(sathya_clon,$var);

if(!$db)

die(could not find the data base.mysql_error());

$name = $_POST['user_name'];

$mail = $_POST['user_email'];

$db_q = mysql_query(insert into users values('$name','$mail'));


This is open to SQL injection attacts. See
php.net/mysql_real_escape_string and phpsec.org


if(!$db_q)

die(mysql error);

$condt = cnd(cond.txt);

$sub = sub (sub.txt);

$name = fetch_names();

$email = fetch_emails();

$mail_stat = mail($email,$sub,$condt,from:[EMAIL PROTECTED]);

if($mail_stat == NULL)


mail doesn't return NULL. php.net/mail.


echo mail sent failed;

else

echo mail sent sucess. Pls check for mail for further acction;

?
==code ends


Rabin

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



Re: [PHP] Mail sending program (beginner)

2006-06-10 Thread benifactor
i don't really understand what your trying to do here but if im correct
there is a much easier way...

if you are trying to make a newletter sign up this is simple. there is no
reason to send the email to the database simply have the enter thier email
address, use regex to check it, if it passes that test, send it and a uniqe
conformation number to a database, and use mail() to send them the
conformation information with the link to the confirm page.  they then click
on the link to confirm.php or whatever and it will check the database for
that email or number... if they are both there and the both match it will
erase it from the confirm database and send the info to the newsletter
database. i will give you an example...

//start index.php or news_signup.php or something of the sort...
?php
//first we define the function for the email check...

 function is_valid ($email) {

  if
(eregi(^[_a-z0-9-]+(\.[_a-z0-9-]+)[EMAIL 
PROTECTED](\.[a-z0-9-]+)*(\.[a-z]{2,3})
$, $email)) {

  return true;

  }
 }
//check to see if the signup form button was pressed and perform tests on
the form data..

 if ($HTTP_POST_VARS[ADD_USER]) {
  if (!$HTTP_POST_VARS[email]) {
   $e = error! you must enter your email address!;
  }
  else {
  if (!is_valid($HTTP_POST_VARS[email]) {
   $e = error! your email address is invalid!;
  }
  else {
   //all the tests passed at this point, so we make that conf # i talked
about...
   $conf = uniqid(nuser);
   //now we eneter all the information in to a database called add that has
three feilds.. auto_increment id. email. confid.
   mysql_query(insert into add (id, email, confid) VALUES (null, '$email',
'$conf'));
   //now we send the email
   $to  = $email;
   $subject = 'Your Newsletter subscription...';
   $message = Hello $email, your registration is almost complete! all you
have to do now is confirm your registration. to do this simply click on this
link: a
href=\http://yoursite.com/newsletter/confirm.php?confid=$conf\;Complete
Registration Now/a or, copy and paste this into your web browser:
www.yoursite.com/newsletter/confirm.php?confid=$conf brbrbPlease Note:
your resgistration will expire in exactly 24 hours from when you clicked the
register button, so please confirm your registration now!/b;
   $message = wordwrap($message);
   $headers = 'From: [EMAIL PROTECTED]' . \r\n;
   $headers  .= 'MIME-Version: 1.0' . \r\n;
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n;
   mail($to, $subject, $message, $headers);
   $e = congratulations you have signed up! You should recieve an email
shortly to confirm.;

  }
  }
  }
  else {
  //now we actually display the form
?

form method=post action=whateveryoucallit.php
email:br
input type=text name=email value=?php echo($email); ?
length=35br
input type=submit name=ADD_USER value=SIGN UP!
/form

?php
//now we wnd the orginal php block
}

//now we dipslay the error message if there was any...

if ($e) {
echo($e);
}

?

this is the whole first page. simple. not too many languages. now the
confirm page.


//start confirm.php or whatever.

?php
//first we make sure they got to this page by email, making sure the
variable $conf is set
if (!$conf) {

 $e = (Sorry, you must have an id in order to complete the registration...
please click on or copy and paste the link from your email into your web
browser.. thank you - staff);
}
//now we make sure that the confid is in the database
else {
$cc1 = mysql_query(SELECT * from add where confid = '$conf') or
die(mysql_error());
$ccc1 = mysql_fetch_array($cc1);
if (!$ccc1) {
$e = (Sorry, The id you have enterd does not match any of our records...you
may have already confirmed your email - staff);
}
//grab the data where the ids match and enter the in to the new database
else {
$query = mysql_query(select * from conf where confid = '$conf');
while ($d = mysql_fetch_array($query)) {
$email = $d[email];
mysql_query(insert into users (id, email) VALUES (NULL, '$email')) or
die(mysql_error());
//delete from the conf database
mysql_query(delete from conf where conf = '$confid') or
die(mysql_error());
$s = (Congratulations b$email/b, you have successfully signedup... you
will now get our monthly emails...);
}
}
}
}
if ($e) {
echo(bcenter$e/b/center);
}
if ($s) {
echo(bcenter$s/b/centerbrbcenter$s1/b/centerbrcenter
bYou will now be redirected to login.../b/center);
}
?

this is not perfect, but should give you an idea of what your doing and a
different way (possibly better) of doing this.

- Original Message - 
From: aci india [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Friday, June 09, 2006 10:24 PM
Subject: [PHP] Mail sending program (beginner)


 Dear group,

 Description:

 Following is the code which I tried for learning propuses. It is a mail
 sending program

 which checks weather the user enters a correct mail id If he enters the
 correct mail ID then

 user name and e-mail will get stored in the mysql data base table. After
 getting stored

 then mail will sent to the 

[PHP] 1,600,000 ��ª��������� �Ѵ������§�ӴѺ�ѡ���дǡ����Ѻ���¸�áԨ�ͧ��ҹ ��������������������ѹ���¨ҡ��ҧ�������ա�������ҧ �ҤҶ١�ҡ���������ա���� ��˹��¨ӹǹ�ӡѴ

2006-06-10 Thread 1,600,000 ��ª��������� �Ѵ������§�ӴѺ�ѡ���дǡ����Ѻ���¸�áԨ�ͧ��ҹ ��������������������ѹ���¨ҡ��ҧ�������ա�������ҧ �ҤҶ١�ҡ���������ա���� ��˹��¨ӹǹ�ӡѴ
1,600,000 ÃÒª×èÍÍÕàÁÅì ¤Ñ´ÊÃÃàÃÕ§ÅӴѺÍÑ¡ÉÃÊдǡÊÓËÃѺ¢ÂÒ¸ØáԨ¢Í§·èÒ¹ 
¾ÃéÍÁ·Ñé§á¶Áâ»Ãá¡ÃÁ·Ñ¹ÊÁѨҡµèÒ§»ÃÐà·ÈÍÕ¡ËÅÒÂÍÂèÒ§ ÃÒ¤Ò¶Ù¡ÁÒ¡ËÒäÁèä´éÍÕ¡áÅéÇ 
¨Ó˹èÒ¨ӹǹ¨Ó¡Ñ´
µÔ´¨ÃÇ´ãËé¸ØáԨ¢Í§·èÒ¹´éÇ¡ÒûÃЪÒÊÑÁ¾Ñ¹¸ì¸ØáԨ·Ò§ÍÕàÁÅì 
â´Âµé¹·Ø¹·ÕèµèÓáÅмŵͺÃѺ·Õè´Õ·ÕèÊØ´
´éÇÂÍÕàÁÅì 1.6 ÅéÒ¹àÁÅì 
á¶Áâ»Ãá¡ÃÁ
- Êè§àÁÅì¤Ø³ÀÒ¾ÊÙ§¨Ò¡µèÒ§»ÃÐà·È µÑÇàµçÁãªé§Ò¹ä´éµÅÍ´ 
- â»Ãá¡ÃÁ´Ù´àÁÅì¤Ø³ÀÒ¾ÊÙ§¨Ò¡µèÒ§»ÃÐà·È µÑÇàµçÁãªé§Ò¹ä´éµÅÍ´ 
- µÑÇ¡ÃͧÍÕàÁÅì ¤Ø³ÀÒ¾ÊÙ§¨Ò¡µèÒ§»ÃÐà·È µÑÇàµçÁãªé§Ò¹ä´éµÅÍ´ 

ÇÔ¸Õ¡ÒèѴÊè§ÊÔ¹¤éÒ Êè§ EMS ·èÒ¹¨Ðä´éÃѺÊÔ¹¤éÒÀÒÂã¹ 1-2 Çѹ
ËÃ×Í ´ÒǹìâËÅ´ÀÒÂã¹ 1-2 ª.Á. ãªéä´éàÅÂ

ÃÒ¤Ò 790 ºÒ·
ʹã¨â·Ã 06-7815050
ÍÕàÁÅì  [EMAIL PROTECTED]

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



[PHP] Curio

2006-06-10 Thread Dave Goodchild

Just a question out of curiousity for the language lawyers out there. Why is
it illegal to begin a variable name with a number in php?

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

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!


RE: [PHP] Restrict uploaded scripts

2006-06-10 Thread Mathias Bundgaard Svesson
Would it then be posible to restrict it in some other way, for example
using chroot? Or do I just have to make sure that the modules come from
a source that I trust or look through the code?

fre, 09 06 2006 kl. 10:47 -0400, skrev Jim Moseby:
  
  Wouldn't it even be posible, if the script couldn't be run 
  directly, but
  had to be run through require or something like that?
  
 
 Require just includes the code inline.  It still runs on the webserver as
 the server user as if it were one big script.  I think you would have to
 sanitize the uploaded code before allowing it to run.  Writing the
 sanitation algorithm to perform such a task would be a nightmare.
 
 JM

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



RE: [PHP] Curio

2006-06-10 Thread Jay Blanchard
[snip]
Just a question out of curiousity for the language lawyers out there.
Why is
it illegal to begin a variable name with a number in php?
[/snip]

This is fairly standard in programming languages. Years ago (sometime in
the 70's) the reasoning was given to me, but I have long since replaced
the data at that address with some other, probably trivial, fact. I
tried a quick Google, but no joy.

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



Re: [PHP] Mail sending program (beginner)

2006-06-10 Thread tedd
At 10:54 AM +0530 6/10/06, aci india wrote:
Dear group,

Description:

Following is the code which I tried for learning propuses. It is a mail
sending program


-snip-

I read what you wanted, try this:

http://www.weberdev.com/get_example-503.html

hth's

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



Re: [PHP] Curio

2006-06-10 Thread tedd
At 11:31 AM +0100 6/10/06, Dave Goodchild wrote:
Just a question out of curiousity for the language lawyers out there. Why is
it illegal to begin a variable name with a number in php?


I don't know why in they do it in php, but I would guess that it's one of those 
legacy things.

Back when I was programming with rocks, a language called FORTRAN came along 
(before FORTRAN started having Roman Numerals after its name).

The rules of this new language was that integers could only start with the 
letters I, J, K, L ,M, N (hence our custom to use $i , $j, $k for loops) and 
all other real number could start with any other character but those, and could 
not start numbers -- however, both variables could contain numbers but were 
limited to just six letters total. (But note we didn't have to start variables 
with a $ ).

As far as strings were concerned -- what the hell were those? If you wanted to 
print something, you use a FORMAT statement and therein you might find syntax 
that could start with a number, such as 4F5.0, but that was just to format a 
number for print -- it had nothing to do with a variable name.

In defense of the decision of the time, I doubt that many of you remember IBM 
punch cards (one card for every line of code in your program) but it was a 
*great* deal easier to review and edit your stack of code if you kept numbers 
and letters separate with different meanings.

So, my guess is it's legacy.

My question to you is, what are you passing on that in 40 years some young 
programmer will ask Why is it illegal to...  :-)

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



Re: [PHP] Session puzzle... / why no new session?

2006-06-10 Thread Ryan A
Hey Chris,
Thanks for replying.

Dont worry about it, solved it, made a silly mistake
on my part but corrected it by just copying the code
from the session_destroy page on the
manual...destroyed the session and the cookie and all
works good now.

Thanks!
Ryan

 
 If you're logging straight back in after logging
 out, maybe not - the
 browser might remember the old session. If you log
 out, close the
 browser then go to the login page you should get a
 new id. If you want
 to guarantee a new id, use
 http://php.net/session_regenerate_id
 
 


--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



[PHP] HTML (php page) - PDF recommendation

2006-06-10 Thread Ryan A
Hi,
can anybody give me a recommendation on a good
html-pdf converter. Checked google and there are
loads of classes, this one looks like one of the best
though (even in price):

http://www.rustyparts.com/pdf.php

Anybody else using this? if yes, would appreciate any
cons of using this class.
Or, if you are using another class to do the above and
think its the next best thing to sliced bread, I would
appreciate you sending me the link so that I may try
it out.

All I need is a pdf generator that will generate an
exact (or as close to exact) copy of the html page
(that was generated by php, not a static html page),
nothing fancy, no permissions etc

Thanks!
Ryan

--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



Re: [PHP] Tables vs. databases

2006-06-10 Thread tedd
At 10:40 PM +0530 6/9/06, Antonio Bassinger wrote:
Hi gang,

Situation:

I've a HTTP server. I intend to run a file upload service. There could be up
to 1 subscribers. Each saving files up to 10 MB.

I made a proof-of-concept service using PHP  MySQL, where there is a single
database, but many tables - a unique table for each subscriber. But I
realize that I may land in trouble with such a huge database. Would it be
better to have a separate database for each subscriber?

Which approach is better, many tables in 1 database, or many databases with
1 or max 2 tables?

Kindly suggest with pros and cons of each.

Thanks  Regards,
Bassinger

You might also ask the mysql group.

http://lists.nyphp.org/mailman/listinfo/mysql

hth's

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



Re: [PHP] HTML (php page) - PDF recommendation

2006-06-10 Thread Frank Arensmeier
Depending on what you need (CSS support, good table support and so  
on) and which plattform you are working with it might be a good idea  
to have a look at: http://www.digitaljunkies.ca/dompdf/


There are also several on-line services available like: http:// 
www.pdfonline.com/


If you are on Mac OS X, I would definitely recommend looking at the  
Core Image functions within the Quartz 2D layer in Mac OS X. Core  
Image has also subroutines for PDF output (this is why you can save  
any document from any program in Mac OS X as a PDF file). You can  
access those APIs for example via Python.


http://developer.apple.com/documentation/GraphicsImaging/Conceptual/ 
drawingwithquartz2d/dq_python/chapter_17_section_1.html


This might give you some ideas where to start.

/frank

10 jun 2006 kl. 16.57 skrev Ryan A:


Hi,
can anybody give me a recommendation on a good
html-pdf converter. Checked google and there are
loads of classes, this one looks like one of the best
though (even in price):

http://www.rustyparts.com/pdf.php

Anybody else using this? if yes, would appreciate any
cons of using this class.
Or, if you are using another class to do the above and
think its the next best thing to sliced bread, I would
appreciate you sending me the link so that I may try
it out.

All I need is a pdf generator that will generate an
exact (or as close to exact) copy of the html page
(that was generated by php, not a static html page),
nothing fancy, no permissions etc

Thanks!
Ryan

--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.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] Re: order of elements in $_POST super global

2006-06-10 Thread Ben Liu

Hi Richard,

I'm basically building a custom mysql table to delimited text file  
function for a membership site. So I've got a lot of typical  
demographic info fields like name, address, etc. The site owners  
would like to dump the membership information for their own purposes,  
but they don't always want a complete set of all data. So the form  
lists each field with a checkbox to determine whether it is desired  
in the exported text file. To simplify things, the names of the  
checkbox form fields correspond exactly to the names of the related  
fields in the mysql table. So if there is a field named  
home_address1, the form checkbox is also name=home_address1. When I  
capture the form data, I iterate through the $_POST variable and  
create a custom query based on the checkboxes that are checked. So  
the form presented looks like:


snip
input type=checkbox value=1 name=prefixPrefix/inputbr 
/
		input type=checkbox value=1 name=first_nameFirst Name/ 
inputbr /
		input type=checkbox value=1 name=middle_nameMiddle Name/ 
inputbr /
		input type=checkbox value=1 name=last_nameLast Name/ 
inputbr /

input type=checkbox value=1 name=suffixSuffix/inputbr 
/
		input type=checkbox value=1 name=home_addr1Home Address  
(Street)/inputbr /
		input type=checkbox value=1 name=home_addr2Home Address 2/ 
inputbr /

/snip

Since the form fields names correspond to mysql field names rather  
than just a plain index array, I can use the keys thus:


snip

$exp_format=array_shift($_POST);
if ($exp_format==tab) {$delimiter=\t; $filesuffix=.txt;}
if ($exp_format==csv) {$delimiter=,; $filesuffix=.csv;}

	/* reset three array elements in the POST superglobal, they are  
flags and

should not be part of the custom query */
$mem_activity=array_shift($_POST);
$part_pref=$_POST['part_pref'];
unset($_POST['part_pref']);

$query=SELECT mem_id, ;

foreach ($_POST as $key = $data) {
$query.=$key, ;
}
/* chops off the last space and comma */
$length=strlen($query);
$query=substr($query, 0, $length-2);

/snip
	So what I really want to know is if there is some kind of best- 
practice method of rearranging the order of the items in a $_POST  
array without rearranging the elements on the original form, or post- 
processing them item by item.



Thanks for any insights...

- Ben

The script that processes the form looks like:


On Jun 9, 2006, at 7:12 PM, Richard Lynch wrote:


name=bool[0][careers]

might do what you want...

it's really quite difficult to say without a concrete example...

On Thu, June 8, 2006 10:20 am, Ben Liu wrote:

I probably should add some more details to my question:

The names of the form checkboxes could be changed from ie:
bool_careers, bool_speaking, bool_internship, etc. to a single array
bool_questions[], for instance. The problem with that is that I am
using the form checkbox names later to process related data.
Specifically, I am building a user-input based query. So if the form
checkbox names are the same as the names of the variables in the
database, it makes for easy creating of the query, since the names
become associative keys in the $_POST array. I iterate through the
$_POST array, checking each for true/false state. If the checkbox is
checked, I add the associative key name to the query. Eliminating the
checkbox names in favor of a numerical key only would make this more
complicated.

- Ben

On 6/8/06, Barry [EMAIL PROTECTED] wrote:


1. Use Keys in your form like a[1],a[2]
2. order the array by usort (alphabetically or whatever u prefer)

that way = 2: yes it is.


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





--
Like Music?
http://l-i-e.com/artists.htm






smime.p7s
Description: S/MIME cryptographic signature


[PHP] Re: How to re-order an array

2006-06-10 Thread Rafael
	Since you asked for some theory... theorically, you won't rely on 
javascript to prepare/validate/whatever some data to the server, that's 
what server-side scripts are for.
Note: you may use JS to make things quicker if possible, or to 
pre-digest the data, but you shall not rely entirely on JS.


	You say that not all browsers support the javascript functions you 
pretend to use, and that not all them support Ajax either.  That sounds 
just like saying that not all browser will have javascript enabled 
--that's why you shouldn't rely on javascript


	Although, this isn't a javascript list, why don't you send whatever you 
were trying to solve this issue? the code that uses JS functions not 
supported for all the browsers that will potentially run the script (as 
well as what these browsers are)  Most likely someone will be able to 
help you this way.


jekillen wrote:

Hello;
i'm scratching my head with a difficulty.
The situation is this.
A script begins with one indexed array (not associative) and one other 
indexed array

with the same values in a different order, the final order.
I want to create an interim array and progressively re order the array 
until it matches
slot for slot one of the original arrays. At this point the script is 
considered completed.
One important factor is that I'm looking to write this in javascript and 
the interim

array will be altered by the actions of a web page user.
Why am I asking the php list? Because I have a better chance of getting 
an answer
here. I'm not looking for help with javascript, specifically, just how 
one would go about
this task. Answer with php code and some theory if you wish and I will 
try to translate

it into javascript.
Some javascript functions I might use aren't supported in all the 
browsers that will

potentially run the script.
I might resort to using Ajax and let php keep track for me. But, then 
again not all

browsers will do the Ajax either (as I understand it).

--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

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



Re: [PHP] sending mail via php and unix box-clients thinks it's spam

2006-06-10 Thread blackwater dev

Here is what I use as the header:

   $header=From:[EMAIL PROTECTED]: text/html;

Thanks!

On 5/31/06, Richard Lynch [EMAIL PROTECTED] wrote:


On Tue, May 30, 2006 12:45 pm, blackwater dev wrote:
 I have a site running on a linux box.  If I use my mail server via an
 email
 client, the email works fine but if I send email through the mail
 function,
 clients mark it as spam.  I see the line in php.ini for SMTP but that
 says
 windows only.  How do I tell php to use my mail server?

While it is possible that the IP has been logged as a spammer, it's
more likely that the email headers are tripping you up...

Compare the two sets of email headers and see what you get, and also
look at the information provided by the spam filters about WHY they
think it's spam.

--
Like Music?
http://l-i-e.com/artists.htm





Re: [PHP] Re: How to re-order an array

2006-06-10 Thread jekillen


On Jun 10, 2006, at 5:32 PM, Rafael wrote:

	Since you asked for some theory... theorically, you won't rely on 
javascript to prepare/validate/whatever some data to the server, 
that's what server-side scripts are for.
Note: you may use JS to make things quicker if possible, or to 
pre-digest the data, but you shall not rely entirely on JS.
You misunderstand my question. I know the limitations of javascript. 
The server won't respond to events registered in the browser. I write 
tons of forms that are all processed
by the client with javascript. I have written ferocious regex filters 
that hack apart form submissions before they even leave the client. I 
have set it up so if the client doesn't
have javascript enabled, the form won't submit if it is going to the 
server. That is why as much as possible I shift form processing to the 
client as much as possible, for
security and to off load work to the client. I use php to dynamically 
write js files when necessary, anticipating what data will be 
requested.
This is a problem that is more a matter of programming theory. I have 
posted to javascript forums and lists and have never got a response.
I will be applying this to dhtml which the server won't and can't do 
but may help things along with Ajax.
Just a simple suggestion about how to reorder arrays if you have a few 
words and suggestions. I'm not looking for free training.
I have been learning and using php and javascript for some five years 
and have developed my own approach to testing and debugging
and such. So I am not really a newby. I have made the dumb mistakes of 
asking for help from forums and lists when it was just a dumb
syntax error that I couldn't expect anyone but my self to find, which i 
have in 99.9% of the cases. Some times it is nice to get some
quick help from a list and I will try to return the favor when ever 
possible to the next person looking for help that I have some answers 
for.


	You say that not all browsers support the javascript functions you 
pretend

'scuse me, did i pretend to use something??

to use, and that not all them support Ajax either.  That sounds just 
like saying that not all browser will have javascript enabled --that's 
why you shouldn't rely on javascript


	Although, this isn't a javascript list, why don't you send whatever 
you were trying to solve this issue? the code that uses JS functions 
not supported for all the browsers that will potentially run the 
script (as well as what these browsers are)  Most likely someone will 
be able to help you this way.

Thanks for the attitude.
jk


jekillen wrote:

Hello;
i'm scratching my head with a difficulty.
The situation is this.
A script begins with one indexed array (not associative) and one 
other indexed array

with the same values in a different order, the final order.
I want to create an interim array and progressively re order the 
array until it matches
slot for slot one of the original arrays. At this point the script is 
considered completed.
One important factor is that I'm looking to write this in javascript 
and the interim

array will be altered by the actions of a web page user.
Why am I asking the php list? Because I have a better chance of 
getting an answer
here. I'm not looking for help with javascript, specifically, just 
how one would go about
this task. Answer with php code and some theory if you wish and I 
will try to translate

it into javascript.
Some javascript functions I might use aren't supported in all the 
browsers that will

potentially run the script.
I might resort to using Ajax and let php keep track for me. But, then 
again not all

browsers will do the Ajax either (as I understand it).

--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

--
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] Tables vs. databases

2006-06-10 Thread Anthony Ettinger

On 6/9/06, Antonio Bassinger [EMAIL PROTECTED] wrote:

Hi gang,

Situation:

I've a HTTP server. I intend to run a file upload service. There could be up
to 1 subscribers. Each saving files up to 10 MB.

I made a proof-of-concept service using PHP  MySQL, where there is a single
database, but many tables - a unique table for each subscriber. But I
realize that I may land in trouble with such a huge database. Would it be
better to have a separate database for each subscriber?

Which approach is better, many tables in 1 database, or many databases with
1 or max 2 tables?

Kindly suggest with pros and cons of each.


you might want to consider storing the files outside of the database
as well, and just a pointer to it's path in the table.

with respect to table vs. databases per user, neither.


--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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



Re: [PHP] Re: How to re-order an array

2006-06-10 Thread Larry Garfield
On Saturday 10 June 2006 21:08, jekillen wrote:

 You misunderstand my question. I know the limitations of javascript.
 The server won't respond to events registered in the browser. I write
 tons of forms that are all processed
 by the client with javascript. I have written ferocious regex filters
 that hack apart form submissions before they even leave the client. I
 have set it up so if the client doesn't
 have javascript enabled, the form won't submit if it is going to the
 server. That is why as much as possible I shift form processing to the
 client as much as possible, for
 security and to off load work to the client. I use php to dynamically
 write js files when necessary, anticipating what data will be
 requested.

...shift form processing to the client as much as possible, for security...

Client-side security isn't.  Your server has no way of telling if the data 
it's receiving is from a properly setup client that did the correct JS 
filtering, or if it's from someone writing as simple bot/script/program 
that's just sending GET and POST requests to you.  Your PHP should never 
trust the client to be benign.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] Running Scripts from the Command Line in Linux

2006-06-10 Thread OOzy Pal

On 6/8/06, Venky [EMAIL PROTECTED] wrote:

Even better... if you want to use GET/POST, and access PHP scripts thru the
web server, it is recommended to use wget very useful tool, supports
http auth, etc.

 Regards


 Venky



On 08/06/06, Brad Bonkoski [EMAIL PROTECTED] wrote:

 $ php script.php


OOzy Pal wrote:

 How can I run a .php script from the command in Linux?


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





Thanks you all but everything up did not work for me until I install
php-cli. :). I am running Kubuntu-Dapper.

Everything is OK.

--
OOzy
Kubuntu-Dapper

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