RE: [PHP] send a file or stream

2006-08-30 Thread Peter Lauri
I think the stations.zip is empty... Try this:

Between your scripting and the readfile() put a sleep(2); between so it waits 2 
seconds before pushing the data.

And I also suggest:

while()
{
fwrite($da, $somevar1:$somevar2);
}
fclose($da);

Header()

(try sleep(2); here)

readfile();


-Original Message-
From: Rafael Mora [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 31, 2006 1:25 AM
To: Peter Lauri
Cc: php-general
Subject: Re: [PHP] send a file or stream

I can download it, but when I see the file I downloaded has 0 bytes, and I
have readfile(stations.zip);




On 8/30/06, Peter Lauri [EMAIL PROTECTED] wrote:

 But can you download it correctly? Is it just the download box that shows
 0 bytes?

 Or is it so that you actually is doing what you do below readfile()
 without any argument? So that you are actually downloading something empty?
 :)

 /Peter



 -Original Message-
 From: Rafael Mora [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, August 30, 2006 8:00 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] send a file or stream

 Hi!!

 Well it works now, but with another issue, when I download it, it says
 that
 it size is 0 bytes!!

 i fwrite the file in a while, is it correct?

 header()...
 while()
 {
 fwrite($da, $somevar1:$somevar2);
 }
 fclose($da);

 readfile();

 thanks



 On 8/30/06, Peter Lauri [EMAIL PROTECTED] wrote:
 
  Try this:
 
  header(Pragma: public);
  header(Expires: 0); // set expiration time
  header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
  header(Content-Type: application/octet-stream);
  header('Content-Disposition: attachment; filename=stations.gzip');
  header(Content-Transfer-Encoding: binary);
  header(Content-Length: .filesize(stations.gzip));
  readfile(stations.gzip);
 
  /Peter
 
  PS! To maintain the list and its functionality, do not post same message
  multiple times  DS!
 
 
  -Original Message-
  From: Rafael Mora [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, August 30, 2006 11:01 AM
  To: Peter Lauri
  Cc: php-general@lists.php.net
  Subject: Re: [PHP] send a file or stream
 
  Ok it works, but it returns me the same .php file, not the one I am
  creating
 
 
 
  On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote:
  
   You need to make sure that you are not outputting ANYTHING before you
 do
   this. I might guess that you have a whitespace in the top of the
 script.
  As
   soon as you output, the server can not send any more header
 information,
  and
   the browser will think it is just text instead of treating it as an
   octet-stream.
  
  
  
   /Peter
  
  
  
   _
  
   From: Rafael Mora [mailto:[EMAIL PROTECTED]
   Sent: Wednesday, August 30, 2006 10:25 AM
   To: Peter Lauri
   Cc: php-general@lists.php.net
   Subject: Re: [PHP] send a file or stream
  
  
  
   I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=(r)(??/§C0/¿D!1O!3·
   ¿¨$1¯D¡¸¤(3/] LÖ‑ so the user should read that?? this is my code:
  
  
  
   ?php
   $params = array('level' = 6, 'window' = 15, 'memory' = 9);
  
   $texto_original = This is a test.\nThis is only a test.\nThis is not
 an
   important string.\n;
   //echo El texto original tiene  . strlen($texto_original) . 
   caracteres.\n;
  
   $da = fopen('stations.gzip', 'w');
   stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE,
 $params);
   fwrite($da, $texto_original);
   fclose($da);
  
   header(Content-Type: application/octet-stream);
   readfile(stations.gzip);
  
  
  
  
  
   On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote:
  
   ?php
   header(Content-Type: application/octet-stream);
   readfile(path_to_compressed_file);
   ?
  
  
  
   Should do it then. if you know the path to the file :)
  
  
  
   _
  
   From: Rafael Mora [mailto:[EMAIL PROTECTED]
   Sent: Wednesday, August 30, 2006 10:10 AM
   To: Peter Lauri
   Subject: Re: [PHP] send a file or stream
  
  
  
   1. A user sends a request to your server to get a compressed file
   2. You compress the file on the server
   3. I want to send back the file to the user
  
  
  
  
  
  
  
   On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote:
  
   Do you mean the following:
  
   1. A user sends a request to your server to get a compressed file
   2. You compress the file on the server
   3. You want to send back to compressed file to the server
  
   It is number 3 you asking for?
  
   In that case:
  
   ?php
   header(Content-Type: application/octet-stream);
   readfile(path_to_compressed_file);
   ?
  
   /Peter
  
  
   -Original Message-
   From: Rafael Mora [mailto:[EMAIL PROTECTED]
   Sent: Wednesday, August 30, 2006 2:34 AM
   To: php-general@lists.php.net
   Subject: [PHP] send a file or stream
  
   Hi!
  
   i want to send a file or output stream in a .php, but first compress
 it,
  I
   tryed the example to compress files but how do i do to send as answer
 to
   the
  
   http request??
  
   Rafa
  
  
  
  
  
  
  
  
  
 
  --
  PHP General Mailing List (http://www.php.net

RE: [PHP] php generated javascript

2006-08-30 Thread Peter Lauri
Koala,

There is no difference with the php generated javascript and javascript on a
static html page.

Take a look at the source code of the page that has been generated in the
browser, and if that one looks as it should, it is probably your javascript
that is not doing what it should :)

And if that is the case you can join the [EMAIL PROTECTED] list for that
purpose.

/Peter



-Original Message-
From: Shu Hung (Koala) [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 31, 2006 10:41 AM
To: PHP General Users
Subject: [PHP] php generated javascript

Hello,

I'm writing a script to generate a javascript. The javascript would
generate a banner when it is sourced. This javascript is sourced
by another html like this:

script type=text/javascript language='JavaScript'
src='http://foo.com/testing/js.php'/script

However, Sometimes the javascript doesn't show anything at all. it
seems that the php generated javascript cannot be loaded sometimes.
Maybe the generation takes too long. I'm not sure about that.

Is there anyway to deal with it?

Koala Yeung

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



[PHP] Extream OT

2006-08-31 Thread Peter Lauri
HI,

 

This is very Off Topic, but I have no clue where to go to find out this
information fast enough.

 

I have a client that just changed their mind and want me to host their web
services. However, they have their current hosting setup on a Windows NT
server. Now the question comes: How the heck can I move the mail boxes from
the Windows NT server to my Plesk Linux server? Basically I just want to
know if it is possible, because then I can give them a go, find out the
information after that is easy maybe, or I will hire someone :-)

 

Thanks if someone have a clue about this.

 

/Peter

 

 

 



[PHP] Crazy behavior...

2006-09-03 Thread Peter Lauri
Hi,

This is really odd. I use this code to retrive value from a database table.
When the field is empty, it cracks the HTML code some how, the PHP script
seam to not break.

function getInfo() {
$html = table;
$html.=
trthName/thtd.$this-getName()./td/tr;
$html.=
trthDescription/thtd.$this-getDesc()./td/tr;
$html.=
trthPriority/thtd.$this-getPriorityText()./td/tr;

$html.= /table;
return $html;
}

The function getDesc is like this (I have made it overly complicated because
I am trying to fix the problem):

function getDesc() {
$Query = sprintf(SELECT todotext FROM teamtodo WHERE id=%d
LIMIT 1, $this-getID());
$Result = mysql_query($Query);
if(mysql_num_rows($Result)0) { 
if($Roww = mysql_fetch_array($Result)) {
if($Roww['todotext']!='') return
$Roww['todotext'];
else return '';
} else return '';
} else return '';
}

When the database field is not empty it works fine, but as soon as the field
todotext is empty the $html seam to break, but the value of $html until the
$this-getDesc() is still being returned by the function (can see half of
the table).

Is this a bug, or am I just stupid? If I just insert some blank spaces it
works, hrm.

/Peter

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



RE: [PHP] Crazy behavior...

2006-09-03 Thread Peter Lauri
Just figured out that it seams to happen when the request is done via AJAX.
But it does not make any sense to me that there should be any difference.

/Peter


-Original Message-
From: Peter Lauri [mailto:[EMAIL PROTECTED] 
Sent: Sunday, September 03, 2006 1:53 PM
To: php-general@lists.php.net
Subject: [PHP] Crazy behavior...

Hi,

This is really odd. I use this code to retrive value from a database table.
When the field is empty, it cracks the HTML code some how, the PHP script
seam to not break.

function getInfo() {
$html = table;
$html.=
trthName/thtd.$this-getName()./td/tr;
$html.=
trthDescription/thtd.$this-getDesc()./td/tr;
$html.=
trthPriority/thtd.$this-getPriorityText()./td/tr;

$html.= /table;
return $html;
}

The function getDesc is like this (I have made it overly complicated because
I am trying to fix the problem):

function getDesc() {
$Query = sprintf(SELECT todotext FROM teamtodo WHERE id=%d
LIMIT 1, $this-getID());
$Result = mysql_query($Query);
if(mysql_num_rows($Result)0) { 
if($Roww = mysql_fetch_array($Result)) {
if($Roww['todotext']!='') return
$Roww['todotext'];
else return '';
} else return '';
} else return '';
}

When the database field is not empty it works fine, but as soon as the field
todotext is empty the $html seam to break, but the value of $html until the
$this-getDesc() is still being returned by the function (can see half of
the table).

Is this a bug, or am I just stupid? If I just insert some blank spaces it
works, hrm.

/Peter

-- 
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] Crazy behavior...

2006-09-03 Thread Peter Lauri
[snip]
Can you send an example of the broken HTML?  What are the symptoms of 
the html being broken.  Finally, in what way are you using AJAX.  This 
looks like html output - so is it really AJAH?

My first guess is that something about the context at the browser end 
makes td/td - an empty table element - cause trouble.

Cheers

AJ

[/snip]


This is really odd. I wrote the $html variable that I send back to the
browser via AJAX, and that code is like this when I pushed it into a
temporary database table:

tablep style='float: right;'
a href='javascript:teamToDoHideInfoBox(1, 6);''Close/a/p
trthName/thtdasdf/td/tr
trthDescription/thtd/td/tr
trthAssigned to/thtd/td/tr
trthCreated by/thtdPeter Lauri(Farang)/td/tr
trthDue date/thtd/td/tr
trthStart date/thtd/td/tr
trthPriority/thtdNormal/td/tr
trthCreation date/thtdSun, 03 Sep 2006 23:09:44 +0700/td/tr
/table

However, if I just use that output all is shown until the empty td/td
tag.

Then I tried to check what is actually captured by the browser, and it was
showing only until the td and then nothing more.

So this should maybe be posted to the JavaScript list :)

I have temporary solved by NOT allowing empty strings into those fields, but
the description should be able to be empty :)

/Peter

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



RE: [PHP] Crazy behavior...

2006-09-03 Thread Peter Lauri
Just thought one thing. I did do a alert() on the http.responseText, and
that breaks in on the td too, so the response that is sent back probably
just ends there... weird...

/Peter

-Original Message-
From: Alex Turner [mailto:[EMAIL PROTECTED] 
Sent: Sunday, September 03, 2006 11:31 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: RE: [PHP] Crazy behavior...

Peter,

When it arrives at the browser, via ajax, I am guessing that you then put it
into the page view .innerHTML or some other method.

I suspect your problem revolves around asking the browser to do stuff it
should not really have to do.

There are two issues I would like to highlight with the html.

1) You are mixing TH and TD on the same row.  You should be using styles to
set the different presentations of the elements.
2) You have placed a paragraph section between the table tag and the first
tr tag.  This is wrong.

I suspect that the browser is managing to cope with this markup when
presented as a static page but is unable to figure out how to update an
existing page with it.  If you fix the html to be standards compliant then
the chances are all will be well.  

If it is not - by all means get back to me :-)

Best wishes

AJ 

Alexander J Turner Ph.D.
www.deployview.com
www.nerds-central.blogspot.com
www.project-network.com

-Original Message-
From: Peter Lauri [mailto:[EMAIL PROTECTED] 
Sent: 03 September 2006 17:20
To: Alex Turner; php-general@lists.php.net
Subject: RE: [PHP] Crazy behavior...


[snip]
Can you send an example of the broken HTML?  What are the symptoms of 
the html being broken.  Finally, in what way are you using AJAX.  This 
looks like html output - so is it really AJAH?

My first guess is that something about the context at the browser end 
makes td/td - an empty table element - cause trouble.

Cheers

AJ

[/snip]


This is really odd. I wrote the $html variable that I send back to the
browser via AJAX, and that code is like this when I pushed it into a
temporary database table:

tablep style='float: right;'
a href='javascript:teamToDoHideInfoBox(1, 6);''Close/a/p
trthName/thtdasdf/td/tr
trthDescription/thtd/td/tr
trthAssigned to/thtd/td/tr
trthCreated by/thtdPeter Lauri(Farang)/td/tr
trthDue date/thtd/td/tr
trthStart date/thtd/td/tr
trthPriority/thtdNormal/td/tr
trthCreation date/thtdSun, 03 Sep 2006 23:09:44 +0700/td/tr
/table

However, if I just use that output all is shown until the empty td/td
tag.

Then I tried to check what is actually captured by the browser, and it was
showing only until the td and then nothing more.

So this should maybe be posted to the JavaScript list :)

I have temporary solved by NOT allowing empty strings into those fields, but
the description should be able to be empty :)

/Peter


-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006
 

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



[PHP] Is this unsecure?

2006-09-05 Thread Peter Lauri
Hi,

 

I have bumped into a problem. I need to use a web service that is located on
server B from server A. The server B will execute a script when the web
service is accessed and an email is sent as an parameter. The problem is, if
I only have the email as incoming parameter, anyone can just figure out the
url for the web service, the name, and then just send the email to that
address.

 

To make this a little bit secure I setup so two parameters are sent, the
email and a confirmation code. First I was just thinking to basically have a
password sent with, and if that is correct just execute the script. However,
due to server restrictions I can not run it on HTTPS, so that also looses
value.

 

So this is how I solved it:

 

I send a parameter with the request that is the email, some extra characters
and then MD5 on that. I do this on server A and then server B just checks if
it is the same resulting string. If so, we know it comes from server A
because that server is the only one that knows the extra characters used.

 

$authstring = md5(asdf.$email.fdsa);

 

Would this be hard to crack assuming that the one who cracks does not know
the characters that are used to generate the $authstring?

 

Maybe someone have experience with this? Or just a comment?

 

Best regards,

Peter Lauri

 

www.lauri.se http://www.lauri.se/  - personal web site

www.dwsasia.com http://www.dwsasia.com/  - company web site



RE: [PHP] Is this unsecure?

2006-09-05 Thread Peter Lauri
Isn't that just to send a username and password with the request? Or is the
username and password protected somehow in that process?

-Original Message-
From: Paul Scott [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 05, 2006 4:08 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Is this unsecure?


On Tue, 2006-09-05 at 16:04 +0700, Peter Lauri wrote:
 I have bumped into a problem. I need to use a web service that is located
on
 server B from server A. The server B will execute a script when the web
 service is accessed and an email is sent as an parameter. The problem is,
if
 I only have the email as incoming parameter, anyone can just figure out
the
 url for the web service, the name, and then just send the email to that
 address.
 

Why not just use SOAP envelope authentication? 

--Paul

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



RE: [PHP] Re: Is this unsecure?

2006-09-05 Thread Peter Lauri
[snip]

This seems the easiest for me:
- Determine IP address of Server A.
- At Server B:
?php
if ($_SERVER['REMOTE_ADDR'] != SERVER_A_IP) {
die('Get lost, will you.');
}

 rest of code ...

How's that? You could, of course, still add the md5 check, which sounds
pretty good.

HTH

Ivo

[/snip]

Then some one with an account on that server can also do the same thing :) A
combination is probably the best...

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



[PHP] Mirror url

2006-09-12 Thread Peter Lauri
Hi,

 

My client wants an affiliate system developed. I already have an affiliate
system that works, but I need to extend it a little.

 

My client want that the affiliate like should be something like:
www.domain.com/rosegarden where rosegarden is the affiliates choosen
affiliate tracking. 

 

1.  I have a script that creates the folder rosegarden and copy
index.php file into that folder that contains the tracking script and then
just redirect them back to www.domain.com http://www.domain.com/ 
2.  I can use ModRewrite or something like that. But I have never used
that before, and I am curious of how difficult it would be to create a
dynamic system for this.

 

When the affiliate signs up they can choose their subfolder and the system
will automatically create necessary files and copy them.

 

Am I clear of what I want to accomplish?

 

Best regards,

Peter Lauri

 

 

 



RE: [PHP] Mirror url

2006-09-12 Thread Peter Lauri

-Original Message-
From: Stut [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 12, 2006 3:11 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Mirror url

Peter Lauri wrote:
 My client wants an affiliate system developed. I already have an affiliate
 system that works, but I need to extend it a little.
  
 My client want that the affiliate like should be something like:
 www.domain.com/rosegarden where rosegarden is the affiliates choosen
 affiliate tracking. 

 1.I have a script that creates the folder rosegarden and copy
 index.php file into that folder that contains the tracking script and then
 just redirect them back to www.domain.com http://www.domain.com/ 
 2.I can use ModRewrite or something like that. But I have never used
 that before, and I am curious of how difficult it would be to create a
 dynamic system for this.

 When the affiliate signs up they can choose their subfolder and the system
 will automatically create necessary files and copy them.
   

Ok, 1 is pure evil, 2 is overkill. My suggestion would be multiviews. If 
you're using Apache (I assume you are since mod_rewrite is an option), 
enable multiviews on the vhost and then create a file called a.php in 
the root of the site. Affiliates link to (as your example) 
/a/rosegarden. In a.php, grab $_SERVER['REQUEST_URI'], remove the /a/ 
from the start of it, what's left is the affiliate identifier. Process 
as you like.

-Stut

--

That sounded simple, will take a look at it.

Best regards,
Peter

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



RE: [PHP] mail() help

2006-09-12 Thread Peter Lauri
What are you doing on this line:

$headers .= 'From: MyADTV asureshkumar_1983'@yahoo.co.in' . \r\n;

Should it not be:

$headers .= 'From: MyADTV [EMAIL PROTECTED]' . \r\n;

?

/Peter

www.lauri.se - personal web site
www.dwsasia.com - company web site



-Original Message-
From: suresh kumar [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 12, 2006 7:56 PM
To: php-general@lists.php.net
Subject: [PHP] mail() help

Hi,
  I  am using php mail function to send mails to our customers.but when
i send mail to them.it is getting received in customers bulk folder .i want
mail to get received in customers inbox.i dont know the reason why its
getting stored in bulk folder.
   
   i attached the code.below,any one help me

  $to='[EMAIL PROTECTED]';

$subject='Password from MyAdTV';

$headers  = 'MIME-Version: 1.0' . \r\n;

$headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n;

$headers .= 'From: MyADTV asureshkumar_1983'@yahoo.co.in' .
\r\n;

$headers.= 'X-Mailer: PHP/' . phpversion(). \r\n;

$sendmessage = brHere is the information you
requestedbrbrYour Logon name and Password details for MyADTV
Accountbrbrb your LogonName is /b: suresh brbrb your Password
is /b rajaysbrbrIf You Want To Login into Your MyADTV Account,a
href=\Click'http://myadtv.com/login.php\;Click Here/abrbr;
  
   
 mail($to,$subject,$sendmessage,$headers);
  

Christopher Weldon [EMAIL PROTECTED] wrote:
  -BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

suresh kumar wrote:
 Hi to all,
 i am having one doubt regarding php mail function.i am using php mail()
function to send mail to the users.but when i send mail throught php its
going to the users bulk folder but not to the user inbox.i dont know the
reason.
 
 Is there any setting that is requried in the php.ini file (or) the user
have to change their setting in their mail (or) is there any option
available to send mail to the user inbox.tnxs for reply
 
 A.suresh
 
 
 
 
 -
 Find out what India is talking about on - Yahoo! Answers India 
 Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get
it NOW

There are several things you need to check for, and probably add to your
emails that you're sending.

Number one, add additional headers to make SPAM / Bulk filters realize
the message is not SPAM or should not be considered SPAM. IE:

$headers = From: Suresh Kumar \r\n.
X-Mailer: PHP 4.3.2\r\n.
X-Sender: $_SERVER['HTTP_HOST']\r\n.
X-Comment: If you can put a comment here, do it.\r\n;

mail($to, $subject, $body, $headers);

The above is considering you have already declared the $to, $subject,
and $body variables. Also, make sure your $subject is not
'undisclosed-recipients;' or something like that - it's a big no-no and
will definitely flag some SPAM filters. Put a valid e-mail address - but
you can still use the BCC-headers and everything should go just fine.
Alternatively, if your list is not too large, it looks better to run a
for / while loop to send each recipient a message directly (ie: not
using BCC) as that will cut down on the SPAM probability.

Second, if you are making MIME emails, make sure you are doing so
correctly. You can learn about creating multipart/alternative MIME
emails more at www.php.net/mail.

Finally, if none of the above works, it would be helpful for us to see
the headers of the received message from one of your recipients where
the message was put in the BULK folder.

- --
Christopher Weldon, ZCE
President  CEO
Cerberus Interactive, Inc.
[EMAIL PROTECTED]
979.739.5874
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFBaG2Zxvk7JEXkbERAgZiAKCJVQfno2fAca13Sx7aXPWD2WMgUwCeOMBX
grbViYDnAXXy8l1i4liVHzE=
=ka5I
-END PGP SIGNATURE-

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




-
 Find out what India is talking about on  - Yahoo! Answers India 
 Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get
it NOW

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



[PHP] Affiliate system

2006-09-12 Thread Peter Lauri
Hi guys,

I am reviewing an affiliate system that I created a while ago. I am using a
very simple method to do this, but I am curious if there is any better
system (better I mean less missed affiliate purchases).

1. User click on affiliate link http://thedomain.com/?a=1234
2. The if $_GET['a'] is set, we check if that is an valid affiliate, and
then set a cookie for that
3. At purchase, we check if that cookie still is there, if so, we register
it as a affiliate purchase and that info is stored in the purchase database

What should I do if they do not allow cookies? I could amend a=1234 onto
every url that they pass, but that would not be a beautiful solution.

Maybe I can also create a SESSION that stores the affiliate information so
that it at least get registered if the purchase is completed within the
session?

What do you think is the best way?

Best regards, 
Peter Lauri

www.lauri.se - personal web site
www.dwsasia.com - company web site

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



RE: [PHP] Affiliate system

2006-09-13 Thread Peter Lauri
That is probably what I will do. Thanks for your comment.

-Original Message-
From: Andrei [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 13, 2006 2:43 PM
To: [php] PHP General List
Subject: Re: [PHP] Affiliate system


I ran into same issue with a site... I solved this problem by saving
information in 2 places (in cookies and in database). So when saving
data once I saved in the cookie then into database. When I wanted to
read the information I first check if cookie exist and if it doesn't I
read from database.

Andy

Peter Lauri wrote:
 Hi guys,
 
 I am reviewing an affiliate system that I created a while ago. I am using
a
 very simple method to do this, but I am curious if there is any better
 system (better I mean less missed affiliate purchases).
 
 1. User click on affiliate link http://thedomain.com/?a=1234
 2. The if $_GET['a'] is set, we check if that is an valid affiliate, and
 then set a cookie for that
 3. At purchase, we check if that cookie still is there, if so, we register
 it as a affiliate purchase and that info is stored in the purchase
database
 
 What should I do if they do not allow cookies? I could amend a=1234 onto
 every url that they pass, but that would not be a beautiful solution.
 
 Maybe I can also create a SESSION that stores the affiliate information so
 that it at least get registered if the purchase is completed within the
 session?
 
 What do you think is the best way?
 
 Best regards, 
 Peter Lauri
 
 www.lauri.se - personal web site
 www.dwsasia.com - company web site
 

-- 
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] PHP and mySQL dates

2006-09-13 Thread Peter Lauri
[snip]
Hi all. I am building an online events registry and have mapped out all the
dates between Oct 1 2006 and Dec 31 2030, stored in the database as
timestamps incremented by 86400 to give daily slots. 
[/snip]

I do not really understand the purpose of mapping all dates between Oct 1
2006 and Dec 31 2030 and store them into a database as a timestamp. First of
all, a date is a date, not a timestamp. A timestamp is date and time
together.

Why don't you just save the events with the date as DATE format and then
compare them with CURDATE() or similar. Or just with $_SESSION[year]-
$_SESSION[month]- $_SESSION[day]

Just some thoughts.

/Peter

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



RE: [PHP] PHP and mySQL dates

2006-09-13 Thread Peter Lauri
No problem, now I will go and make my girlfriend happy :)

-Original Message-
From: Dave Goodchild [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 13, 2006 6:27 PM
To: Peter Lauri
Cc: PHP General
Subject: Re: [PHP] PHP and mySQL dates

Thanks. I have been so up close and personal with this that I can't see the
wood for the trees. Of course, so obvious. Thank you - you have made me very
happy.





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

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



[PHP] preg_replace (again)

2006-09-19 Thread Peter Lauri
Hi group,

 

I know I am a little bit stupid when it comes to actually figuring out how
to use the preg_match and preg_replace. This is what I am facing:

 

A string like this: This is some _color:pink_ colored text _color_ that I
want to transfer

 

Should convert to: This is some font color=pinkcolored text/font that
I want to transfer

 

Anyone who see a simple solution to this? Right now I have created an ugly
script that do the same thing, but I want to start to learn and use
preg_match.

 

Thanks.

 

/Peter

 

www.lauri.se http://www.lauri.se/  - Personal web site

www.dwsasia.com http://www.dwsasia.com/  - Company web site 

 

 

 



RE: [PHP] preg_replace (again) [solved]

2006-09-19 Thread Peter Lauri
Just to share my solution:

preg_replace('/_color:(.*?)_(.*?)_color_/i', 'font color=$1$2/font',
$html);

/Peter

-Original Message-
From: Peter Lauri [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 20, 2006 9:42 AM
To: 'PHP General'
Subject: [PHP] preg_replace (again)

Hi group,

 

I know I am a little bit stupid when it comes to actually figuring out how
to use the preg_match and preg_replace. This is what I am facing:

 

A string like this: This is some _color:pink_ colored text _color_ that I
want to transfer

 

Should convert to: This is some font color=pinkcolored text/font that
I want to transfer

 

Anyone who see a simple solution to this? Right now I have created an ugly
script that do the same thing, but I want to start to learn and use
preg_match.

 

Thanks.

 

/Peter

 

www.lauri.se http://www.lauri.se/  - Personal web site

www.dwsasia.com http://www.dwsasia.com/  - Company web site 

 

 

 

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



RE: [PHP] preg_replace (again) [solved]

2006-09-20 Thread Peter Lauri
Hi,

Thanks for you comment. I already changed to span.

About sanitation: Do you know any open source where it checks code if it is
acceptable or not? Or should I just create a lib that do some preg_match to
see if any javascript tag is inside (assuming javascript should not be
allowed).

This is a private system, so I do not worry so much :)

/Peter

-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 20, 2006 2:13 PM
To: Peter Lauri
Cc: 'PHP General'
Subject: RE: [PHP] preg_replace (again) [solved]

On Wed, 2006-09-20 at 11:45 +0700, Peter Lauri wrote:
 Just to share my solution:

Out of curiosity, why don't you go with the very well known BBCode
system?

 preg_replace('/_color:(.*?)_(.*?)_color_/i', 'font color=$1$2/font',
 $html);

Hopefully this is a private system, otherwise someone not very nice
might do the following:


This is some _color:pink script type=text/javascript
language=javascript
document.location = 'http://www.myDoityPr0nCollection.com';
/scriptfont color=pink_ colored text _color_ that I want to transfer


You need better content sanitization ]:B

FWIW, the font tag is about as deprecated as deprecated can get. You
might consider switching to span.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] Convert UTF-8 to windows-874?

2006-09-28 Thread Peter Lauri
Hi group,

 

I am having a site all encoded in UTF-8, and it works fine. I use AJAX a lot
to send data back and forth to the server.

 

I have one service that requires that I send the data in windows-874
encoding (SMS gateway in Thailand). So is there anyway I can take the data
that is UTF-8 and then convert it to windows-874 and then send it to the SMS
gateway?

 

Best regards,

Peter Lauri

 

www.lauri.se http://www.lauri.se/  - personal web site

www.dwsasia.com http://www.dwsasia.com/  - company web site



RE: [PHP] Convert UTF-8 to windows-874?

2006-09-28 Thread Peter Lauri
I think I am on the right track right now.

There is a function mb_convert_encoding() that could be used. However, I
have not found out how to code windows-874?

Warning: mb_convert_encoding(): Unknown encoding ISO-8859-11 in
D:\webserver\viphavadee\sms\classes\sms.class.php on line 17

Was one of my attempts...

Anyone with a hint of how to work out this problem?

/Peter


-Original Message-
From: Peter Lauri [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 28, 2006 5:10 PM
To: 'PHP General'
Subject: [PHP] Convert UTF-8 to windows-874?

Hi group,

 

I am having a site all encoded in UTF-8, and it works fine. I use AJAX a lot
to send data back and forth to the server.

 

I have one service that requires that I send the data in windows-874
encoding (SMS gateway in Thailand). So is there anyway I can take the data
that is UTF-8 and then convert it to windows-874 and then send it to the SMS
gateway?

 

Best regards,

Peter Lauri

 

www.lauri.se http://www.lauri.se/  - personal web site

www.dwsasia.com http://www.dwsasia.com/  - company web site

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



RE: [PHP] Convert UTF-8 to windows-874?

2006-09-28 Thread Peter Lauri
Hi,

I was on the right track. However, the mbstring does not seam to support
windows-874 (ISO-8859-11).

What is the next step I could take? One not the good is to convert the whole
system to Windows-874 and use that, but that is not so fun. Please help me
:)

Best regards,
Peter Lauri



-Original Message-
From: Peter Lauri [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 28, 2006 7:16 PM
To: 'Peter Lauri'; 'PHP General'
Subject: RE: [PHP] Convert UTF-8 to windows-874?

I think I am on the right track right now.

There is a function mb_convert_encoding() that could be used. However, I
have not found out how to code windows-874?

Warning: mb_convert_encoding(): Unknown encoding ISO-8859-11 in
D:\webserver\viphavadee\sms\classes\sms.class.php on line 17

Was one of my attempts...

Anyone with a hint of how to work out this problem?

/Peter


-Original Message-
From: Peter Lauri [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 28, 2006 5:10 PM
To: 'PHP General'
Subject: [PHP] Convert UTF-8 to windows-874?

Hi group,

 

I am having a site all encoded in UTF-8, and it works fine. I use AJAX a lot
to send data back and forth to the server.

 

I have one service that requires that I send the data in windows-874
encoding (SMS gateway in Thailand). So is there anyway I can take the data
that is UTF-8 and then convert it to windows-874 and then send it to the SMS
gateway?

 

Best regards,

Peter Lauri

 

www.lauri.se http://www.lauri.se/  - personal web site

www.dwsasia.com http://www.dwsasia.com/  - company web site

-- 
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] Convert UTF-8 to windows-874?

2006-09-28 Thread Peter Lauri
Iconv did it for me, a great thanks!!!

/Peter

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 28, 2006 11:12 PM
To: Peter Lauri
Cc: 'PHP General'
Subject: RE: [PHP] Convert UTF-8 to windows-874?

I think that the iconv function/package may have what you are looking
for...

This is just a parrot of previous answers to similar questions.

I have no personal knowledge...

You could also contact the Thai folks and find out if there is
anything close enough to Windows-874 to use.

From my limited understanding, sometimes the difference between 2
encodings is sooo minor that you're only screwing up a couple
characters, and only a linguist cares. :-v

I also suspect that MS, in typical fashion, may have stolen (no!) a
character encoding, renamed it windows-874, and it's really really the
same thing as an OSS encoding of another name.

On Thu, September 28, 2006 7:16 am, Peter Lauri wrote:
 I think I am on the right track right now.

 There is a function mb_convert_encoding() that could be used. However,
 I
 have not found out how to code windows-874?

 Warning: mb_convert_encoding(): Unknown encoding ISO-8859-11 in
 D:\webserver\viphavadee\sms\classes\sms.class.php on line 17

 Was one of my attempts...

 Anyone with a hint of how to work out this problem?

 /Peter


 -Original Message-
 From: Peter Lauri [mailto:[EMAIL PROTECTED]
 Sent: Thursday, September 28, 2006 5:10 PM
 To: 'PHP General'
 Subject: [PHP] Convert UTF-8 to windows-874?

 Hi group,



 I am having a site all encoded in UTF-8, and it works fine. I use AJAX
 a lot
 to send data back and forth to the server.



 I have one service that requires that I send the data in windows-874
 encoding (SMS gateway in Thailand). So is there anyway I can take the
 data
 that is UTF-8 and then convert it to windows-874 and then send it to
 the SMS
 gateway?



 Best regards,

 Peter Lauri



 www.lauri.se http://www.lauri.se/  - personal web site

 www.dwsasia.com http://www.dwsasia.com/  - company web site

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

-- 
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] Rapid application development

2006-09-29 Thread Peter Lauri
Why don't you reuse the basic code from your old projects? Then you don't
need to worry about this :) (OOP)

-Original Message-
From: Ahmad Al-Twaijiry [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 30, 2006 12:45 PM
To: PHP
Subject: [PHP] Rapid application development

Hi Everyone,

I need your feedback in this

What is the best RAD (Rapid application development) do you use for
PHP to develop an *advance* application in few days or weeks ?

I like programming but one this that I hate is the first stage of
programming when you start creating the basic code (db connection,
interface, insert,update,etc), this is why I'm looking for a good
RAD tool that can speed up my programming.



-- 

Ahmad Fahad AlTwaijiry

-- 
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] WebMail client

2006-10-02 Thread Peter Lauri
Hi,

 

Do you have any suggestion on WebMail clients written in PHP that is good
and easy to install?

 

Horde IMP and SquirrelMail is two that I found. 

 

Are there any AJAX supporting client?

 

/Peter

 



RE: [PHP] a function for retuned vatiable

2006-10-02 Thread Peter Lauri
Not actually sure what you want, but this might do it :)

$j = 0;

While($Row = mysql_fetch_array($Result)) {
$email[$j] = $Row['email'];
...
...
$j++;
}

-Original Message-
From: Ross [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 02, 2006 7:09 PM
To: php-general@lists.php.net
Subject: [PHP] a function for retuned vatiable

What I need is a quick way to assign variable names to the same value of the

row name.

example..

$query= SELECT * from $table_name WHERE sname=='hulford';

  $result = mysql_query($query) or die('Error, query failed');
 while ($row=mysql_fetch_array($result)) {


$email = $row['email'];
$name=$row['name'];
$address = $row['address'];

//this goes on for 30 fields is there a way to automate this?


} 

-- 
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] Template system

2006-10-05 Thread Peter Lauri
Hi group,

 

I was curious of your experience of Template systems/parsers.

 

For the moment I am using the one available on www.berrewaerts.net/dev.
However, sometimes it feels like the parsing takes to long.

 

I am looking for a fast template parser that supports nested blocks etc to
be able to build more complicated pages structures.

 

Best regards,

Peter Lauri

 

www.lauri.se http://www.lauri.se/  - personal web site

www.dwsasia.com http://www.dwsasia.com/  - company web site

 

 



RE: [PHP] Template system

2006-10-05 Thread Peter Lauri
I haven't even read all replies, but the first one caught my love :-)

 

/Peter

 

www.lauri.se http://www.lauri.se/  - personal web site

www.dwsasia.com http://www.dwsasia.com/  - company web site

 

  _  

From: Dave Goodchild [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 05, 2006 5:59 PM
To: Peter Lauri
Cc: PHP
Subject: Re: [PHP] Template system

 

Smarty? smarty.php.net












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



[PHP] $_SERVER['HTTP_REFERER']

2006-10-08 Thread Peter Lauri
Hi guys,

 

I am trying to track where the people entered a unique page from (developing
an affiliate system).

 

I have been using the $_SERVER['HTTP_REFERER'] to track this and record it
on a affiliate entrance of the web site. However, that is not tracking all
clicks. Only some of them have. I assume some of the links are not from a
traditional a/a link.

 

Is there any other way to do this?

 

Best regards,

Peter Lauri

 

www.lauri.se http://www.lauri.se/  - personal web site

www.dwsasia.com http://www.dwsasia.com/  - company web site

 

 



RE: [PHP] Seperate HTML from PHP

2006-10-10 Thread Peter Lauri
Have you tried Smarty (smarty.php.net)?

-Original Message-
From: Sancar Saran [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 10, 2006 3:43 PM
To: php-general@lists.php.net
Subject: [PHP] Seperate HTML from PHP

Hi there, following words are my ideas about that HTML PHP parting. I hope
you 
can understand my broken english and do not take personally.

SEPERATING html FROM php ARE USELESS

For years, some php users try to show php to look like other programming 
languages like C or JAVA. I believe they try to prove PHP can act like other

programming languages because most professionals from other disciplines 
thinks that thing PHP was so easy to write to someting and because of this 
that PHP thing can't be a professional tool.

To show professionalisim of php, people start to make programs using 3 tier 
programming aproach. Then that MAGIC WORD seperating business layer from 
presentation layer comes to php land...

After some time community sees templating engines, today you will see lots
of 
them oh sorry TONS of them...

I'm sorry guys, I admire your efforts, REALLY. 

Personally I spend more than 2 years to create some kind of OO library to 
making forms easly.  And after some time I realize, we cannot standardize 
HTML/Javascirpt, every new project we have to challange to new interface 
problems and because of this I have to redesign that templating library to 
not broke code integritiy. Of course I may use that common library's to
solve 
problems and of course later or sooner I find myself into a deep trouble. 
That new project can't fit that lib.

And of course that was not only problem about templating engines. 
They are slow, hell yes SLOW. (yea yea I know your uber template system 
blazingly faster than more popular ones). You have to open tons of mini tpl 
files, have to parse them, have to manage them.

So if that templating system generates this much of problem why we should
use 
them ? Just Because of our uber HTML designer can't understand php ?.

I'm sorry, things are changing, nearly all new project are contains dynamic 
parts. These visual designers have to learn some degree of php code.

And also I believe we have to change aproaching and usage of php language.

I see most people using php dynamic part of their html code. They using php 
like

a href=somepage.php?a=?php echo $foo; ??php echo $bar; ?/a

And I suggest we can aproaching html marking language to part of php 
presentation layer. 

Like

?php
...
generate $head
generate $header
generate $left
generate $content
generate $right
generate $footer
...
include('theme.inc.php')
print $strOutput;
?

theme.inc.php
?php

$strOutput=!DOCTYPE html PUBLIC \-//W3C//DTD XHTML 1.0 Transitional//EN\

\http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\;
html xmlns=\http://www.w3.org/1999/xhtml\; lang=\en\
head
.$head.
/head
body
div id='mainDiv' class='cMainDiv'
div id='headDiv' class='cHeadDiv'
.$header.
/div
div id='contDiv' class='cContDiv'
table border='0' cellpadding='0'
cellspacing='1' width='100%'
tr
td id='contLeftTD'
class='cContLeftTD' valign='top'
.$left.
/td
td id='contCentTD'
class='cContCentTD' valign='top'
.$content.
/td
td id='contRightTD'
class='cContRightTD' valign='top'
.$right.
/td
/tr
/table
/div
div id='footDiv' class='cFootDiv'
.$footer.
/div
/div
/body
/html;

?
Also we can use php to generate some kind of html code to reduce our
workload, 
I believe best aproach was, do not generate data and html code in same 
function...

Seperating html generation and data generation best way to increase code 
reuse.

For example

function makeSelects($arrData,$strRequest)
{
$intSize = sizeof($arrData);
for($intS=0;$intS$intSize;$intS++)
{
@$strReturn.=option value='.$arrData[$intS]['val'].';
if(@$strRequest == $arrData[$intS]['val']) { $strReturn.= 
selected; }
$strReturn.= .$arrData[$intS]['tex']./option\n;
}
return $strReturn;
}

with this function we can generate select options. 

$sqlGetType = 
SELECT typeId,typeName
  FROM listType
 WHERE 

[PHP] PHP Mailer and SMTP = SPAM?

2006-10-10 Thread Peter Lauri
Hi,

 

I am developing a tell-a-friend application for one of my customers. We
are going to have it all located on their server, and want to make sure we
take the right decisions on the road so that we don't spam mark our server
and don't end up in the SPAM inbox of the recipients. This is how I have
prepared it all:

 

1.  We have setup an email that do have an inbox and is REAL. We have an
mailbox connected to it and can send and read emails from it via webmail and
pop
2.  We have an SMTP server that requires authentication
3.  We are going to use PHP Mailer

 

Using PHP Mailer and the SMTP sending function should make the emails look
pretty real, am I right? On that we make sure that the HTML that we create
is good, check that with http://spamcheck.sitesell.com
http://spamcheck.sitesell.com/  or similar.

 

Shouldn't I be pretty good to go? We are not talking about millions of
emails per day here, maybe a few thousands. What are the risks of ending up
being a spam marked ip?

 

Best regards,

Peter Lauri

 

www.lauri.se http://www.lauri.se/  - personal web site

www.dwsasia.com http://www.dwsasia.com/  - company web site

 

 

 



RE: [PHP] PHP Mailer and SMTP = SPAM?

2006-10-11 Thread Peter Lauri
[snip]
Unless the email is coming from somebody the recipient knows/trusts,
then you're going to get marked by them as a spammer -- which will
report back to some of the lists marking you as a spammer.
[/snip]

But is it not a problem sending from the SMTP server thedomain.com using
something else then the email [EMAIL PROTECTED] I am planning to send
from an existing email from the domain.

So even that I send from thedomain.com SMTP server I should to set the FROM
and REPLY TO to the person who is referring? Our main idea was to send the
email from the author of the book as it comes from him, but that is maybe
not a great idea?

So I am in the middle of two suggestions:

1. Make sure that the email is in the domain that you are sending from
2. Make sure that the emails is from the referring persons email so it won't
be marked as spam at their point.

This is what I got from Rick. What are you thoughts on this?

[snip]
when you do a dns lookup (from a machine not on the same network) on the
ipnumber of the sending mail server does it show a name? if you do a forward
lookup on that name, does that resolve to the (same) ipnumber? 

the answer to the first part must be yes, and ideally the second will be
yes. if the first is no, then don't bother sending from that machine
until that issue has been dealt with. 

sending html substantially increases the probability that your messages will
be tagged as spam. certain things will increase that probability. 

your point 2. is mostly irrelevant. an smtp server simply needs to be
configured so it is not an open relay. that is generally the default
configuration (of any MTA that's worth using), and is achievable without
smtp auth.
[/snip]

Best regards,
Peter Lauri

www.lauri.se - personal website
www.dwsasia.com - company website

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



[PHP] readfile() problem

2006-10-12 Thread Peter Lauri
Hi gang,

I have a problem. I am using readfile() to send files to the browser. The
code is below. I had is working on another server before, but now my client
have moved to a new server and we have started to experience problems with
bigger files.

I have three different files that I am sending. They are 3MB, 15MB and 59MB
large. The 3MB and 15MB are working fine, but the 59MB does not work. I have
checked so that the file_exist() and also was able to retrieve filesize() of
the file, so the file is there. I have also tried to download it with the
url I know it is located at, and that works too.

Is there any limitations or settings of how large the files can be when
using readfile()? If so, are they settable?

header(Pragma: public);
header(Expires: 0); // set expiration time
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
header(Content-Type: application/octet-stream);
header(Content-Disposition: attachment; filename=$Row[filename]);
header(Content-Transfer-Encoding: binary);
$filesize = filesize($filelocation);
header(Content-Length: $filesize); 
readfile($filelocation);

Best regards,
Peter Lauri

www.lauri.se - personal website
www.dwsasia.com - company website

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



RE: [PHP] PHP Mailer and SMTP = SPAM?

2006-10-12 Thread Peter Lauri
Thanks for your answer. I better think about this one more time, read some
more about it, and then execute :) I will let you know if it flops...

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 12, 2006 11:24 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: RE: [PHP] PHP Mailer and SMTP = SPAM?

On Wed, October 11, 2006 11:28 pm, Peter Lauri wrote:
 [snip]
 Unless the email is coming from somebody the recipient knows/trusts,
 then you're going to get marked by them as a spammer -- which will
 report back to some of the lists marking you as a spammer.
 [/snip]

 But is it not a problem sending from the SMTP server thedomain.com
 using
 something else then the email [EMAIL PROTECTED] I am planning to
 send
 from an existing email from the domain.

Not really -- at least not in my limited experience.

There are so many OTHER factors that the DNS resolution of the return
address and the actual SMTP machine not matching up are probably not a
deciding factor...

I could be wrong on this -- I don't run SMTP servers, and *most* of my
email is coming out from the same server, but I also have a contact
them link, and it seems to work fine, and is most certainly not using
return addresses whose DNS matches the sending server.

 So even that I send from thedomain.com SMTP server I should to set the
 FROM
 and REPLY TO to the person who is referring? Our main idea was to send
 the
 email from the author of the book as it comes from him, but that is
 maybe
 not a great idea?

Send the email From:  the person who actually typed it.

Anything else is more likely to trip you up in some other way, I
should think.

 So I am in the middle of two suggestions:

 1. Make sure that the email is in the domain that you are sending from
 2. Make sure that the emails is from the referring persons email so it
 won't
 be marked as spam at their point.

In an ideal world, you have a limited number of authors, and you can
configure YOUR SMTP server as a relay for them, thus meeting both
conditions.

rasmus AT dwsasia.com would a valid email, forwarding to a known valid
email for Rasmus the PHP Pocket Guide author.

So, you get the best of all worlds -- Custom emails on your site with
the correct DNS resolution to match the sender, the author's name in
the email address, even using the First Last [EMAIL PROTECTED]
format.

This satisfies all the conditions, at the minimal expense of setting
up an email forward for each author/recipient.

If I had easy access to control email setup, I'd do that on my site,
but I don't, so I just send them out with the return address of
whomever sent them.

Course I also throttle it so it can only send 4 emails per day from
one IP, and have a few other measures in place to limit spam abuse.

NOTE:
If the authors aren't typing the actual email, you do NOT want to be
sending it from them without their prior explicit review and consent
of the outgoing email.  Authors in particular are very picky about
what words you put in their mouth. :-)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] Internet Explorer - and File Download dialog box

2006-10-12 Thread Peter Lauri
Hi,

 

Is there any way to set so that the IE File Download dialog box can
understand UTF-8? I have some Thai named files that just end up like
nonsense :-)

 

/Peter

 

www.lauri.se http://www.lauri.se/  - personal website

www.dwsasia.com http://www.dwsasia.com/  - company website



RE: [PHP] readfile() problem

2006-10-12 Thread Peter Lauri
Hi,

It did help, but not perfectly. Sometimes I have to refresh a few times
before it will be pushed.

Best regards,
Peter

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 13, 2006 12:52 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] readfile() problem

On Thu, October 12, 2006 11:43 am, Peter Lauri wrote:
 I have a problem. I am using readfile() to send files to the browser.

 I have three different files that I am sending. They are 3MB, 15MB and
 59MB

 Is there any limitations or settings of how large the files can be
 when
 using readfile()? If so, are they settable?

readfile() will slurp the whole file into RAM, and then spit it out to
the browser.

It's super-convenient and easy for small files.

It's not a Good Idea for large files.

fopen/fread/echo loop is your buddy.

I'll bet a dollar that your old setting had a different memory_limit
in php.ini  -- or none at all, or it wasn't even compiled to allow
memory_limit -- something along those lines.

Actually, depending on the speed of the server, and its hard drives,
and the drive caches, etc, it's entirely possible that the server is
just taking TOO LONG to spit out that monster file.  wget would
probably let you find out pretty quickly if it's RAM or speed that's
killing you.  But it's kinda moot, really, as the solution either way
remains the same.

 header(Pragma: public);
 header(Expires: 0); // set expiration time
 header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
 header(Content-Type: application/octet-stream);
 header(Content-Disposition: attachment; filename=$Row[filename]);
 header(Content-Transfer-Encoding: binary);

You got Content-type: right, but you know that filename thing is only
going to work on some browsers, right?
http://richardlynch.blogspot.com

Actually, I think -Type should be -type and it might be
case-sensitive, but I'd have to re-read HTTP specs to be 100% sure,
and I think all the browsers ignore case anyway, so it's kind of moot,
and I'm not THAT bored...


//readfile($filelocation);
$file = fopen($filelocation);
while (!feof($file)){
  //Last I heard, 2048 optimized some PHP internal buffer...
  //That's probably way out of date!
  //And does not account for your bandwidth bottle-neck anyway.
  //Play with the 2048 until you're happy.
  echo fread($file, 2048);
}

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] PHP Mailer and SMTP = SPAM?

2006-10-12 Thread Peter Lauri
Thanks, that was very clear :)

-Original Message-
From: Roman Neuhauser [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 13, 2006 6:32 AM
To: Richard Lynch
Cc: Peter Lauri; php-general@lists.php.net
Subject: Re: [PHP] PHP Mailer and SMTP = SPAM?

# [EMAIL PROTECTED] / 2006-10-12 11:23:52 -0500:
 On Wed, October 11, 2006 11:28 pm, Peter Lauri wrote:
  [snip]
  Unless the email is coming from somebody the recipient knows/trusts,
  then you're going to get marked by them as a spammer -- which will
  report back to some of the lists marking you as a spammer.
  [/snip]
 
  But is it not a problem sending from the SMTP server thedomain.com
  using something else then the email [EMAIL PROTECTED] I am
  planning to send from an existing email from the domain.
 
 Not really -- at least not in my limited experience.
 
 There are so many OTHER factors that the DNS resolution of the return
 address and the actual SMTP machine not matching up are probably not a
 deciding factor...

Sender, client.example.org, IP 1.2.3.4 connects to the receiver
(server.example.org).

1. DNS - PTR RR. If 4.3.2.1.in-addr.arpa doesn't exist (the value
   would be client.example.org), server refuses the connection
2. DNS - A RR. If client.example.org doesn't exist or doesn't
   resolve to 1.2.3.4, server refuses the connection
3. DNS - RBL. If 1.2.3.4 is in any of a number of possible
   RBLs, server refuses the connection
4. DNS - RHSBL. If example.org is in any of a number of possible
   RHSBLs, server refuses the connection 
 
If the client passed all checks, the server accepts the connection:

S: 220 server.example.org ESMTP
C: HELO client.example.org
S: 250 Ok

5. SMTP - If client doesn't say HELO with a FQDN argument, or
6. SMTP - If the HELO command argument doesn't resolve to the client
   IP address, the server responds with a 4xx or 5xx.

C: MAIL FROM: [EMAIL PROTECTED]

7. DNS - MX or A RR. If neither of these records exists for
   elsewhere.org, server replies with 5xx, permanent error.

S: 450 Greylisted
C: QUIT

server replied with a 4xx temporary error code, the client (rightly)
disconnected. server in turn tries to send a message back to
[EMAIL PROTECTED] to see if it accepts email:

E: 220 erwin.elsewhere.org ESMTP
S: HELO server.example.org
E: 250 Ok
S: MAIL FROM: 
E: 250 Ok
S: RCPT TO: [EMAIL PROTECTED]
E: 250 Ok
S: QUIT

The empty FROM address is the special null address used to send
bounce messages.

Should erwin reply with 5xx to any of the commands from server,
[EMAIL PROTECTED] will be stored in a nondeliverables database, and
when client returns it'll be rejected:

C: MAIL FROM: [EMAIL PROTECTED]
S: 550 Sender rejected

I'm sure I forgot something or screwed the description here and
there, but you get the idea.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



RE: [PHP] readfile() problem

2006-10-13 Thread Peter Lauri
Hi, I am trying to do this, but now I cannot set values with ini_set. I do
the following and it outputs could not set. I have also tried 0, 0, but
that doesn't help.

if(ini_set(output_buffering, off)) echo could set;
else echo could NOT set;

/Peter


-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 13, 2006 4:59 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: RE: [PHP] readfile() problem

On Thu, October 12, 2006 3:26 pm, Peter Lauri wrote:
 It did help, but not perfectly. Sometimes I have to refresh a few
 times
 before it will be pushed.

Is output_buffering defaulted to on?...

Cuz then you're putting a whole SECOND copy of the output into PHP's
output buffer.

That's bad. :-)

ini_set the buffering off in that script, or just turn it off
entirely, or...

Sorry I missed that bit.  I never turn ob on in php.ini, so never
think of it.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] readfile() problem

2006-10-13 Thread Peter Lauri
You are correct. I might love you :)

-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 13, 2006 2:27 PM
To: Peter Lauri
Cc: [EMAIL PROTECTED]; php-general@lists.php.net
Subject: RE: [PHP] readfile() problem

On Fri, 2006-10-13 at 13:28 +0700, Peter Lauri wrote:
 Hi, I am trying to do this, but now I cannot set values with ini_set. I do
 the following and it outputs could not set. I have also tried 0, 0,
but
 that doesn't help.
 
 if(ini_set(output_buffering, off)) echo could set;
 else echo could NOT set;

I don't think you can set it at run-time, at least it wouldn't make
sense to me... looking at PHP it has the following semantic:

PHP_INI_PERDIR  

So you can't :) But the following might work without having to edit
a .htaccess:

?php

while( ob_get_level() )
{
ob_end_flush();
}

?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



RE: [PHP] GD, and GD JPEG

2006-11-26 Thread Peter Lauri
I don't know what environment you are on, because I have been absent from
this list a long while. If you are on a Linux distribution you might be able
to do this via the command line:

yum install php-gd.i386

service httpd restart

That might install GD and then restart the web server.

/Peter



-Original Message-
From: sublimenal [mailto:[EMAIL PROTECTED] 
Sent: Sunday, November 26, 2006 6:31 AM
To: php-general@lists.php.net
Subject: Re: [PHP] GD, and GD JPEG


Hey you need to ./configure it into your php installation via the command
line

Jeff-153 wrote:
 
 
   Hi there.
 I installed a script but it requires GD and GD JPEG
 
 I downloaded GD, and GD JPEG
 
 But how the heck do I install it?
 
 Thanks guys
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
View this message in context:
http://www.nabble.com/GD%2C-and-GD-JPEG-tf2705080.html#a7543299
Sent from the PHP - General mailing list archive at Nabble.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] How to not be abused by mail form injectors?

2006-12-06 Thread Peter Lauri
Except the check for \n and \r? I mean any class that you think is good
doing this? Is PHP Mailer doing any check of its variables?

/Peter

-Original Message-
From: Peter Lauri [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 06, 2006 11:10 PM
To: php-general@lists.php.net
Subject: [PHP] How to not be abused by mail form injectors?

Hi,

 

Are there any general protection methods to minimize the risk of robots
using your mailing forms as spam senders?

 

/Peter

 

 

 

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



[PHP] preg_match to preg_replace

2006-12-11 Thread Peter Lauri
Hi guys,

I have a sample string [hp-ex][log]peter[hall o] that I need to process. I
need to remove the [] and separate the sections with a space. If there are
more then one [] part the first part should be bold (add b/b around it).
I have a solution that is working very well, but am thinking that I can do
this with preg_replace directly, what do you think? The final output is
always found in $thestr. Can all this be done with one preg_replace?

?php

echo pre;

$str = [hp-ex][log]peter[hall o];

preg_match_all(/\[(.+?)\]/, $str, $matches);

print_r($matches);

$m1 = $matches[0];
$m2 = $matches[1];

if(count($m1)1) {
$m2[0] = b$m2[0]/b;
$thestr = implode( , $m2);
} elseif(count($m1)==1) {
$thestr = $m2[0];
} else $thestr = ;

echo $thestr;

echo /pre;

?

Best regards,
Peter Lauri

www.dwsasia.com - company website
www.lauri.se - personal website

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



RE: [PHP] Cookies page refresh

2006-12-12 Thread Peter Lauri
Hi,

I think it says somewhere in the documentation that the cookie values will
not be available until next request/response...

/Peter


-Original Message-
From: William Stokes [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 12, 2006 5:28 PM
To: php-general@lists.php.net
Subject: [PHP] Cookies  page refresh

Hello,

I have a page that uses session cookies for deciding what content to show to

a visitor. User also has 2 form objecks to apply filters to the content SQL 
queries. So at the beginning of the script I set 2 cookies based on user 
selections(or defaults) and after that make DB query based on user 
selections. I wanted to use cookies because there also back - up - 
forward links for pagination.

Problem is that in order to get the cookie based system to work the page 
needs a refresh to read the cookies and display content corretly. Is this 
because the page loads faster than the server set's the cookies to client 
browser? If so what's the corrert / best way to implement the filters and 
page navigation if there's 2 form select lists and 3 links to navigate the 
page.

Thanks
-Will

-- 
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] calling a function in the same page

2006-12-25 Thread Peter Lauri
Hi,

Are you trying to use PHP as a client scripting language?

What you are doing cannot be done with plain PHP, you have to invoke
JavaScript or similar to make a HTTP request and then parse it.

Search Google for AJAX and you could get it working using that. Prototype
is a easy to use JS library that you can do AJAX requests with and then do
what you want with by DOM.

/Peter


-Original Message-
From: Jahangir [mailto:[EMAIL PROTECTED] 
Sent: Sunday, December 24, 2006 5:34 PM
To: php-general@lists.php.net
Subject: [PHP] calling a function in the same page

I am trying to call a function from a href inside the same page.
this is the code:
echo brbra href=\isearch($query)\More results from Mysite/a;
// calling the function isearch

function isearch($query)

{$query=urlencode($query);

$request='http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=Ja
hangirquery=' .urlencode($query). 'output=phpresults=100site=mysite.com;

$response=file_get_contents($request);

if ($response === false) {

die('Request failed');}

$phpobj=unserialize($response);

$count=$phpobj[ResultSet][totalResultsReturned];

if($phpobj[ResultSet][totalResultsAvailable]==0)

{echo brNO RESULTS TO DISPLAY; }

echo tr; echo h4 style=\color:#FF\ align=\center\Results from
Mysite/h4;

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

{ echo 'pre';

$no=$i+1;

$url=$phpobj[ResultSet][Result][$i][Url];

echo h3 .$no. . a href=\$url\ .
$phpobj[ResultSet][Result][$i][Title] . /a/h3; echo /tr;

echo tr; echo $phpobj[ResultSet][Result][$i][Summary]; echo
/tr;

echo br; echo tr; echo b
.$phpobj[ResultSet][Result][$i][Url] ./b; echo /tr;

echo br; $link=$phpobj[ResultSet][Result][$i][DisplayUrl];

echo tr; echo a href=\$url\$link/a; echo /tr;

echo '/pre'; }}



whenever i try to execute this function i either get an Object not found
error or Access Forbidden error.

Can someone tell me where am i going wrong here??

thanks in advance

-- 
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] calling a function in the same page

2006-12-26 Thread Peter Lauri
This is what you could do. Separating them into a few files. Also read the
http://en.wikipedia.org/wiki/Ajax_%28programming%29 to learn some more about
AJAX.

You should also learn more about Server Side Scripting so you understand
what can be done with Server Side Scripting and Client Side Scripting.


index.php:

$query would contain the SQL (or is it some other query type) you want to
execute. This is far from any security as you come if this would be SQL, as
you would output the SQL and therefore give table names etc to anyone who
views the source of the HTML. This could in the future lead to SQL
injections etc if you don't protect your self against that as well. 

You would also need to include the javascript.js in your head tag of the
HTML that you generate. Also you would need to download the Prototype
library and include them in head as well. See
http://wiki.script.aculo.us/scriptaculous/show/Prototype where you can
download the necessary files to do your AJAX calls. If you want to do it the
hard coded way you need to create an ActiveXObject object if the user have
IE or an XMLHttpRequest object if user don't have a IE compatiable browser.
I suggest that you stick with Prototype unless you need to create an really
high performance tool for this, and might need to hard code it your self.

--
echo brbra href=\javascript:doSearch($query)\More results from
Mysite/a;
echo div id='resultsdiv'/div;
--



javascript.js:

--
function doSearch(sql) {
var success = function(t){
thediv = document.getElementById(resultsdiv);
thediv.innerHTML = t.responseText;
}

var failure = function(t){
alert(Something went wrong, please try again.);
}

var url='ajax.php';

pars = query=+ query;

var req= new Ajax.Request(url, {method: 'post', postBody:pars,
onSuccess: success, onFailure: failure});

}
--



ajax.php

--
//Set header to TEXT/HTML and also whatever enc type you want.
header(Content-type: text/html);

if(isset($_POST['mysql'])) {
//do whatever you want with the
//$_POST['mysql'] variable and output the results
//the you want to be shown in the div with id resultsdiv
}
--


Best regards,
Peter Lauri


-Original Message-
From: Aras [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 26, 2006 11:50 AM
To: php-general@lists.php.net
Subject: RE: [PHP] calling a function in the same page



You can not call PHP functions through a href which is used for linking web
pages.
You need to create a new file or use a switch in your current file for
search input,
with the function in it. So that you can link to that URL, not the function
itself.

You can use AJAX as well, to send commands to a php file and get the results
in xml/text,
but again you need to call Javascript there, your logic is totally wrong.


Aras Koktas
[EMAIL PROTECTED]
Business Excellence Development
Phi.dot Internet Systems


-Original Message-
From: Jahangir [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 24, 2006 6:34 PM
To: php-general@lists.php.net
Subject: [PHP] calling a function in the same page


I am trying to call a function from a href inside the same page.
this is the code:
echo brbra href=\isearch($query)\More results from Mysite/a;
// calling the function isearch

function isearch($query)

{$query=urlencode($query);

$request='http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=Ja
hangirquery=' .urlencode($query). 'output=phpresults=100site=mysite.com;

$response=file_get_contents($request);

if ($response === false) {

die('Request failed');}

$phpobj=unserialize($response);

$count=$phpobj[ResultSet][totalResultsReturned];

if($phpobj[ResultSet][totalResultsAvailable]==0)

{echo brNO RESULTS TO DISPLAY; }

echo tr; echo h4 style=\color:#FF\ align=\center\Results from
Mysite/h4;

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

{ echo 'pre';

$no=$i+1;

$url=$phpobj[ResultSet][Result][$i][Url];

echo h3 .$no. . a href=\$url\ .
$phpobj[ResultSet][Result][$i][Title] . /a/h3; echo /tr;

echo tr; echo $phpobj[ResultSet][Result][$i][Summary]; echo
/tr;

echo br; echo tr; echo b
.$phpobj[ResultSet][Result][$i][Url] ./b; echo /tr;

echo br; $link=$phpobj[ResultSet][Result][$i][DisplayUrl];

echo tr; echo a href=\$url\$link/a; echo /tr;

echo '/pre'; }}



whenever i try to execute this function i either get an Object not found
error or Access Forbidden error.

Can someone tell me where am i going wrong here??

thanks in advance

--
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] pattern containing single quote in IF statement

2006-12-26 Thread Peter Lauri
Quote:

here is the code:
 if($_GET['query']==new)
 { filter($query);}
 elseif($_GET['query']==some'u'all)
 { filter($query);}
 elseif($_GET['query']==all'u'ppl)
 { filter($query);}


Did you forget about  around the strings?

/Peter

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - a way to reduce your carbon emissions and be a
helping hand in the struggle against global warming

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



RE: [PHP] GD 2.0.28 + PHP 4.4.2 + pixelation :(

2006-12-27 Thread Peter Lauri
Hi,

imagecopyresampled might help you... I use that and it works without
problems.

/Peter

-Original Message-
From: Steven Macintyre [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 27, 2006 10:17 AM
To: php-general@lists.php.net
Subject: [PHP] GD 2.0.28 + PHP 4.4.2 + pixelation :(

Hi All,

I have done some searching via google and some answers say change
copyimageresampled to copyimageresized etc 

I have tried all fixes ... to no avail


I have one image here 1280 x 960 (150 dpi) 24 depth

When using the following it pixelates ... 

function createthumb($name,$filename,$new_w,$new_h)
{
$system=explode(.,$name);
$src_img=imagecreatefromjpeg($name);
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x  $old_y)
{
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x  $old_y)
{
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y)
{
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);

imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
imagejpeg($dst_img,$filename);
imagedestroy($dst_img);
imagedestroy($src_img);
}

Which I am of course calling with
createthumb($add,'../pics/'.$largeval,350,263);

Now ... afaik my new sizes are proportional to the big ones ... but it
pixelates :(

However,

Using an image 1600 x 1200 (96 dpi) 24 depth it works and there is no
pixilation

Can someone perhaps assist now?


  
Kind Regards,


Steven Macintyre
http://steven.macintyre.name
--

http://www.friends4friends.co.za

-- 
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] PDFlib problem

2006-12-27 Thread Peter Lauri
Try this one:

http://pecl.php.net/bugs/bug.php?id=9491edit=1

/Peter

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free



-Original Message-
From: Rosen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 27, 2006 2:58 PM
To: php-general@lists.php.net
Subject: [PHP] PDFlib problem

Hi,
I have problem with PDFlib on Windows 2000, PHP 5.2.0 and Apache 2.2.3

When I try to execute:

$p = new PDFlib();

in the Apache log I receive:
PDFlib exception (fatal): [1202] PDF_set_parameter: Unknown key 'objorient'
[.] [notice] Parent: child process exited with status 99 -- Restarting.

And nothing happens - I receive Problem loading page.

Can someone help?

Thanks in advance,
Rosen

-- 
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: PDFlib problem

2006-12-27 Thread Peter Lauri
http://www.pdflib.com/download/pdflib-family/pdflib-6/

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free

-Original Message-
From: Rosen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 27, 2006 4:40 PM
To: php-general@lists.php.net
Subject: [PHP] Re: PDFlib problem

Thank you all,
But from where I can download new version ( binary)  of  PDFlib  for windows

?


Rosen [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi,
 I have problem with PDFlib on Windows 2000, PHP 5.2.0 and Apache 2.2.3

 When I try to execute:

 $p = new PDFlib();

 in the Apache log I receive:
 PDFlib exception (fatal): [1202] PDF_set_parameter: Unknown key 
 'objorient'
 [.] [notice] Parent: child process exited with status 99 --  
 Restarting.

 And nothing happens - I receive Problem loading page.

 Can someone help?

 Thanks in advance,
 Rosen 

-- 
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] Simple PDF manipulation

2006-12-27 Thread Peter Lauri
FPDF might do the same thing, won't it?

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free




-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 27, 2006 11:11 PM
To: php-general@lists.php.net
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Simple PDF manipulation

Yeah, this is exactly what we do at my work.  We have a license for PDFLib
and essentually we load blank forms and then say take this text and position
it at this location.  Kind of like putting words on a clear piece of acetate
and overlaying it on top of a piece of paper.

If I recall, we had issues trying to do this with fpdf and some other PHP
PDF libraries, but PDFlib allowed us to do it and it's what we've used ever
since.

Actually, tedd.. did you use PDFlib or another library or maybe something in
PHP5 (that we don't use yet)?  We may be moving off of PDFlib at some point
and I may be looking for alternatives.  This is the main function we need.
Ignorant question, but I havn't even thought of researching it yet and
figured I'd ask while the topic was at hand.

-TG

= = = Original message = = =

Interesting, that's a good idea. I was not aware that it was possible  
to load an existing PDF into memory and then add stuff to it.


On Dec 27, 2006, at 7:28 AM, tedd wrote:

 At 6:32 AM -0800 12/27/06, Brian Dunning wrote:
 Let's say I have a complicated PDF document, like a Christmas  
 card, that was made in Illustrator -- too complicated to easily  
 create from scratch using PDFlib. Is there a way to use PHP make  
 simple text changes - like changing Dear XXX to Dear John?  
 I've opened the files with a text editor and cannot locate the  
 simple text, it appears to be encoded somehow. The PDF has no  
 security or encryption in it. Thanks

 Brian:

 I'm not saying that there is/isn't a way to do this, but I tried  
 and failed.

 In my investigation, I found that the insides of a PDF file are not  
 conducive to a simple search and replace mechanism. The text is  
 encoded in some fashion that is not easy to decode and reassemble.

 The solution I came up with was to combine the existing PDF file  
 with my coding and write over (on top of) the old to produce the  
 new PDF that I wanted. In your case, take your Christmas Card with  
 a big space where xxx appears and then write over that space with  
 John in your new code.

 I wish someone would show me a simpler way to do this.

 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



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.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] Chocked

2006-12-28 Thread Peter Lauri
I was chocked when I got my additional dedicated server from my server
provider. I assumed everyting would have been the same as I ordered the
server with same package name etc. The chocking part was that the server had
PHP5 and not PHP4.

 

Ok, it is not a hard piece of work to get it working, but one thing stunned
me :-)

 

Assuming that I have the following structure:

 

/index.php

/classes/first.class.php

/classes/second.class.php

 

Index.php:

 

include_once(classes/first.class.php);

 

 

first.class.php

 

include_once(second.class.php);

 

 

This worked fine, but this time I get an open dir error. Is this something
that is new to PHP5 for this, or do I just need to config the server to
accept this sloppy including of files?

 

Best regards,

Peter Lauri

 

 http://www.dwsasia.com/ www.dwsasia.com - company web site

 http://www.lauri.se/ www.lauri.se - personal web site

 http://www.carbonfree.org.uk/ www.carbonfree.org.uk - become Carbon Free

 



RE: [PHP] Re: Chocked

2006-12-29 Thread Peter Lauri
Hi,

I got it working before the post, but I was just curious if there were any
change from php4 to php5 as I have been using that method for a while now.

Best regards,
Peter Lauri

www.dwsasia.com  - company web site
www.lauri.se  - personal web site
www.carbonfree.org.uk  - become Carbon Free



-Original Message-
From: Johannes Lindenbaum [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 29, 2006 4:24 AM
To: php-general@lists.php.net
Subject: [PHP] Re: Chocked

I think this is correct:

Let's just assume for a minute that in your index.php you echo out getcwd();
Output would be / (only an example)

According to that you do the following include:
include(./classes/first.class.php);

If you were to echo getcwd() after the include in the first.class.php it 
would output /

You would then have to include your second class (inside the 
first.class.php - correct?) as:
include(./classes/second.class.php)
to make it a correct include without PHP having to search the 
directories for the include.

Give that a shot.

Regards,
Johannes

-- 
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] help with \n\r in strings

2006-12-29 Thread Peter Lauri
Try:

$string_as_array = explode(\n, $string);

echo pre;
print_r($string_as_array);
echo /pre;

The array that you get will contain segments of the string that is separated
with \n. Let me know if that helps. 

Best regards,
Peter Lauri

www.dwsasia.com  - company web site
www.lauri.se  - personal web site
www.carbonfree.org.uk  - become Carbon Free

-Original Message-
From: Angelo Zanetti [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 29, 2006 10:43 AM
To: PHP List
Subject: [PHP] help with \n\r in strings

Hi all,

I receive a text file with a whole bunch of strings. and each line is 
terminated by what I presume is \n\r however when I read the string into 
PHP, it seems that the last column of the row and the first column of 
the next row are connected but it appears as a space but I've done all 
kinds of tests like $spacePos = strrpos($dateAmount, ' '); but this is 
always empty.

So is there a way to test for \r\n? or what else can I use to delimit 
these two values (last column of row and first column of next row)?

Thanks in advance.

Angelo
   
-- 

Angelo Zanetti
Systems developer


*Telephone:* +27 (021) 469 1052
*Mobile:*   +27 (0) 72 441 3355
*Fax:*+27 (0) 86 681 5885
*
Web:* http://www.zlogic.co.za
*E-Mail:* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]

-- 
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] Javascript detection

2007-01-01 Thread Peter Lauri
I do have javascript enabled, but it does not detect it...

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free




-Original Message-
From: tedd [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 01, 2007 11:14 PM
To: php-general@lists.php.net
Subject: [PHP] Javascript detection

Hi gang:

I've asked this request on a couple of other list, but considering 
that I've done this with a mixture of php and javascript, perhaps 
some of you might check this out for me.

Try this:

http://sperling.com/js_detect

Does this technique work to detect your browser's javascript setting?

Also, if you change your browser's javascript setting, please restart 
your browser before rechecking the link.

If this works well enough, I'll post the code.

Thanks.

tedd

PS: I wrote this simply because I couldn't find an acceptable PHP 
Javascript detection solution. If anyone knows of something better, 
please let me know.
-- 
---
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] Please help me

2007-01-02 Thread Peter Lauri
I also use PHPmailer to send emails. However it is good to do it the 'hard'
way once to learn about mailing headers etc.

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free



-Original Message-
From: Steven Macintyre [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 02, 2007 2:44 PM
To: php-general@lists.php.net
Subject: RE: [PHP] Please help me

 When I send a mail using php using mail(), and using html tags in
 message
 body , these tags are being displayed as it is.
 Please let me know if there's any way of how to tackle with this.

I use phpmailer for all my email sending ... 

Never had a problem with it

S

-- 
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] How to read cookies set by php?

2007-01-02 Thread Peter Lauri
Are you trying to read cookies that are not set by your host? If that is the
case you will probably be disappointed. The purpose with cookies is that
they should only be table to be read by the one who is setting the cookie.

If you want to read cookies on the machine that you are able to view just:

echo pre;
print_r($_COOKIE);
echo /pre;

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free



-Original Message-
From: Dotan Cohen [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 02, 2007 4:17 PM
To: php php
Subject: [PHP] How to read cookies set by php?

I'm trying to debug some scripts, and I see that the contents of
cookies seems to be encoded (in Firefox2 on Kubuntu, at least). How
can one read the cookies stored on his machine?

Dotan Cohen

http://what-is-what.com/what_is/gmail.html
http://datip.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] Concerning SSL

2007-01-02 Thread Peter Lauri
Make the src ABSOULUTE and it will work. When you are using relative links
as you are right now the web server will look in the
https://www.mywebsite.com/images

Best regards,
Peter Lauri

www.dwsasia.com  - company web site
www.lauri.se  - personal web site
www.carbonfree.org.uk  - become Carbon Free


-Original Message-
From: R. Van Tassel [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 02, 2007 6:33 PM
To: php-general@lists.php.net
Subject: RE: [PHP] Concerning SSL

How do you correct the image URLs? That's what I'm asking.

I have a website that is secure. When you change the URL from
http://www.mywebsite.com
to
https://www.mywebsite.com

the images disappear.

The images are codes as relative links:

http://www.mywebsite.com/images/myimage.jpg

is coded as img src=images/myimage.jpg / if a root file

is coded as img src=../images/myimage.jpg / if in a directory



-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 02, 2007 11:27 AM
To: R. Van Tassel
Cc: php-general@lists.php.net
Subject: Re: [PHP] Concerning SSL

R. Van Tassel wrote:
 Hello everyone, I hope you all had a great new year.
 
 I'm having an issue with a website where changing the URL from http:// to
 https:// makes the images disappear. The images are all relative and not
 absolute.
 
 How can I fix this?

correct the image URLs? clear your cache?

we gave up mind-reading on the list last year, please provide us with
some actual info otherwise we can't help you.

 
 Thanks,
 -Roy
 

-- 
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] Pushing a file to the browser

2007-01-03 Thread Peter Lauri
Hi,

I assume that you mean you want to send the file as
application/octet-stream. Take a look at this:


ob_start();

$path = 'path to directory where file resides';
$filename = 'the name of the file';

ob_end_clean();

header(Pragma: public);
header(Expires: 0); // set expiration time
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
header(Content-Type: application/octet-stream);
header(Content-Disposition: attachment; filename=$filename);
header(Content-Transfer-Encoding: binary);
$filesize = filesize($path.$filelocation);
header(Content-Length: $filesize);

echo file_get_contents($path.$filelocation);



You could also use fread() or similar if the file is larger.

Let me know if it helped.

Best regards,
Peter Lauri

www.dwsasia.com  - company web site
www.lauri.se  - personal web site
www.carbonfree.org.uk  - become Carbon Free


-Original Message-
From: Mike Mannakee [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 16, 2006 2:39 AM
To: php-general@lists.php.net
Subject: [PHP] Pushing a file to the browser

Hello,

I have a script I've created which takes a file upload, monkeys with the 
data in it, and needs to push the new file out to the browser.  Everything 
is coded and working up to that last point, but I've never pushed out a file

to the browser before.  Does anyone have the code for this laying around 
that I can see (and modify)?

Mike 

-- 
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] File reading code2

2007-01-06 Thread Peter Lauri
This just dumps the content to the browsers. You could use file() instead if
you want to loop thru every line.

$file = test1.txt;

if(file_exists($file)) {
if(is_readable($file)) {
if($file_content = get_file_contents($file)) {
echo pre;
echo $file_content;
echo /pre;
} echo Something went wrong;  
} else echo Cannot read the file '$file', check permissions;
} else echo The file '$file' does not exist in this directory;

You should learn how to read the manual, because in the end we will not do
this kind of things if it already is in the manual.

http://th.php.net/manual/en/function.file-get-contents.php

http://th.php.net/file

Best regards,
Peter Lauri

www.dwsasia.com  - company web site
www.lauri.se  - personal web site
www.carbonfree.org.uk  - become Carbon Free



-Original Message-
From: Delta Storm [mailto:[EMAIL PROTECTED] 
Sent: Saturday, January 06, 2007 10:39 AM
To: php-general@lists.php.net
Subject: [PHP] File reading code2

Hi,

Can someone make me an example of simple reading a *.txt file on a hard 
drive
and displaying that file with a echo command or some loop or anything
path to file:

(C:\Program Files\XAMPP\xampp\htdocs\test_folder\test1.txt) btw the 
script is in this folder to.

Full code please.


Thanks in advance!

-- 
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: Search script problem

2007-01-06 Thread Peter Lauri
Have you tried to catch (echo) the query you try to execute in mysql and
then debug it from there?

I saw that you in your code did all in one row. Separate it to:

$Query = your query;

echo $Query; //Use this in phpMyAdmin or any other MySQL administrator and
see if the query is correct. If you get matches there your code should be
fine.

$Result = mysql_query($Query);
...
...


Best regards,
Peter Lauri

www.dwsasia.com  - company web site
www.lauri.se  - personal web site
www.carbonfree.org.uk  - become Carbon Free


-Original Message-
From: Wikus Moller [mailto:[EMAIL PROTECTED] 
Sent: Sunday, January 07, 2007 1:20 AM
To: php-general@lists.php.net
Subject: [PHP] Re: Search script problem

So it should be like this (it still doesn't show the results):

?php

echo ?xml version=\1.0\ encoding=\UTF-8\?;
echo !DOCTYPE HTML PUBLIC \-//W3C//DTD XHTML Mobile 1.0//EN\
\http://www.wapforum.org/DTD/xhtml-mobile10.dtd\;;
echo html xmlns=\http://www.w3.org/1999/xhtml\;;

error_reporting(E_ALL ^ E_NOTICE);

$pwd = $_GET[pwd];
$uid = $_GET[uid];
$action = $_GET[action];
$cid = $_GET[cid];
$sid = $_GET[sid];
$var = $_GET[q];

include (function.php);
include (config.php);
connect($dbserver,$dbname,$dbuser,$dbpass);



/Search main page
if(!isset($var)){
echo head;
echo titleSearch Engine/title;
echo style type=\text/css\
   .m3 {background-color: #291C6F;}
   .n1 {background-color: #A0A0A0;}
   .n2 {background-color: #88;}
   .c2 {color: #00;}
   .m2 {color: #91D0FF;}
   body   {font-family: Arial, sans-serif;
   font-size: 12px;
   color: #ff;
   background-color: #33;
   margin-left: 0px;
   margin-right: 0px;
   margin-top: 0px;}
   .ct1 {font-family: Arial, sans-serif;
   font-size: 12px;
   color: #800080;}
   .cre {background-color: #1300A4;
   padding: 2px 2px 2px 2px;
   margin: 3px 0 0;
   font-size: 12px;
   color:#00;
   text-align: center;
   border-width:1px 0;
   border-style:solid;
   border-color:#00;}
/style;
echo /head;
echo body;
echo table;
echo div class=\cre\;
echo bSearch Engine/b/div;
echo form method=\GET\
action=\search.php?uid=$uidamp;pwd=$pwd\; ///the uid and pwd is
nessecary cause my member features are very basic and the urls is used
to keep the user 'logged in'
echo Keywords: input type=\text\ name=\q\ /br/;
echo input type=\submit\ name=\Submit\/;
echo /form;
echo /table;
echo div class=\cre\img src=\images/home.gif\ alt=\*\/a
href=\index.php?uid=$uidamp;pwd=$pwd\Home/a/div;
echo /body;
echo /html;
}

///Display Results

if(isset($var)){
$var = $_GET[q];
$trimmed = trim($var); //trim whitespace from the stored variable
echo head;
echo titleSearch Results/title;
echo style type=\text/css\
   .m3 {background-color: #291C6F;}
   .n1 {background-color: #A0A0A0;}
   .n2 {background-color: #88;}
   .c2 {color: #00;}
   .m2 {color: #91D0FF;}
   body   {font-family: Arial, sans-serif;
   font-size: 12px;
   color: #ff;
   background-color: #33;
   margin-left: 0px;
   margin-right: 0px;
   margin-top: 0px;}
   .ct1 {font-family: Arial, sans-serif;
   font-size: 12px;
   color: #800080;}
   .cre {background-color: #1300A4;
   padding: 2px 2px 2px 2px;
   margin: 3px 0 0;
   font-size: 12px;
   color:#00;
   text-align: center;
   border-width:1px 0;
   border-style:solid;
   border-color:#00;}
/style;
echo /head;
echo body;
echo div class=\cre\;
echo bSearch Results/b/div;
echo table;
 // Get the search variable from URL



// check for an empty string and display a message.
if ($trimmed == )
 {
 echo Please enter a search...;
 exit;
 }



if($pg==0)$pg=1;
 $pg--;
 $lmt = $pg*20;
 $pg++;
 $cou =$lmt+1;
 $scount = mysql_fetch_array(mysql_query(SELECT COUNT(*) FROM table
WHERE keywords like \%$trimmed%\ AND banned='0' AND hits_in =
'2'));
 $pgs = ceil($scount[0]/20);
 // Build SQL Query
 $sql = SELECT * FROM table WHERE keywords like \%$trimmed%\ AND
banned='0' and hits_in ='2' ORDER by hits_in DESC LIMIT .$lmt., 20;;
// EDIT HERE and specify your table and field names for the SQL query
 $sites=mysql_query($sql);


while ($site = mysql_fetch_array($sites))
{
   $dscr =htmlspecialchars($site[11]);
   $snm=htmlspecialchars($site[1]);
   echo trtd align=\left

RE: [PHP] Domain Search

2007-01-09 Thread Peter Lauri
Most domain wholesale sites have it. www.onlinenic.com has it, I am sure
that godaddy.com has it as well. Joker.com has it.

Best regards,
Peter Lauri

www.dwsasia.com  - company web site
www.lauri.se  - personal web site
www.carbonfree.org.uk  - become Carbon Free

-Original Message-
From: Marcelo Ferrufino Murillo [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 09, 2007 4:23 PM
To: php-general@lists.php.net
Subject: [PHP] Domain Search

I have to make a domain search so I don´t know if there is an API or
something that could help me in this o if you know how I could make this.
Thank you.

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



RE: [PHP] most powerful php editor

2007-01-21 Thread Peter Lauri
I would put my vote on Eclipse. It has great support for cvs and also for
general coding autofilling etc. The downside is that it is resource
demanding...

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free


-Original Message-
From: Vinicius C Silva [mailto:[EMAIL PROTECTED] 
Sent: Sunday, January 21, 2007 2:54 AM
To: php-general@lists.php.net
Subject: [PHP] most powerful php editor

hi everyone!

i'd like to ask something maybe commonly asked here. what is the most
powerful php editor?

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



[PHP] Re: fwrite/fclose troubles

2008-03-20 Thread Peter Ford

Mark Weaver wrote:

Hi all,

I've been lurking and reading now for some time, but have decided to
come out of the shadows cause I've got an issue that's gonna drive me 
crazy!


I'm developing an application and within this application is a class
that is very simple and only serves a singular purpose - to make log
entries to help with debugging. Problem is, now I'm debugging the damned
logging class that is supposed to be helping me debug the application as
I'm putting it together! sigh I've looked and looked all over the
place, but I don't seem to be able to find an answer to this problem.
The only information that I have found so far deals with permissions and
I don't think that's the problem. At first I was getting an access
denied error but since setting dir perms and log file perms so that both
apache and my user can right to both the directory and the file that one
has gone away.

Log Directory permissions: /mystuff/logs  rwx-rwx-rwx (777)
Log file permissions: /mystuff/logs/run.log   rwx-rwx-rwx
(777)

At any rate, the following is the information I'm getting in the apache
error_log while working on this particular portion of the application:

PHP Warning:  fwrite(): supplied argument is not a valid stream resource
in /mystuff/inc/Log.inc on line 22,
PHP Warning:  fclose(): supplied argument is not a valid stream resource
in /mystuff/inc/Log.inc on line 23,

The Log class:
-
class Log{
public $path, $entry, $logfile;

public function Log(){}

public function setLog($path,$file){

$this-path = $path;
$this-logfile = $file;
}

public function writeLog($entry){

// open the file, in this case the log file
$h = $this-path/$this-logfile;
fopen($h, 'a+');
fwrite($h,$entry);
fclose($h);
}
}

Code snippet where attempting to write log entry from program:
 


$pl_log = new Log;
$pl_log-setLog($logpath,run.log);
   
$usernanme = $_POST['username'];

$password = $_POST['secret'];
   
/**

   * (debugging) logging incoming values from form:
   */
$pl_log-writeLog(getDateTime(): Incoming values from Login Form:
blah...blah...blah\n);

Any help with this would be most appreciated. (be gentle... I'm a PERL
program learning PHP OOP)




As Stut pointed out, you've misunderstood the difference between a file resource 
and a file name.


Try something like:


 public function writeLog($entry)
 {
 // open the file, in this case the log file
 $fileName = $this-path.'/'.$this-logfile;
 $h = fopen($fileName, 'a+');
 fwrite($h,$entry);
 fclose($h);
 }

The file resource that fwrite and fclose need is the *result* of opening the 
file, not the file name as you were doing.
Ideally, you would check the value of $h after the fopen call, to make sure that 
it had successfully opened the file.


Also, I changed the way you were constructing the file name: interpolating the 
variables in a string is slightly less efficient than concatenating the bits 
together, and there are possible gotchas when using the $this-variable 
structure in a string like that.

An alternative syntax is to escape the variables with braces:

$fileName = {$this-path}/{$this-logfile};


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: Pattern etc to reduce duplicated validation?

2008-03-27 Thread Peter Ford

David Lidstone wrote:

Hi All

I seem to be writing a lot of this:


// SCRIPT =
$var = $_POST['var'];

// validate $var

$foo = new foo;
$foo-setBar($var);


// CLASS ==
class foo {
public function setBar($var) {
// validate $var
}
}


As you can see, the issue is that I am validating the input in my 
script, and then again in my class... surely unwanted duplication!? 
Obviously (I think!), I need to be validating at the level of my class, 
so does anyone have a pattern / strategy to help ease the pain... a way 
of using the validation in the class to validate the script and return 
meaningful errors to the user?? Throwing errors and forcing the script 
to catch them perhaps?
I have tried a few validation classes etc and they have not really 
addressed this issue. Perhaps I should just live with it and get on with 
it! :)


Many thanks for your help, David



Well, you could try looking at using exceptions:

// CLASS 
class foo
{
public function setBar($var)
{
if ( var_is_NOT_a_valid_value_for_bar )
{
throw new Exception('Invalid value for bar in class foo');
}
}
}

// = Script =
$var = $_POST['var'];
$foo = new foo();
try
{
$foo-setBar($var);
}
catch (Exception $e)
{
echo 'An error occurred: ',$e-getMessage(),\n;
}


Take a look at http://www.php.net/manual/en/language.exceptions.php


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Re: optimilize web page loading

2008-03-27 Thread Peter Ford

Jason Pruim wrote:


On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote:

Al wrote:

Good point.  I usually do use the single quotes, just happened to key
doubles for the email.

Actually, it's good idea for all variable assignments.

Philip Thompson wrote:

On Mar 26, 2008, at 6:28 PM, Al wrote:

Depends on the server and it's load.  I've strung together some
rather large html strings and they aways take far less time than the
transient time on the internet. I used to use OB extensively until
one day I took the time to measure the difference. I don't recall the
numbers; but, I do recall it was not worth the slight extra trouble
to use OB.

Now, I simple assemble by html strings with $report .= foo; And
then echo $report at the end. It also makes the code very easy to
read and follow.


You might as well take it a step further. Change the above to:

$report .= 'foo';

This way for literal strings, the PHP parser doesn't have to evaluate
this string to determine if anything needs to be translated (e.g.,
$report .= I like to $foo). A minimal speedup, but nonetheless...

~Philip



Andrew Ballard wrote:

On Wed, Mar 26, 2008 at 1:18 PM, Al [EMAIL PROTECTED] wrote:

You are really asking an HTML question, if you think about it.

At the PHP level, either use output buffering or assemble all your
html string as a variable and
then echo it.  The goal is to compress the string into the minimum
number of packets.
Yes, but do so smartly. Excessive string concatenation can slow 
things
down as well. On most pages you probably won't notice much 
difference,

but I have seen instances where the difference was painfully obvious.
Andrew


Yes and if your script takes .0002 seconds
to run using double quotes it will only take
.00019 seconds with single (depending upon
how many quotes you have of course)  :-)


I'm coming in late to this thread so sorry if I missed this :)

How much of a difference would it make if you have something like this: 
echo $foo bar bar bar bar $foo $foo; verses: echo $foo . bar bar bar 
bar . $foo $foo; ?In other words... You have a large application which 
is most likely to be faster? :)





There was a discussion about this a few weeks ago - ISTR that the compiler does 
wierd things with double-quoted strings, something like tokenising the words and 
checking each bit for lurking variables.

So in fact

  echo $foo bar bar bar bar $foo $foo;

is slowest (because there *are* variables to interpolate,

  echo $foo .  bar bar bar bar .$foo. .$foo;

is a bit faster, but the double-quoted bits cause some slow-down,

  echo $foo . ' bar bar bar bar '.$foo.' '.$foo;

is a bit faster again - the single quoted bits pass through without further 
inspection, and finally


  echo $foo,' bar bar bar bar ',$foo,' ',$foo;

is actually the fastest, because the strings are not concatenated before output.

I think that was the overall summary - I can't locate the original post to 
verify (or attribute) but it's in this list somewhere...


Cheers

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Re: optimilize web page loading

2008-03-28 Thread Peter Ford

Eric Butera wrote:

On Thu, Mar 27, 2008 at 12:41 PM, Peter Ford [EMAIL PROTECTED] wrote:

Jason Pruim wrote:
 
  On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote:
  Al wrote:
  Good point.  I usually do use the single quotes, just happened to key
  doubles for the email.
 
  Actually, it's good idea for all variable assignments.
 
  Philip Thompson wrote:
  On Mar 26, 2008, at 6:28 PM, Al wrote:
  Depends on the server and it's load.  I've strung together some
  rather large html strings and they aways take far less time than the
  transient time on the internet. I used to use OB extensively until
  one day I took the time to measure the difference. I don't recall the
  numbers; but, I do recall it was not worth the slight extra trouble
  to use OB.
 
  Now, I simple assemble by html strings with $report .= foo; And
  then echo $report at the end. It also makes the code very easy to
  read and follow.
 
  You might as well take it a step further. Change the above to:
 
  $report .= 'foo';
 
  This way for literal strings, the PHP parser doesn't have to evaluate
  this string to determine if anything needs to be translated (e.g.,
  $report .= I like to $foo). A minimal speedup, but nonetheless...
 
  ~Philip
 
 
  Andrew Ballard wrote:
  On Wed, Mar 26, 2008 at 1:18 PM, Al [EMAIL PROTECTED] wrote:
  You are really asking an HTML question, if you think about it.
 
  At the PHP level, either use output buffering or assemble all your
  html string as a variable and
  then echo it.  The goal is to compress the string into the minimum
  number of packets.
  Yes, but do so smartly. Excessive string concatenation can slow
  things
  down as well. On most pages you probably won't notice much
  difference,
  but I have seen instances where the difference was painfully obvious.
  Andrew
 
  Yes and if your script takes .0002 seconds
  to run using double quotes it will only take
  .00019 seconds with single (depending upon
  how many quotes you have of course)  :-)
 
  I'm coming in late to this thread so sorry if I missed this :)
 
  How much of a difference would it make if you have something like this:
  echo $foo bar bar bar bar $foo $foo; verses: echo $foo . bar bar bar
  bar . $foo $foo; ?In other words... You have a large application which
  is most likely to be faster? :)
 
 

 There was a discussion about this a few weeks ago - ISTR that the compiler does
 wierd things with double-quoted strings, something like tokenising the words 
and
 checking each bit for lurking variables.
 So in fact


   echo $foo bar bar bar bar $foo $foo;

 is slowest (because there *are* variables to interpolate,


   echo $foo .  bar bar bar bar .$foo. .$foo;

 is a bit faster, but the double-quoted bits cause some slow-down,


   echo $foo . ' bar bar bar bar '.$foo.' '.$foo;

 is a bit faster again - the single quoted bits pass through without further
 inspection, and finally


   echo $foo,' bar bar bar bar ',$foo,' ',$foo;

 is actually the fastest, because the strings are not concatenated before 
output.

 I think that was the overall summary - I can't locate the original post to
 verify (or attribute) but it's in this list somewhere...

 Cheers

 --
 Peter Ford  phone: 01580 89
 Developer   fax:   01580 893399
 Justcroft International Ltd., Staplehurst, Kent



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




Can you prove these statements with real benchmarks that are current?
Ilia said that it is a myth that there is a performance difference
between  and ' in one of his talks.


I found one recent post on the subject in gmane:
http://article.gmane.org/gmane.comp.php.general/169028




The poster's results are as I remembered, except that was building a string, not 
echoing: possibly not quite the same.


So I tried it myself, adapting to using echo (to the ob to avaoid printing forty 
million * foo bar bar ...). For an extra wheeze, I also tried ?=$foo? syntax 
embedded in HTML to see if that is as bad as people make out. I didn't try 
HEREDOC syntax, because it is difficult to reproduce exactly the same output - 
newlines get added to the output.
To get thing to run I needed to increase time out, and reduce the string to 
avoid filling the PHP memory limit I have set at the moment. Here is the code:


?php
ini_set('max_execution_time',300);
$foo = 'f';
ob_start();
$time[1] = microtime(TRUE);
for($x = 0; $x  1000; $x++){
echo $foo b b b b $foo $foo;
}
$time[2] = microtime(TRUE);
ob_end_clean();
ob_start();
$time[3] = microtime(TRUE);
for($x = 0; $x  1000; $x++){
echo $foo . ' b b b b '.$foo.' '.$foo;
}
$time[4] = microtime(TRUE);
ob_end_clean();
ob_start();
$time[5] = microtime(TRUE);
for($x = 0; $x  1000; $x++){
echo $foo .  b b b b .$foo. .$foo;
}
$time[6] = microtime(TRUE);
ob_end_clean();
ob_start();
$time[7

[PHP] Re: putting variables in a variable

2008-03-28 Thread Peter Ford

Hulf wrote:

Hi,

I am making and HTML email. I have 3 images to put in. Currently I have

$body .=
table
  tr
tdimg src=\image1.jpg\/td
  /tr

  tr
td/td
  /tr
/table
;


ideally I would like to have

$myimage1 = image1.jpg;
$myimage2 = image2.jpg;
$myimage3 = image3.jpg;


and put them into the HTML body variable. I have tried escaping them in 
every way i can think of, dots and slashes and the rest. Any ideas?



Ross




Since you've used double quotes, It Should Just Work(TM) ...

$body .=
table
  tr
tdimg src=\$myimage1\/td
  /tr
/table
;

I'd probably use single-quotes (') around the src attribute to avoid those ugly 
backslashes ...


$body .=
table
  tr
tdimg src='$myimage1'/td
  /tr
/table
;

Might be better in this case to use heredoc syntax ...

$body .EndOfChunk
table
  tr
tdimg src=$myimage1/td
  /tr
/table
EndOfChunk;

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] dynamic boxes problem... JS and PHP

2008-04-08 Thread Peter Ford

Mark Weaver wrote:

Ryan S wrote:

Hey everyone,

A bit of a puzzle here, dont know if this is a JS problem or PHP or FF 
or  just me.


(My money is on the last one :p )


Here's what I am trying to do:
In a form  I have a listbox with the values 1-5, and under the listbox 
i have a TD with the id of recips (like so: TD id='recips


I have a onChange event linked to the list box and depending on what 
number the client picks it should dynamically put the number of text 
boxes there, here is the JS code:


/ ### Start JS code 
function change_no_of_recipients()
{
var 
nr=document.mainform.no_of_friends.options[document.mainform.no_of_friends.selectedIndex].value; 


if(nr5){nr=5;} // max number of recipients
var msg = ;

for (var x = 1; x = nr; x++)
   {
   msg += 'table width=50% border=0 cellspacing=2 
cellpadding=2' +

  'tr' +
'td nowrap=nowrap'+ x +'. Recipient\'s name:/td' +
'tdinput type=text name=rec_name[] id=rec_name[] //td' +
'td nowrap=nowrapRecipient\'s email:/td' +
'tdinput type=text name=rec_email[] id=rec_email[] 
//td' +

  '/tr' +
'tr' +
'/table';
   }
document.getElementById('recips').innerHTML=msg;
}

/ # End JS code 

So far on the page everything is working, but when I click the submit 
button this is my PHP processing script:


?php
print_r($_REQUEST);
?


It shows me everything that has been submitted but NOT any of the 
above dynamically made boxes values... but get this, it DOES show me 
all values... in IE7 _not_ in FF (am using 2.0.0.13)


Anybody else face anything like this?
Is this a bug in FF? Is $_REQUEST wrong to catch this? Dont know what 
the @#$@ to do... ANY help even a link to a site which can shed a 
little light would be appreciated.


Thanks in advance.

/Ryan



Hi Ryan,

Since I'm relatively new to PHP I could be off on this, but I'd say yes, 
$_REQUEST is wrong. I would think you'd want to use $_POST to receive 
the incoming values from a form.




That would depend on the method that the form is using: GET or POST.

I don't think that's the answer.

Two things I would suggest:

1. Check that the Javascript is doing what you expect: you *are* using Firebug 
on Firefox, aren't you?  Also the WebDeveloper toolbar plugin is useful - it has 
a View Generated Source tool which will show you what Firefox thinks your page 
actually looks like after the JS has run...


2. Check that the TD you are loading with content is actually inside the FORM 
tags - otherwise the inputs won't be included in the request/post variables...


Cheers
Pete

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] dynamic boxes problem... JS and PHP

2008-04-09 Thread Peter Ford

Peter Ford wrote:

Mark Weaver wrote:

Ryan S wrote:

Hey everyone,

A bit of a puzzle here, dont know if this is a JS problem or PHP or 
FF or  just me.


(My money is on the last one :p )


Here's what I am trying to do:
In a form  I have a listbox with the values 1-5, and under the 
listbox i have a TD with the id of recips (like so: TD id='recips


I have a onChange event linked to the list box and depending on what 
number the client picks it should dynamically put the number of text 
boxes there, here is the JS code:


/ ### Start JS code 
function change_no_of_recipients()
{
var 
nr=document.mainform.no_of_friends.options[document.mainform.no_of_friends.selectedIndex].value; 


if(nr5){nr=5;} // max number of recipients
var msg = ;

for (var x = 1; x = nr; x++)
   {
   msg += 'table width=50% border=0 cellspacing=2 
cellpadding=2' +

  'tr' +
'td nowrap=nowrap'+ x +'. Recipient\'s name:/td' +
'tdinput type=text name=rec_name[] id=rec_name[] //td' +
'td nowrap=nowrapRecipient\'s email:/td' +
'tdinput type=text name=rec_email[] id=rec_email[] 
//td' +

  '/tr' +
'tr' +
'/table';
   }
document.getElementById('recips').innerHTML=msg;
}

/ # End JS code 

So far on the page everything is working, but when I click the submit 
button this is my PHP processing script:


?php
print_r($_REQUEST);
?


It shows me everything that has been submitted but NOT any of the 
above dynamically made boxes values... but get this, it DOES show me 
all values... in IE7 _not_ in FF (am using 2.0.0.13)


Anybody else face anything like this?
Is this a bug in FF? Is $_REQUEST wrong to catch this? Dont know what 
the @#$@ to do... ANY help even a link to a site which can shed a 
little light would be appreciated.


Thanks in advance.

/Ryan



Hi Ryan,

Since I'm relatively new to PHP I could be off on this, but I'd say 
yes, $_REQUEST is wrong. I would think you'd want to use $_POST to 
receive the incoming values from a form.




That would depend on the method that the form is using: GET or POST.

I don't think that's the answer.

Two things I would suggest:

1. Check that the Javascript is doing what you expect: you *are* using 
Firebug on Firefox, aren't you?  Also the WebDeveloper toolbar plugin is 
useful - it has a View Generated Source tool which will show you what 
Firefox thinks your page actually looks like after the JS has run...


2. Check that the TD you are loading with content is actually inside the 
FORM tags - otherwise the inputs won't be included in the request/post 
variables...


Cheers
Pete



Ryan,

First, you should reply to the list - that way more people could see the links 
you posted and help out.


Right,

It looks like there may be a problem with the form tags - when I look at this 
code I see

form action=process_ecard1.php method=post name=mainform/form

That looks like you've closed your mainform before defining the inputs

Don't know why IE works, but it's probably trying to be helpful... :)



--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] dynamic boxes problem... JS and PHP

2008-04-09 Thread Peter Ford

Ryan S wrote:

Hey Pete,


**
First, you should reply to the list - that way more people could see the links 
you posted and help out.

**
Oops, my mistake, I thought I did that. Will add a snip at the bottom of this 
email.

**
It looks like there may be a problem with the form tags - when I look at this 
code I see

form action=process_ecard1.php method=post name=mainform/form

That looks like you've closed your mainform before defining the inputs
**

can you tell me which line you see this? I did a search using that string on top and I 
couldnt find it... I even did a form search and still didnt find both of the 
form tags side by side..

Thanks again,
R

/// Snip of other mail with links ///
but looks like posting links is the best option so will do:

http://www.coinpass.com/test/step2.php (to run the script)
http://www.coinpass.com/test/step2.phps (View the source, its just a html file 
really)
All Javascript and CSS is in the http://www.coinpass.com/test/scripts/; 
directory

The processing script just has
print_r($_REQUEST);
so its useless pointing you to the actual file source.

/ End snip///




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


Ryan,

You did reply to the list - it appeared in a separate thread in my viewer, so my 
bad.



OK, the version with form .../form appeared when I used WebDeveloper toolbar 
to view the *generated* source.


When I look at the source code as received by Firefox (which is what the regular 
View source option does), the closing form-tag is where you expect.


i think I spotted a problem, however. Your original source code looks like it 
has a spurious tr after the first recipient block.


I think you need to really check the nesting of your tags - try indenting stuff 
to make the opening and closing tags line up and see if it gets out of line 
somewhere.


Anyway, I suspect what is happening is that Firefox is treating the /form as a 
closing tag for the spurious /tr and then implicitly closing the original 
form tag with an empty form.


Your Javascript code also adds a spurious tr tag (line 17 of 
dynamic_no_of_recipients2.js)


This is not really anything to do with PHP, of course... :)

--
Peter Ford, Developer phone: 01580 89 fax: 01580 893399
Justcroft International Ltd.  www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS

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



Re: [PHP] Quarters -- ERRORS --

2008-04-14 Thread Peter Ford

tedd wrote:

Hi gang:

Sorry for the lame app, but the program worked for Safari (Mac and Win). 
However, I did get it to work for FF and a couple of other browsers (Mac 
and Win), see again:


http://webbytedd.com/quarters

But the critter is dead in the water for all versions of IE -- if -- I 
don't figure out a way around the following single statement.


document.getElementById(id).checked = true;

Granted it's javascript, but all that line does is to set a checkbox 
variable (id) to 'on'. Surely, $M code can do that, right?


After reading a bunch, it seems that M$ has a better way to do things 
(big surprise there, huh?) and thus does not use the 
document.getElementById(id) thing that everyone else in the world uses. 
Instead, they use something better and it's not documented well as is 
typical.


Unfortunately, I have not been able to find a M$ work-a-round.

So, what I need is:

if (document.getElementById)
   {
   document.getElementById(id).checked = true;
   }
else
   {
inset solution here. 
   }

All the code has to do is to set a simple checkbox to 'on' in IE.

Anyone have any ideas?

Cheers,

tedd

PS: I'm going to post this on a js list as well.

PPS: You have to wonder how much more technically advanced we would be 
if we weren't always held back by the what's in it for me 
shortsightedness of M$.





What you talkin' bout?
Document.getElementById() works fine in IE5 and later.
There must be some other error.

You could check that document.getElementById(id) is actually returning something 
- if it fails it returns null.


Maybe you have given your checkbox a name and not an id, although that should 
fail with FF (and Safari) too...


It's fine on IE7 - anything older than IE7 is too broken to be usable, really. 
:)



--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: File Upload Security

2008-04-14 Thread Peter Ford

Al wrote:

Thanks guys.

I had written a newer version restricted to images which checks MIME and 
image width and height.


I have one application which needs a text file.  I think I'll have my 
users hide a password in it and scan the whole file for ? an ?php and 
other signs of scripts, etc.


Al wrote:
One of my sites has been hacked and I'm trying to find the hole.  The 
hack code creates dirs with nobody ownership, so it's obvious stuff 
is not via ftp [ownership would be foo]


Site is virtual host, Linux/Apache

I'm concerned about a file uploader my users use to upload photos.

Can anyone see a hole in this scrip? Can my code upload an executable 
masquerading as an image file?


You probably need a deeper inspection than checking the extension - that's 
Microsoft thinking...
You can't trust what the client is telling you - even the MIME type sent by the 
browser is no guarantee.
Since you're on Linux, why not look at using the 'file' shell command to get a 
more detailed inspection of the upload.
I made a basic function like this a few years ago - probably needs a bit of 
tweaking:


?php
function getMimeType($file)
{
global $magicFile;
$mimecmd = /usr/bin/file -b -m .escapeshellargs($magicFile). 
.escapeshellargs($file). 2 /dev/null;

$ret = exec($mimecmd);
if (!$ret)
{
$ret = unknown;
}
return $ret;
}
?

The global $magicFile is the tricky bit - you need to find a nice Unix magic 
numbers file that returns mime types (they're easier to parse than regular magic 
number responses). Probably something like /usr/share/misc/magic.mime, but that 
depends on the system.



--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: newbie with another HTML/navigation question

2008-04-29 Thread Peter Ford

Rod Clay wrote:

I have a php script that is invoked on 2 different occasions:

1) the first to create a page with a form the user will use to input 
information for a new table row - this form has method=POST


2) the script is run a second time to accept the input from the 
completed form, add the new row to the table on the database, then 
create a simple form with an OK button the user will click on to go to 
another page to view the result of the database maintenance - this form 
has method=GET


Everything is working great EXCEPT THAT the url parameter I attempt to 
pass on the second form to the php script that displays the database 
maintenance never gets there!  It's on the second form (form 
method=get action=bloglist.php?thread=yet%20another%20new%20thread) 
but the bloglist.php script doesn't receive it.  The query string is 
empty when bloglist.php starts.


Also, another very curious, and perhaps revealing, thing - when I 
attempt to view the page source of the second form I mention above, the 
one with method=GET, I get the odd, and absolutely nonsensical, message 
The page you are trying to view contains POSTDATA that has expired from 
the cache.  But this makes no sense, since this second page (with 
method=GET) has (or should have) no POSTDATA!?!


Can anyone make any sense of any of this for me?  I'm making pretty good 
progress in general, but, once again, I seem to have hit a snag here I'm 
don't seem to be able to get past.


Thanks for any help you can give me.

Rod
[EMAIL PROTECTED]


Firstly, if you have a form and you are sending it using GET, then why don't you 
use a input type='hidden' name='thread' value='yet another new thread' / 
element to send the parameter - that's what input tags are for. I have a feeling 
that the ?foo=bar bit is stripped off a GET request URL if there are other 
form elements, although it's not always stripped off a POST... maybe it's 
browser-dependent.


Secondly, when you refresh the second form, you are making a POST request - 
that's what generated the form in the first place, so you would expect the 
message about POSTDATA - and (in Firefox at least), to view the source the 
browser repeats the page request, effectively the same as refreshing the page. 
If you want to see the source without repeating the POST request, you need to 
use something like the WebDeveloper tool bar - it has a View Generated Source 
function which extracts the source from the DOM model the browser used to render 
the page.


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: problem with for loop

2008-05-02 Thread Peter Ford

Richard Kurth wrote:
Way does my for loop not complete the task if there are 4 emails it only 
process 3 emails through the foreach loop if there is 3 it only process 2


#  Connect up
$host =domain.com;
$port =110;
$mailtype = pop3;
$mailbox =INBOX;
$username =[EMAIL PROTECTED];
$password =boat1234;
   $conn = @imap_open({ . $host . : . $port . / . $mailtype . 
/notls} . $mailbox, $username, $password);


$number=imap_num_msg($conn);
for($i = 1; $i = $number; $i++) {
$file=C:\web\bouncehandler\eml\em$i;
imap_savebody($conn,$file,$i);


$file=file_get_contents(C:\web\bouncehandler\eml\em$i);
$multiArray = Bouncehandler::get_the_facts($file);

$EMAIL = $the['recipient'];
foreach($multiArray as $the){
   switch($the['action']){
   case 'failed':
   $sql=UPDATE contacts SET emailstatus = 'Fatal-Bounced' WHERE 
emailaddress = '$EMAIL';
   mysql_query($sql) or die(Invalid query:  . mysql_error());
   break;

   case 'transient':
   $sql=UPDATE contacts SET emailstatus = 'Bounced' WHERE 
emailaddress = '$EMAIL';

   mysql_query($sql) or die(Invalid query:  . mysql_error());
   break;
   case 'autoreply':
   $sql=UPDATE contacts SET emailstatus = 'Bounced' WHERE 
emailaddress = '$EMAIL';

   mysql_query($sql) or die(Invalid query:  . mysql_error());
   break;
   default:
   //don't do anything
   break;
   }
   }

}




I think you need to check the boundary conditions on your loop.
As you write it,

for($i = 1; $i = $number; $i++)

if $number is 4 then $i will have the values 1,2,3,4.

Perhaps message list is zero-based, and you actually need to count from zero:

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

so you would get $i to read 0,1,2,3

The manual page doesn't explicitly say the the message number is one-based, and 
most real programming languages these days use zero-based arrays...


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: A Little Something.

2008-05-12 Thread Peter Ford

tedd wrote:

Hi gang:

This is what I did this morning:

http://webbytedd.com/bb/tribute/

It speaks for itself.

Cheers,

tedd


tedd,

Nothing to do with the subject matter, but I noticed because it is one of your 
more simple pages: I get a JS urchinTracker() not defined error on your site, 
almost certainly because NoScript is blocking UrchinTracker...


Perhaps you should wrap that naked call to urchinTracker() in a conditional - 
maybe as simple as


if (urchinTracker) urchinTracker();

pet-peeve
I really hate seeing JS errors on published sites (i.e. not development 
sandboxes)
/pet-peeve

'course, there are many sites that make the same call to urchinTracker(), and 
many many worse errors...


Cheers
Pete


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Re: A Little Something.

2008-05-12 Thread Peter Ford

Stut wrote:

On 12 May 2008, at 09:39, Peter Ford wrote:

tedd wrote:

Hi gang:
This is what I did this morning:
http://webbytedd.com/bb/tribute/
It speaks for itself.
Cheers,
tedd


tedd,

Nothing to do with the subject matter, but I noticed because it is one 
of your more simple pages: I get a JS urchinTracker() not defined 
error on your site, almost certainly because NoScript is blocking 
UrchinTracker...


Perhaps you should wrap that naked call to urchinTracker() in a 
conditional - maybe as simple as


if (urchinTracker) urchinTracker();

pet-peeve
I really hate seeing JS errors on published sites (i.e. not 
development sandboxes)

/pet-peeve

'course, there are many sites that make the same call to 
urchinTracker(), and many many worse errors...


I see your pet peeve and I'll raise you one of mine...

pet-peeve
People who use Javascript blockers, especially Javascript blockers that 
do a half-arsed job which causes errors.

/pet-peeve

If you're going to block Javascript, block it. Don't use something that 
tries (and apparently fails) to block it intelligently.


What are you so afraid of?

-Stut



Your pet peeve seems to be a rather thinly veiled personal attack - I tried to 
be clear to tedd that my comment was not personal, but highlighted by his page.


Javascript is a very powerful but rather blunt instrument, and I prefer to be 
judicious in my use of power.


NoScript is not causing the error. The absence of UrchinTracker is causing the 
error. I choose not to allow UrchinTracker into my system.
NoScript is certainly not doing a half-arsed job - it's working perfectly, 
unless you think I should suffer extra CPU cycles while the browser parses every 
line of Javascript to see what will happen before running it. That would be a 
job for a compiler, rather than a scripting engine.


What I'm most afraid of are assumptions that something I didn't ask for exists 
in the environment I use to work in. If a page features a message that says we 
use Urchin Tracker to (...whatever it is that Urchin Tracker does...) and you 
may see errors if you block it, then I can understand.


What I also am afraid of is that I don't know everything that I should be 
afraid of - using NoScript is a good way of giving me chance to research the 
stuff that is being pushed into my browser. Of course, in some cases I don't 
feel the need to research, and block unconditionally until I see a problem with 
that approach.


A developer should not make assumptions about the existence of a feature in the 
target system - he should specify requirements and let the end-user decide if 
his product is acceptable, or check that a feature is present and work around it 
if not.
I can even tolerate This site requires Internet Explorer 5.3 or later (as my 
credit card company does) if the providers are upfront about it...


I don't consider being afraid as a weakness - but blasé indifference to danger 
can be a fatal weakness.


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Re: A Little Something.

2008-05-13 Thread Peter Ford

tedd wrote:

At 3:11 PM -0400 5/12/08, Eric Butera wrote:


NoScript is a FireFox extension to protect users from malicious
scripts.


NoScript is also a tag for browsers to read and react to IF they do not 
accept javascript.


http://www.w3schools.com/TAGS/tag_noscript.asp

That's an unfortunate naming convention from FireFox.

https://addons.mozilla.org/en-US/firefox/addon/722


 JS is indeed very dangerous right now especially as mashups
continue to gain popularity and all of that personal information
floating around.  Subscribe to planet websecurity and see the truth.

The way I deal with urchin is by /etc/hosts'ing out google's
adservers.  Then we all win, right?  ;)

Here is a fairly current rant:
http://blog.360.yahoo.com/blog-TBPekxc1dLNy5DOloPfzVvFIVOWMB0li?p=819



Okay, I read that -- but what does that have to do with urchin?

Urchin is not an ad delivery system, but rather a way to keep track of 
visitors to your web site.


Now, how is that a security threat? Or is the claim that any site that 
uses js is a security threat?


Cheers,

tedd



tedd,

I don't expect anyone to second-guess pet peeves :)
And, as you say, Urchin is not your code: I think the onus is on the coders of 
Urchin to document how to avoid errors when Javascript is disabled, not the site 
developer who uses it.


Some of us are extremely cautious about how we expose our systems to unknowns. 
As far as I can tell, Urchin does me no favours so I don't need to allow it in. 
In addition, I might not want a site to know where I am or where I came from: 
that is a (very mild) form of surveillance.


On a more rebellious note, I actively try to confound any attempts to target 
advertising at me - I hate all forms of advertising (except the really clever TV 
ads that make me laugh) and tend to choose what products I buy based on my own 
research, rather than what a marketing droid thinks I need to buy.


Anyway, this is waaay off-topic: it was right from the start - sorry 
everyone :(

I'll keep my pet peeves private from now on ...

Cheers
Pete


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: Scripts slowing down?

2008-05-13 Thread Peter Ford

René Leboeuf wrote:

Hi.

I'm running a large website. I have some mailing scripts that take days
to run.

I noticed these scripts slow down with time, sometimes going to an
almost complete stop (no mail sent for several minutes).

The source code is trivial and can't contain a loop. I monitored the
memory usage and couldn't find a memory leak. Using APD, most of the
time is reported to be spent in the fgets() function (script waiting for
a sendmail reply). But sendmail still replies swiftly when this problem
occurs.


By this, I guesss you mean that other connections to sendmail reply swiftly: so 
the server is not just jamming up completely and refusing requests ?


It might depend on the exact implementation of 'sendmail': for example, the 
Courier mail system which I use replaces the program 'sendmail' with it's own 
binary to do the job.
Courier also has a 'tar-pitting' feature which is triggered by behaviour that 
looks like a spammer is trying to relay stuff: it atificially slows the response 
to the send requests if there is an unreasonably high rate of requests coming 
from a given source. At least that's how I understand the feature to work.
Other mail system may implement a similar feature - it might just be that your 
mailing script looks like a spam engine to the mail server.





Restarting sendmail has no effect on these scripts. Restarting the
scripts makes them run like hell for some hours, until the problem rises
again.

I'm using PHP 5.2.5

I don't know where to look next for the source of this problem...


I think you need to provide some more detail - you could start by explaining 
what method you use to send the messages. The next thing to do is to look at the 
mail logs and see if there are any messages written around the time that yourt 
script runs.
Don't always assume that it is your code that is wrong (that's what managers are 
for)


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Choosing PHP or ? for building an automatic photo web.

2008-06-08 Thread Peter Sorensen

Hi everyone

I want to make my own web with my familie photos.
At the same time I get a remote backup for our photos.
I am new to web prgramming including HTML, but as an electronic engineer I 
have some fundamental understanding of programming.

I use windows XP or Vista but that properly does not matter in web design?
I have invested in a web service on surftown (only starter) for 5 years.
So before I spend a lot time learning webprogramming, I would like some 
experience web programmers to tell me if my project is doable within a 
reasonable effort.


I want 2 thinks that are a little uncommon:
1. User login protected by password (don't won't free access to all my 
photos).
   I have found some PHP code that does this and seems readable to me, so I 
guess this is trivial and on to the main problem.


2. I want the web source to automatic create a new tab or link or ?, when 
ever I upload a new set of photo's via FTP.
   I want the photos arranged in subfolders when I upload (preferreable two 
levels of subfolders).
   If I upload more photos in an existing folder with photos, they must 
appear automatickly.


So the question is: is this doable for a  newbie within a limited amount of 
hours?

Is PHP the choice?
Do I need to use mySQL for this?
What features must the webhotel suport and do you know if Surftown does?
Is there anywhere I get template source code for this, free or at a low 
price?


best regards
Peter Sørensen








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



Re: [PHP] Choosing PHP or ? for building an automatic photo web.

2008-06-09 Thread Peter Sorensen

Sorry wrong button on the mail program.


Stut [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

Please copy replies to the list.

On 8 Jun 2008, at 22:47, Nordstjernealle 10 wrote:

Thanks Stut

I have looked at Gallery and I think your are right, just what I need.
Onfortunately I have found that Gallery musthave PHP safe mode off, 
which Surftown does not allow.
Using Gallery means write of my Surftown account and get another web 
hotel.

Any other ideers?


Use a better web host. Any system that can do what you're after will  want 
to do things like generate thumbnails and other different sizes.  This can 
get difficult with safe mode enabled.


I try not to recommend web hosts because they all suck, but I do know  a 
few people on this list provide hosting services and I'm sure  they'll get 
in contact if they can help.


-Stut

--
http://stut.net/


- Original Message - From: Stut [EMAIL PROTECTED]
Newsgroups: php.general
To: Peter Sorensen [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Sunday, June 08, 2008 11:27 PM
Subject: Re: [PHP] Choosing PHP or ? for building an automatic photo 
web.




On 8 Jun 2008, at 21:44, Peter Sorensen wrote:

I want to make my own web with my familie photos.
At the same time I get a remote backup for our photos.
I am new to web prgramming including HTML, but as an electronic 
engineer I have some fundamental understanding of programming.
I use windows XP or Vista but that properly does not matter in web 
design?
I have invested in a web service on surftown (only starter) for 5 
years.
So before I spend a lot time learning webprogramming, I would  like 
some experience web programmers to tell me if my project is  doable 
within a reasonable effort.


I want 2 thinks that are a little uncommon:
1. User login protected by password (don't won't free access to  all 
my photos).
 I have found some PHP code that does this and seems readable to   me, 
so I guess this is trivial and on to the main problem.


2. I want the web source to automatic create a new tab or link  or ?, 
when ever I upload a new set of photo's via FTP.
 I want the photos arranged in subfolders when I upload   (preferreable 
two levels of subfolders).
 If I upload more photos in an existing folder with photos, they   must 
appear automatickly.


So the question is: is this doable for a  newbie within a limited 
amount of hours?

Is PHP the choice?
Do I need to use mySQL for this?
What features must the webhotel suport and do you know if  Surftown 
does?
Is there anywhere I get template source code for this, free or at  a 
low price?


This wheel has been invented a hundred times already.

I would suggest http://gallery.menalto.com/ which I think does 
everything you're after.


-Stut

--
http://stut.net/







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



Re: [PHP] substr?

2008-06-18 Thread Peter Ford

Frank Arensmeier wrote:


17 jun 2008 kl. 22.14 skrev Jim Lucas:


Jason Pruim wrote:

Hi everyone,
I am attempting to adopt some code to work more reliably then how it 
is now...
What I am doing is coding a upload form where people could be 
uploading .zip files in excess of 200 MB... Yes I know that is large, 
but it's for a print shop and they get HUGE files to print from.

The code I'm having issues with is this:
$filename = $_FILES['userfile']['name']; // Get the name of the 
file (including file extension).
$ext = substr($filename, strpos($filename,'.'), 
strlen($filename)-1); // Get the extension from the filename.
All I want to do is grab the file extension and verify that it is a 
.zip or a .pdf etc. file. This is working for small files (under a 
few megs) but for some reason it fails when I get bigger. I have 
increased the allowed memory size to 50 MB's I'm testing with a 44 MB 
file right now.
When it fails, it says the file type is not allowed even though it is 
listed in the file type array.
Hopefully I have given you enough to go on to at least ask me some 
questions :)

--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]


Looking at what I think you are trying to do, how about this?

?php

if ( isset( $_FILES ) ) {

  foreach ( $_FILES AS $file )

$filename = $file['name'];

list($ext) = array_reverse(explode('.', $filename));

$allowed_ext = array('zip', 'pdf');

if ( in_array($ext, $allowed_ext) ) {
  // Correct extension; do what ever
} else {
  // Incorrect extension; do nothing
}

  }

}

?



I am somewhat surprised that all code suggestions are rather complicated 
in my opinion. What is wrong with 'pathinfo'?


if ( !isset( $_FILES['userfile']['name'] ) ) {
echo No file has been uploaded;
} else {

$allowed_extensions = array( zip, pdf, ai, html );
$file_info = pathinfo( $_FILES['userfile']['name'] );

if ( in_array( strtolower( $file_info['extension'] ), 
$allowed_extensions ) ) {

echo File has a valid extension;
} else {
// do something else
}
}

// frank




Two points here:
Firstyl, as someone has already indicated, the file will be uploaded before the 
PHP script runs, so the end user will have to wait for his junk to get through 
the internet before (s)he is told it is junk. Is that what you want?


Secondly, using the file extension to determine file type is a very poor idea 
and open to abuse. If you have the file (which you do, 'cos it's been uploaded 
before your script runs) then you should do a bit more checking before accepting 
it. The Unix/Linux file command can help here. Not perfect, but still...
You could also Virus-scan the file before accepting it. All depends on whether 
your customer is prepared to wait while you clear his upload.


Cheers
Pete

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] substr?

2008-06-19 Thread Peter Ford

Jim Lucas wrote:

Peter Ford wrote:

Frank Arensmeier wrote:


17 jun 2008 kl. 22.14 skrev Jim Lucas:


Jason Pruim wrote:

Hi everyone,
I am attempting to adopt some code to work more reliably then how 
it is now...
What I am doing is coding a upload form where people could be 
uploading .zip files in excess of 200 MB... Yes I know that is 
large, but it's for a print shop and they get HUGE files to print 
from.

The code I'm having issues with is this:
$filename = $_FILES['userfile']['name']; // Get the name of the 
file (including file extension).
$ext = substr($filename, strpos($filename,'.'), 
strlen($filename)-1); // Get the extension from the filename.
All I want to do is grab the file extension and verify that it is a 
.zip or a .pdf etc. file. This is working for small files (under a 
few megs) but for some reason it fails when I get bigger. I have 
increased the allowed memory size to 50 MB's I'm testing with a 44 
MB file right now.
When it fails, it says the file type is not allowed even though it 
is listed in the file type array.
Hopefully I have given you enough to go on to at least ask me some 
questions :)

--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]


Looking at what I think you are trying to do, how about this?

?php

if ( isset( $_FILES ) ) {

  foreach ( $_FILES AS $file )

$filename = $file['name'];

list($ext) = array_reverse(explode('.', $filename));

$allowed_ext = array('zip', 'pdf');

if ( in_array($ext, $allowed_ext) ) {
  // Correct extension; do what ever
} else {
  // Incorrect extension; do nothing
}

  }

}

?



I am somewhat surprised that all code suggestions are rather 
complicated in my opinion. What is wrong with 'pathinfo'?


if ( !isset( $_FILES['userfile']['name'] ) ) {
echo No file has been uploaded;
} else {

$allowed_extensions = array( zip, pdf, ai, html );
$file_info = pathinfo( $_FILES['userfile']['name'] );

if ( in_array( strtolower( $file_info['extension'] ), 
$allowed_extensions ) ) {

echo File has a valid extension;
} else {
// do something else
}
}

// frank




Two points here:
Firstyl, as someone has already indicated, the file will be uploaded 
before the PHP script runs, so the end user will have to wait for his 
junk to get through the internet before (s)he is told it is junk. Is 
that what you want?


Secondly, using the file extension to determine file type is a very 
poor idea and open to abuse. If you have the file (which you do, 'cos 
it's been uploaded before your script runs) then you should do a bit 
more checking before accepting it. The Unix/Linux file command can 
help here. Not perfect, but still...
You could also Virus-scan the file before accepting it. All depends on 
whether your customer is prepared to wait while you clear his upload.


Cheers
Pete



I think that you have the wrong person here.  That was a different 
thread/person talking about preventing DoS'ing attacks.  Not Jason.




D'oh! I'm sure I responded to the other thread.

I'm a bit young for 'Senior moments' yet...

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] odbc msaccess php5

2008-07-05 Thread Peter Jackson

Hi list,

 I am trying to get info out of a MS Access 2000 db.  So far I have 
managed to do some of it but current part has me stumped.


Set up
Machine 1 - Debian 4, Apache, PHP5 unixodbc, mdbtools
Machine 2 - WindowsXP, MS-Access

Database is in a windows share that is smfs mounted on the linux box.

$conn=odbc_connect(Database,,);  works
$a = abcd; (this value exists in db)
$stat = Select * FROM  . 'Table Name';
$qry = odbc_exec($conn,$stat);
$res = odbc_result_all($qry) or die(Error: );

The above works as I expect it to.(Returns 70 rows)

If I now want to add a where clause
$stat = SELECT * FROM  . 'Table Name' .  Where  . 'Column Name = 
   . $a;  (This works)


Now the place I fall into the abyss.
if I change WHERE clause in $stat to
  WHERE  . 'Column Name' LIKE abc*  (or other variations like abc% 
abc% abc* 'abc%' 'abc*')
All I end up with is a blank page or Warning odbc_result_all No tuples 
available at this result index.


Also I'm having trouble working out how to use a date in the WHERE 
clause.  I've tried #yy-mm-dd# yy-mm-dd* dd/mm/yy etc etc (oh and 
yy/mm/dd 00:00:00 etc
 I realize this is probably more odbc/sql related but after a lot of 
goggling and reading I havent found the answer (about 5 days so far)
And before everyone shouts use mySQL postgresql etc that isnt an option 
at this point in time. I dont need to update the records I just need to 
be able to read them with php.


 Oh and whilst I'm here is it possible to read an ms-query via odbc?
(eg select * from myquery). Just thinking that may fix one of my 
problems (Caps and spaces in table/column names aaarrgghh)


Peter Jackson

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



[PHP] Re: Trying to keep a dropdown selection sticky

2008-07-05 Thread Peter Jackson

Michael S. Dunsavage wrote:

I have a form I want to keep sticky, but I can't figure out how. I got
all the INPUT's to be sticky

The select script


?php
echo 'strongState/strongbr';
echo 'select name=State';
foreach ($state_list as $key = $value) {
echo option value=\$key\ $value/option\n;
}
echo '/select';
echo 'br';



?



If I'm reading this correctly you mean if the value has been selected 
before select it again?

If so way I did it was by checking the database value
 eg
echo option value=\$key\
if ($row[id] == $key) {
  print SELECTED; }
echo  $value /option\n;

Peter Jackson


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



Re: [PHP] odbc msaccess php5

2008-07-05 Thread Peter Jackson

Bastien Koert wrote:

On Sat, Jul 5, 2008 at 11:04 AM, Bastien Koert [EMAIL PROTECTED] wrote:



On Sat, Jul 5, 2008 at 6:51 AM, Peter Jackson [EMAIL PROTECTED]
wrote:




$conn=odbc_connect(Database,,);  works
$a = abcd; (this value exists in db)
$stat = Select * FROM  . 'Table Name';
$qry = odbc_exec($conn,$stat);
$res = odbc_result_all($qry) or die(Error: );

The above works as I expect it to.(Returns 70 rows)

If I now want to add a where clause
$stat = SELECT * FROM  . 'Table Name' .  Where  . 'Column Name =
  . $a;  (This works)

Now the place I fall into the abyss.
if I change WHERE clause in $stat to
  WHERE  . 'Column Name' LIKE abc*  (or other variations like abc%
abc% abc* 'abc%' 'abc*')
All I end up with is a blank page or Warning odbc_result_all No tuples
available at this result index.

Also I'm having trouble working out how to use a date in the WHERE clause.
 I've tried #yy-mm-dd# yy-mm-dd* dd/mm/yy etc etc (oh and yy/mm/dd 00:00:00
etc
 I realize this is probably more odbc/sql related but after a lot of
goggling and reading I havent found the answer (about 5 days so far)





As the data seems to be text based, you need to quote it

WHERE  . 'Column Name' LIKE 'abc%'

--

Bastien

Cat, the other other white meat




sorry, missed the access dates...

try mm/dd/ as the format


Unfortunately thats the first thing I thought of.  I've tried every 
variation of quote I could think of.  Can anyone tell me how to log what 
 the odbc connection is actually sending/receiving?  (as opposed to 
just echoing the sql statement I 'think' its sending.






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



Re: [PHP] odbc msaccess php5 [Giving Up]

2008-07-06 Thread Peter Jackson

Peter Jackson wrote:

 well thats it Ive come to the conclusion that its a driver/lib issue. 
 From what I can see mdbtools lib only reads and only does basic select.
(eg Select * from table where col =thistext But not tex* % or date. 
Also looks like the project has died (think the last release was 2004 or 
so.)  Thought I would give odbtp ago but cant get that to make. aargghh 
I give up.



Bastien Koert wrote:

On Sat, Jul 5, 2008 at 11:04 AM, Bastien Koert [EMAIL PROTECTED] wrote:



On Sat, Jul 5, 2008 at 6:51 AM, Peter Jackson [EMAIL PROTECTED]
wrote:




$conn=odbc_connect(Database,,);  works
$a = abcd; (this value exists in db)
$stat = Select * FROM  . 'Table Name';
$qry = odbc_exec($conn,$stat);
$res = odbc_result_all($qry) or die(Error: );

The above works as I expect it to.(Returns 70 rows)

If I now want to add a where clause
$stat = SELECT * FROM  . 'Table Name' .  Where  . 'Column 
Name =

  . $a;  (This works)

Now the place I fall into the abyss.
if I change WHERE clause in $stat to
  WHERE  . 'Column Name' LIKE abc*  (or other variations like abc%
abc% abc* 'abc%' 'abc*')
All I end up with is a blank page or Warning odbc_result_all No tuples
available at this result index.

Also I'm having trouble working out how to use a date in the WHERE 
clause.
 I've tried #yy-mm-dd# yy-mm-dd* dd/mm/yy etc etc (oh and yy/mm/dd 
00:00:00

etc
 I realize this is probably more odbc/sql related but after a lot of
goggling and reading I havent found the answer (about 5 days so far)





As the data seems to be text based, you need to quote it

WHERE  . 'Column Name' LIKE 'abc%'

--

Bastien

Cat, the other other white meat




sorry, missed the access dates...

try mm/dd/ as the format


Unfortunately thats the first thing I thought of.  I've tried every 
variation of quote I could think of.  Can anyone tell me how to log what 
 the odbc connection is actually sending/receiving?  (as opposed to just 
echoing the sql statement I 'think' its sending.







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



Re: [PHP] how to create a slide show using PHP5

2008-07-08 Thread Peter Ford

tedd wrote:

At 4:37 PM -0400 7/2/08, philip wrote:

Hi everyone,

I want to create a slide show of photos for my web site. How is this 
done using php5? I am using Opensuse 10.3, Apache, PHP5.


TIA for any assistance,

Philip


Philip:

With a combination of php, html, and javascript, you can get this:

http://webbytedd.com/c/fade-cycle/

The javascript is there.

Cheers,

tedd



Oh! For a moment I thought tedd had let me down - it didn't quite work properly: 
the faded-out image flashed up again before being replaced by the new image. So 
I looked at the code and realised that the new image was a background image, 
which was being copied up to the foreground... and I had caching disabled (I was 
on my development system and hacking some annoying IE/JS problems) so the 
copying-up was forcing a reload from source...


Not broken after all.

Faith restored.

All is well.

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: What font/size do you use for programming?

2008-07-10 Thread Peter Ford

tedd wrote:

Hi gang:

I'm running a Mac (so I know mine is a bit different size wise) but I'm 
currently using Veranda at 14 point for coding.


Just out of curiosity, what font and size do you ppls use for your 
programming?


Cheers,

tedd



I'd love to be coding on the Veranda, but it's raining horizontally at the 
moment and my keyboard hates being wet.


I'm using Lucida Sans for code these days - I finally figured that it didn't 
really have to be a fixed-width font, since I couldn't find one that wasn't ugly.


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: Logic sought

2008-07-10 Thread Peter Ford

tedd wrote:

Hi gang:

Here's the logic problem.

First the site:

http://php1.net/b/zip-files/

Now, the site works well enough. The user selects what they want, clicks 
Submit, the order is assembled in zip file and presented to the user for 
downloading.


However, as it stands now, before the script assembles the test.zip, it 
deletes (unlinks) the previous test.zip and therein lies the problem.


If two, or more, users hit the site at the same time then a RACE 
condition may have one user getting something they didn't ask for or not 
getting anything at all.


The complicated way I figure I could solve this would be to:

1. Generate a random string name for the file -- instead of test.zip, it 
could be ax12nhg34.zip.


2. Then when the user selects the download that would trigger a 
javascript routine that would send the name of the file to be deleted to 
a slave php script that would unlinks the file.


I know this will work, but if the user never downloads the file, then 
the files accumulate on the server.


Does anyone have a better idea?

Thanks,

tedd



For bespoke downloads I create a directory somewhere named with the session ID, 
then build the download file there and only allow access throw a PHP script 
which knows the session ID. I guess it depends how commercial or sensitive the 
data is.

Then I have a cron or something clean up the old directories.

It would be nice to have some sort of trigger to indicate that the session has 
expired - anyone know if Apache can do such a thing?
In a Java environment, I used a session object which cleaned up such folders 
when it was garbage-collected...


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] mkdir permission errors

2008-07-15 Thread Peter Ford

Wei, Alice J. wrote:

Hi, Rob:

  I forgot to mention that I have been using yum install.
  I have reinstalled the entire thing, put back all the packages, and then I 
went to /var and did a chmod -R 777 var, and then did a

   [EMAIL PROTECTED] var]# chown -R apache:apache .

Interestingly, I do not see anything different, and I still get this error that 
says my permission is denied. Here is my

[EMAIL PROTECTED] var]#  ps awxu | grep -E 'apache|httpd'
root 31547  0.0  0.3  21268  6584 ?Ss   16:12   0:00 /usr/sbin/httpd
apache   31549  0.0  0.2  21400  5572 ?S16:12   0:00 /usr/sbin/httpd
apache   31550  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31551  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31552  0.0  0.2  21400  4896 ?S16:12   0:00 /usr/sbin/httpd
apache   31553  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31554  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31555  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31556  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
root 31708  0.0  0.0   4120   728 pts/1R+   16:30   0:00 grep -E 
apache|httpd

Obviously, my last one has already changed the owner to apache 
already.Nevertheless, I am still denied even when I am now logged in as root. 
Is this anything with firewalls?



Hang on a minute: you're original message said the error was:

Warning: chmod() [function.chmod]: Permission denied in 
/usr/local/apache/htdocs/file_linux.php on line 27


But you say you've re-installed, and done chmod -R 777 var and chown -R 
apache:apache . in /var


A few things there:
When you are changing permissions and ownerships on such a large scale, you 
should always use absolute paths to be sure you are doing the right thing - like 
chmod -R 777 /var and chown -R apache:apache /var


Next, changing permission and ownership recursively on something like /var is 
likely to wreck your system in weird and wonderful ways, and is pretty difficult 
to undo - you might be looking at a total OS reinstall here (once you've solved 
your Apache problems)


Finally, the error message refers to a file in /usr/local/apache/htdocs, but you 
then are changing permissions in /var - where is your web root?! It looks like 
your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web 
files are actually in /var/something...


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] mkdir permission errors

2008-07-15 Thread Peter Ford

Wei, Alice J. wrote:


-Original Message-
From: Peter Ford [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 4:06 AM
To: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:

Hi, Rob:

  I forgot to mention that I have been using yum install.
  I have reinstalled the entire thing, put back all the packages, and then I 
went to /var and did a chmod -R 777 var, and then did a

   [EMAIL PROTECTED] var]# chown -R apache:apache .

Interestingly, I do not see anything different, and I still get this error that 
says my permission is denied. Here is my

[EMAIL PROTECTED] var]#  ps awxu | grep -E 'apache|httpd'
root 31547  0.0  0.3  21268  6584 ?Ss   16:12   0:00 /usr/sbin/httpd
apache   31549  0.0  0.2  21400  5572 ?S16:12   0:00 /usr/sbin/httpd
apache   31550  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31551  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31552  0.0  0.2  21400  4896 ?S16:12   0:00 /usr/sbin/httpd
apache   31553  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31554  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31555  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31556  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
root 31708  0.0  0.0   4120   728 pts/1R+   16:30   0:00 grep -E 
apache|httpd

Obviously, my last one has already changed the owner to apache 
already.Nevertheless, I am still denied even when I am now logged in as root. 
Is this anything with firewalls?



Hang on a minute: you're original message said the error was:

Warning: chmod() [function.chmod]: Permission denied in
/usr/local/apache/htdocs/file_linux.php on line 27

But you say you've re-installed, and done chmod -R 777 var and chown -R
apache:apache . in /var

A few things there:
When you are changing permissions and ownerships on such a large scale, you
should always use absolute paths to be sure you are doing the right thing - like
chmod -R 777 /var and chown -R apache:apache /var

Next, changing permission and ownership recursively on something like /var is
likely to wreck your system in weird and wonderful ways, and is pretty difficult
to undo - you might be looking at a total OS reinstall here (once you've solved
your Apache problems)

Finally, the error message refers to a file in /usr/local/apache/htdocs, but you
then are changing permissions in /var - where is your web root?! It looks like
your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web
files are actually in /var/something...

I forgot to mention that I use Fedora on a Linux machine. I used yum install 
apache and yum install php to install my packages. Therefore, I don't have a 
/usr/local/apache/htdocs folder. The web root is now /var/www/html, which 
originally I do have /usr/local/apache/htdocs that I configured during previous 
installations. This is not there anymore after my reinstallations since 
yesterday.

Do I really have to reinstall the entire Fedora? I hate to say that my scripts 
worked fine BEFORE yesterday until the power went out and nothing went right 
after I have restarted the entire system.

Alice



You don't *have* to reinstall Fedora (yet) - that was just a warning that 
changing ownership and permissions on /var might cause some problems later...


So the question is, does the error message say that it cannot change 
permissions on
/usr/local/apache/htdocs/file_linux.php
or
 /var/www/html/file_linux.php
?

And does your PHP script have the correct path?

The original problem may just have been that the /usr/local file system was 
mounted read-only after the power outage (perhaps due to some disk corruption 
caused by the failure?). Since then you have reinstalled apache, but possibly 
not in the place your PHP script expects it to be. That would be my first thing 
to check...


--
Peter Ford, Developer phone: 01580 89 fax: 01580 893399
Justcroft International Ltd.  www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS

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



Re: [PHP] mkdir permission errors

2008-07-15 Thread Peter Ford

Wei, Alice J. wrote:

From: Peter Ford [EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 7:28 AM
To: Wei, Alice J.
Cc: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:

-Original Message-
From: Peter Ford [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 4:06 AM
To: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:

Hi, Rob:

  I forgot to mention that I have been using yum install.
  I have reinstalled the entire thing, put back all the packages, and then I 
went to /var and did a chmod -R 777 var, and then did a

   [EMAIL PROTECTED] var]# chown -R apache:apache .

Interestingly, I do not see anything different, and I still get this error that 
says my permission is denied. Here is my

[EMAIL PROTECTED] var]#  ps awxu | grep -E 'apache|httpd'
root 31547  0.0  0.3  21268  6584 ?Ss   16:12   0:00 /usr/sbin/httpd
apache   31549  0.0  0.2  21400  5572 ?S16:12   0:00 /usr/sbin/httpd
apache   31550  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31551  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31552  0.0  0.2  21400  4896 ?S16:12   0:00 /usr/sbin/httpd
apache   31553  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31554  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31555  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31556  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
root 31708  0.0  0.0   4120   728 pts/1R+   16:30   0:00 grep -E 
apache|httpd

Obviously, my last one has already changed the owner to apache 
already.Nevertheless, I am still denied even when I am now logged in as root. 
Is this anything with firewalls?


Hang on a minute: you're original message said the error was:

Warning: chmod() [function.chmod]: Permission denied in
/usr/local/apache/htdocs/file_linux.php on line 27

But you say you've re-installed, and done chmod -R 777 var and chown -R
apache:apache . in /var

A few things there:
When you are changing permissions and ownerships on such a large scale, you
should always use absolute paths to be sure you are doing the right thing - like
chmod -R 777 /var and chown -R apache:apache /var

Next, changing permission and ownership recursively on something like /var is
likely to wreck your system in weird and wonderful ways, and is pretty difficult
to undo - you might be looking at a total OS reinstall here (once you've solved
your Apache problems)

Finally, the error message refers to a file in /usr/local/apache/htdocs, but you
then are changing permissions in /var - where is your web root?! It looks like
your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web
files are actually in /var/something...

I forgot to mention that I use Fedora on a Linux machine. I used yum install 
apache and yum install php to install my packages. Therefore, I don't have a 
/usr/local/apache/htdocs folder. The web root is now /var/www/html, which 
originally I do have /usr/local/apache/htdocs that I configured during previous 
installations. This is not there anymore after my reinstallations since 
yesterday.

Do I really have to reinstall the entire Fedora? I hate to say that my scripts 
worked fine BEFORE yesterday until the power went out and nothing went right 
after I have restarted the entire system.

Alice



You don't *have* to reinstall Fedora (yet) - that was just a warning that
changing ownership and permissions on /var might cause some problems later...

So the question is, does the error message say that it cannot change 
permissions on
/usr/local/apache/htdocs/file_linux.php
or
 /var/www/html/file_linux.php
?

This portion is to answer Rob's question:

[EMAIL PROTECTED] var]# ls -la
total 92
drwxrwxrwx 22 root root 4096 2008-06-24 08:34 .
drwxr-xr-x 21 root root 4096 2008-07-14 08:17 ..
drwxrwxrwx  2 root root 4096 2008-06-24 08:25 account
drwxrwxrwx 13 root root 4096 2008-07-14 16:07 cache
drwxrwxrwx  2 root root 4096 2008-02-19 20:47 cvs
drwxrwxrwx  3 root root 4096 2008-06-24 08:25 db
drwxrwxrwx  3 root root 4096 2008-06-24 08:29 empty
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 games
drwxrwxrwx  2 root root 4096 2008-05-01 22:45 gdm
drwxrwxrwx 35 root root 4096 2008-07-14 16:07 lib
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 local
drwxrwxrwx  5 root root 4096 2008-07-15 04:10 lock
drwxrwxrwx 17 root root 4096 2008-07-15 04:10 log
lrwxrwxrwx  1 root root   10 2008-06-24 08:24 mail - spool/mail
drwxrwxrwx  6 root root 4096 2008-06-24 08:26 named
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 nis
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 opt
drwxrwxrwx  2 root root 4096 2008-04-07 17:44 preserve
drwxrwxrwx 27 root root 4096 2008-07-14 16:12 run
drwxrwxrwx 13 root root 4096 2008-06-24 08:35 spool
drwxrwxrwx  2 root root 4096 2008-07-14 16:10 tmp
drwxrwxrwx  8

Re: [PHP] mkdir permission errors

2008-07-15 Thread Peter Ford

Wei, Alice J. wrote:


From: Peter Ford [EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 7:28 AM
To: Wei, Alice J.
Cc: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:

-Original Message-
From: Peter Ford [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2008 4:06 AM
To: php-general@lists.php.net
Subject: Re: [PHP] mkdir permission errors

Wei, Alice J. wrote:

Hi, Rob:

  I forgot to mention that I have been using yum install.
  I have reinstalled the entire thing, put back all the packages, and then I 
went to /var and did a chmod -R 777 var, and then did a

   [EMAIL PROTECTED] var]# chown -R apache:apache .

Interestingly, I do not see anything different, and I still get this error that 
says my permission is denied. Here is my

[EMAIL PROTECTED] var]#  ps awxu | grep -E 'apache|httpd'
root 31547  0.0  0.3  21268  6584 ?Ss   16:12   0:00 /usr/sbin/httpd
apache   31549  0.0  0.2  21400  5572 ?S16:12   0:00 /usr/sbin/httpd
apache   31550  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31551  0.0  0.2  21400  4908 ?S16:12   0:00 /usr/sbin/httpd
apache   31552  0.0  0.2  21400  4896 ?S16:12   0:00 /usr/sbin/httpd
apache   31553  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31554  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31555  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
apache   31556  0.0  0.2  21268  4860 ?S16:12   0:00 /usr/sbin/httpd
root 31708  0.0  0.0   4120   728 pts/1R+   16:30   0:00 grep -E 
apache|httpd

Obviously, my last one has already changed the owner to apache 
already.Nevertheless, I am still denied even when I am now logged in as root. 
Is this anything with firewalls?


Hang on a minute: you're original message said the error was:

Warning: chmod() [function.chmod]: Permission denied in
/usr/local/apache/htdocs/file_linux.php on line 27

But you say you've re-installed, and done chmod -R 777 var and chown -R
apache:apache . in /var

A few things there:
When you are changing permissions and ownerships on such a large scale, you
should always use absolute paths to be sure you are doing the right thing - like
chmod -R 777 /var and chown -R apache:apache /var

Next, changing permission and ownership recursively on something like /var is
likely to wreck your system in weird and wonderful ways, and is pretty difficult
to undo - you might be looking at a total OS reinstall here (once you've solved
your Apache problems)

Finally, the error message refers to a file in /usr/local/apache/htdocs, but you
then are changing permissions in /var - where is your web root?! It looks like
your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web
files are actually in /var/something...

I forgot to mention that I use Fedora on a Linux machine. I used yum install 
apache and yum install php to install my packages. Therefore, I don't have a 
/usr/local/apache/htdocs folder. The web root is now /var/www/html, which 
originally I do have /usr/local/apache/htdocs that I configured during previous 
installations. This is not there anymore after my reinstallations since 
yesterday.

Do I really have to reinstall the entire Fedora? I hate to say that my scripts 
worked fine BEFORE yesterday until the power went out and nothing went right 
after I have restarted the entire system.

Alice



You don't *have* to reinstall Fedora (yet) - that was just a warning that
changing ownership and permissions on /var might cause some problems later...

So the question is, does the error message say that it cannot change 
permissions on
/usr/local/apache/htdocs/file_linux.php
or
 /var/www/html/file_linux.php
?

And does your PHP script have the correct path?

The original problem may just have been that the /usr/local file system was
mounted read-only after the power outage (perhaps due to some disk corruption
caused by the failure?). Since then you have reinstalled apache, but possibly
not in the place your PHP script expects it to be. That would be my first thing
to check...

This sounds really dumb, but it turned out that I have some inconsistencies 
going on in my httpd.conf file. Now I have changed both groups to daemon, and 
changed to owners as Rob suggested. Now it is finally working fine. Would I 
still need to change everything back to 0755? Or, should I ask, what is the 
appropriate permission I should be using here?

Alice


At least that explains why the problem arose from a power failure: you had some 
new settings in the configuration which needed an apache restart to make them 
happen, and when the server rebooted, apache picked up the new settings...


The problem is that if you did chmod -R 777 /var, you changed every file /var 
and ALL of its subdirectories to have 777 permissions, and there's not an easy 
way

[PHP] Re: Corrupted ZIP files (downloaded via a php script) : Internext Explorer 7

2008-07-17 Thread Peter Ford

robert mena wrote:

Hi,

I have a set of files stored in a directory and I need to serve those via a
php script (in order to protect, control access etc).

The problem is that zip files (exe also) get corrupted when I try from IE7.
 I've read the posts from this list and google etc with no idea of how to
solve it.

The stored files are ok (tested from firefox or direct copy).  When I use
IE7 the file size is smaller.  In my test a config.zip with 248 bytes ends
up with 214 bytes.

This is the code used

header(Pragma: public);
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
header(Cache-Control: private,false);
header(Content-Type: .$type);

if($remove_date_from_file == false)
header('Content-Disposition: attachment;
filename='.basename($file).'');
 else
  {
 $name_ = substr(basename($file),0,strrpos(basename($file),.));
 $ext_ = substr(basename($file),strrpos(basename($file),.));
 $new_name_ = substr($name_,0,strlen($name_)-15).$ext_;
 header('Content-Disposition: attachment;
filename='.$new_name_.'');
 }
 header(Content-Transfer-Encoding: binary);
 header('Content-Length: '.filesize($file));
 while(!feof($fp))
 {
 echo fgets($fp) ;
 }
 fclose($fp);

I've added a debug to send me a message with the header and it comes the
same way no matter what browser.


Pragma: public

Expires: Wed, 16 Jul 2008 23:12:00 GMT

Cache-Control: must-revalidate, post-check=0, pre-check=0

Cache-Control: private

Content-Type: application/zip

Content-Disposition: attachment; filename=config.zip

Content-Transfer-Encoding: binary

Content-Length: 248

Am I doing something wrong or do I have to start looking to the server's
configuration (like mod_deflate)?



Instead of that looping through every byte, have you tried just using the 
readfile() function?


In fact, in that code you posted I don't see you opening the file (where does 
$fp come from?)
Also in your code, you don't flush the file before closing (fflush($fp)), which 
might make a difference, especially since your result seems to be a few bytes short.


Oh, and make VERY sure that there is *nothing* output to the client before you 
start pushing the ZIP file out - that definitely leads to corruption of such 
things, although if you were sending data before changing the headers you would 
get an error message about that.


What I can't understand is why is might work with one browser and not another...

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Trailing Spaces Problem

2008-07-18 Thread Peter Ford

Thiago H. Pojda wrote:

On Fri, Jul 18, 2008 at 11:41 AM, Wei, Alice J. [EMAIL PROTECTED] wrote:


Hi,





Is there some way that I can have it so that it can print out:

1: 1 2:0 3: 70.208 4. 61.613 5. 1.424

I tried using \s for trailing spaces, but It all gave me output of
everything in the single line.
Have I missed something here?



You're just removing every space there is, letting none for values
separation.

Just replace every \s\s with \s until there's no more \s\s.

Probably some regex would be better, but that's not my area :)

Regards,
Thiago



Thanks in advance.

Alice


You probably need to use a regexp, so you can accomodate the different types of 
white space:

?php

 $string=1 0 70.208 61.613 1.424  3.689 61.404 
0.000  0.000  0.000  0.000  0.000;


   $data = preg_split('/\s+/',$string);
  echo 1: . $data[0] .  2:  . $data[1] .  3:  . $data[2] .  4:  . 
$data[3] .  5:  . $data[4]


?

Does that work for you?


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Code beautifier

2008-07-28 Thread Peter Ford

tedd wrote:

At 6:47 PM -0400 7/25/08, Daniel Brown wrote:

On Fri, Jul 25, 2008 at 6:29 PM, tedd [EMAIL PROTECTED] wrote:
  But, there's nothing wrong with starting a sentence with but.


 There, I even started AND ended with one.


Correct, as I said, in Reader's Digest English.  In proper
grammar, it's tantamount to ending a sentence with a preposition[1].
However, even in Reader's Digest English (RDE[TM]), heading a word
with but is acceptable but following it immediately with a comma
is not[2].

1: Hence the name, pre-position --- positioned before.
2: http://www.michbar.org/journal/pdf/pdf4article628.pdf


As I see it, this is more of a When to use a comma thing than a but 
thing.


I use commas like I talk. For example, I would never say:

But that didn't happen.

Instead, I would say

But -- pause -- that didn't happen.

So, I write it:

But, that didn't happen.



It's arguably more correct in this case to use ellipsis:

But ... I could be wrong :)



--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Back to Basics - Why Use Single Quotes?

2008-08-01 Thread Peter Ford

Eric Butera wrote:

On Wed, Jul 30, 2008 at 6:51 PM, Stephen [EMAIL PROTECTED] wrote:

I have traditionally used double quotes going back to my PASCAL days.

I see many PHP examples using single quotes, and I began to adopt that
convention.

Even updating existing code.

And I broke some stuff that was doing variable expansion. So I am back to
using double quotes.

But I wonder, is there any reason to use single quotes?

Stephen


Because sometimes it is nice to do this:

$onclick = ' onclick=...'

Not having to escape my single tick makes it more readable.



Now *that's* a good reason... anything that means fewer \'s or \s.
I often go for HEREDOC syntax if the backslashes start taking over - readability 
is much more important to me than nanoseconds of performance.


There's also the case where you might want literal $s in your string:
e.g.
$foo = 'You need to pay $dollars...';

compared with

$foo = You need to pay \$dollars...;

Again, it depends on you view of backslashes.


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: RSS Feed using PHP/MySQL errors

2008-08-07 Thread Peter Ford

Don Mak wrote:

Trying to create an articles rss feed for my site and I keep getting an
error that says:

=
A semi colon character was expected.
Line: 7 Character: 60
linkhttp://www.chirunning.com/shop/pages.php?pageid=19id=383/link
=



This is an easy one: in both of the following lines

@mysql_connect('localhost', 'x', 'x') or die('ERROR--CAN'T CONNECT
TO SERVER');
@mysql_select_db('shop') or die('ERROR--CAN'T CONNECT TO DB');

you have an unescaped ' in the die() message.

Suggest you use one of:

die(ERROR--CAN'T CONNECT TO SERVER);
die('ERROR--CAN\'T CONNECT TO SERVER');
die('ERROR--CANNOT CONNECT TO SERVER'); // English is a very powerful language!!

and similar for the other message...


There may be other errors in your code, but that's all you were asking about.



--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Re: php File upload

2008-08-08 Thread Peter Ford

Per Jessen wrote:

Tom wrote:


Im very glad to fix this problem, but the next one is here: Other
machine (but 2 GB Ram), same suse version, same (working now)  php.ini
with limits to 5000M now and i can't upload a File greater than 900MB.
A file under 900MB i see the tmp file growing. A File with +1 GB no
temp file seeing at all and break after a view minutes. It's horrible
with no error codes and wasting pure of time :-(


The maximum size of an HTTP request is 2Gb. 



/Per Jessen, Zürich



Also bear in mind that the file is MIME encoded (so probably actually a base-64 
stream or some such) and the actual size of the data sent in the request is 
therefore likely to be some fraction bigger than the file itself (like 33% 
bigger for base-64 encoding)



--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



<    2   3   4   5   6   7   8   9   10   11   >