[PHP] Re: using cookies

2004-05-09 Thread Aidan Lister
Hi,

Richards email was kinda wierd, so I'll reply to your email directly

 Hi, all --

 I guess I need a primer on cookie usage.  I've read the manual regarding
 setcookie and have gone back to look at everything having to do with
 cookies on this list in the past few months (it seems that I'm not the
 only one with some troubles, but most of them appear to have been having
 sent some HTML output before trying to set a cookie).

The manual is all you need to know, you just need to experiment with the
information provided until it clicks in.

 I want to check to see if the user has my cookie to then log him in
 automatically, and if he doesn't then I show the login screen and he logs
 in and then I set the cookie if the box is checked.

Okay, simple:

?php
if (isset($_COOKIE['yourcookie'])) { // they have the login cookie, so do
what you called log them in, whatever that means }
else { // they are not logged in, so include your login page }
?

 Of course, $_COOKIE is set, so I have to check for my cookie name.  Even
 something as simple as

   $_COOKIE['test'] = 'tested';

 followed by a load of the page and a print doesn't show it.

The above stuff didn't really make sense, you havn't explained what you are
trying to do and what does not work.

 Do I only call setcookie if the cookie isn't set, or do i call it every
 time I load the page to initialize it?  Once I set it, how do I read it?
 Does anyone have any pointers to a basic tutorial?

setcookie() does what you would expect, sets a cookie. As explained on the
PHP manual,  setcookie -- Send a cookie 
So, logically, you only need to call it when you want to set a cookie...

If you want to read the contents of the cookie, print_r($_COOKIE); That will
show you all cookie information on their computer for your domain.

If you know the name of the cookie you set, simply print $_COOKIE['name']

There's not a lot to it, all the information you'll need is on the manual,
good luck!


 TIA  HAND


David T-G [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

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



Re: [PHP] $myobject-$$varname doens't work ??

2004-05-09 Thread Aidan Lister
Richard,

I think you need to read the questions more accurately - your last two
replies have been somewhat incorrect


Richard Harb [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Try
 echo $obj-$varname;


 -Original Message-
 From: greg
 Sent: Sunday, May 9, 2004, 9:21:52 AM
  Hello,

  I was just trying this but it doesn't work :
  ?php

  class a {
 public $foo = hello world;
  }

  $obj = new a();
  $varname = foo;
 echo $obj-$$varname;

  $bar = this is working;
  $varname = bar;
  echo $$varname; // display this is working as expected
 ?

  Is it a bug or is it normal ?
  I didn't find anything about it in documentation (php4 / php5).

  Greg

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



Re: [PHP] $myobject-$$varname doens't work ??

2004-05-09 Thread Aidan Lister
Ooops, actually he was pretty ambiguous, please disregard my previous
comment :)


Richard Harb [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Try
 echo $obj-$varname;


 -Original Message-
 From: greg
 Sent: Sunday, May 9, 2004, 9:21:52 AM
  Hello,

  I was just trying this but it doesn't work :
  ?php

  class a {
 public $foo = hello world;
  }

  $obj = new a();
  $varname = foo;
 echo $obj-$$varname;

  $bar = this is working;
  $varname = bar;
  echo $$varname; // display this is working as expected
 ?

  Is it a bug or is it normal ?
  I didn't find anything about it in documentation (php4 / php5).

  Greg

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



[PHP] Re: $myobject-$$varname doens't work ??

2004-05-09 Thread Aidan Lister

Greg [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hello,

 I was just trying this but it doesn't work :
 ?php

 class a {
public $foo = hello world;
 }

 $obj = new a();
 $varname = foo;
 echo $obj-$$varname;


$$varname is turned into $foo, what is the value of $foo?

If you're trying to access public $foo then Richard was entirely correct
(sorry richard!), just do it like so: $a-foo

If, like in the below example, $foo is the name of a variable that you want
to access, then try ${$foo}, everynow and then there's a problem to that
effect

Good luck, welcome to oop :)


 $bar = this is working;
 $varname = bar;
 echo $$varname; // display this is working as expected
 ?

 Is it a bug or is it normal ?
 I didn't find anything about it in documentation (php4 / php5).

 Greg

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



[PHP] Re: $myobject-$$varname doens't work ??

2004-05-09 Thread greg
Good luck, welcome to oop :)

PHP 5 is great ! :D
My favorites are __get() and __set()
It allows a very flexible programmation and a very simple programmation 
when using huge objects correctly implemented.

Greg

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


[PHP] Strange mails...

2004-05-09 Thread greg
Each time I post a message on p.general, i receive two strange mails 
from ADVANCE CREDIT SUISSE BANK.

What's this spam ? It looks like an auto-responder is subscribed on the 
newsgroup. Spammers really s*x !

Greg

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


[PHP] preg_replace to delete all js code in string help needed

2004-05-09 Thread Dave Carrera
$text2 = preg_replace(/script[^]+.*?\/script/is,,$text2);

Leaves output with language=javascript blah blah

Dose anyone know of a pattern that will get rid of ALL javascript from a
string.

Thank you for any help

Dave Carrera


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.679 / Virus Database: 441 - Release Date: 07/05/2004
 

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



[PHP] icmp echo / ping

2004-05-09 Thread news.php.net
Hi,

I was wondering if it's possible to issue a icmp echo / ping without
actually using the ping program supplied with the operating system.

Anyone has an idea?

Thanks in advance.



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



[PHP] Re: icmp echo / ping

2004-05-09 Thread Aidan Lister
Yep, check out:

http://pear.php.net/net_ping


News.Php.Net [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 I was wondering if it's possible to issue a icmp echo / ping without
 actually using the ping program supplied with the operating system.

 Anyone has an idea?

 Thanks in advance.



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



Re: [PHP] preg_replace to delete all js code in string help needed

2004-05-09 Thread Curt Zirzow
* Thus wrote Dave Carrera ([EMAIL PROTECTED]):
 $text2 = preg_replace(/script[^]+.*?\/script/is,,$text2);
 
 Leaves output with language=javascript blah blah

I tested that and it strips the script tags with language too. I
do know that it will not strip script tags that have no attributes:
   script var yada;... /script

This will fix that though:
   /script[^]*?.*?\/script/is

   or
   !script[^]*.*/script!/isU


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



[PHP] Putting a stop in a foreach

2004-05-09 Thread Verdon Vaillancourt
Hi :)

I'm trying to put a stop in a foreach statement following the user
suggestion here, php.net/manual/en/control-structures.foreach.php

Not really knowing what I am doing, I am running into some synatx problems.
I'm sure I'm doing something really stupid, can anybody point it out?

This is the original statement that works...

foreach ($this-_content as $item) {
if ($item['type'] == 'item'){
$elements['ITEM_LINK'] = $item['link'];
$elements['ITEM_TITLE'] = $item['title'];
$elements[TARGET] = $this-_target;
$items .= PHPWS_Template::processTemplate($elements,
phpwsrssfeeds, block_item.tpl);
}
} 


This is my attempt to count items and put a stop in the foreach so it only
returns 5 items.

foreach ($this-_content as $n = $item) {
if ($n==5) { 
break;
} else { 
if ($this-_content[$n] = $item['type'] == 'item'){
$elements['ITEM_LINK'] = $this-_content[$n] = $item['link'];
$elements['ITEM_TITLE'] = $this-_content[$n] = $item['title'];
$elements[TARGET] = $this-_target;
$items .= PHPWS_Template::processTemplate($elements,
phpwsrssfeeds, block_item.tpl);
}
}
}

Php doesn't like the syntax on any of the,
$this-_content[$n] = $item['type']
, etc lines


TIA,
Verdon

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



[PHP] Re: Putting a stop in a foreach

2004-05-09 Thread Torsten Roehr
Verdon Vaillancourt [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi :)

 I'm trying to put a stop in a foreach statement following the user
 suggestion here, php.net/manual/en/control-structures.foreach.php

 Not really knowing what I am doing, I am running into some synatx
problems.
 I'm sure I'm doing something really stupid, can anybody point it out?

 This is the original statement that works...

 foreach ($this-_content as $item) {
 if ($item['type'] == 'item'){
 $elements['ITEM_LINK'] = $item['link'];
 $elements['ITEM_TITLE'] = $item['title'];
 $elements[TARGET] = $this-_target;
 $items .= PHPWS_Template::processTemplate($elements,
 phpwsrssfeeds, block_item.tpl);
 }
 }


 This is my attempt to count items and put a stop in the foreach so it only
 returns 5 items.

 foreach ($this-_content as $n = $item) {
 if ($n==5)

 break;
 } else

 if ($this-_content[$n] = $item['type'] == 'item'){
 $elements['ITEM_LINK'] = $this-_content[$n] = $item['link'];
 $elements['ITEM_TITLE'] = $this-_content[$n] =
$item['title'];
 $elements[TARGET] = $this-_target;
 $items .= PHPWS_Template::processTemplate($elements,
 phpwsrssfeeds, block_item.tpl);
 }
 }
 }

Why don't you use a for() loop to restrict to 5 loops?:

$count = count($this-_content);
for ($i; $i  5; $i++) {
...
}


 Php doesn't like the syntax on any of the,
 $this-_content[$n] = $item['type']

Because = is a foreach() specific syntax. As far as I understand you don't
need $this-_content[$n] as this is the same as $item, so just omit
'$this-_content[$n] =':

 if ($item['type'] == 'item'){
 $elements['ITEM_LINK'] = $item['link'];
 $elements['ITEM_TITLE'] = $item['title'];
 $elements[TARGET] = $this-_target;
 $items .= PHPWS_Template::processTemplate($elements,
phpwsrssfeeds, block_item.tpl);
 }

Please try and report if it helped.

Regards, Torsten

 , etc lines


 TIA,
 Verdon

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



[PHP] Re: Putting a stop in a foreach

2004-05-09 Thread Torsten Roehr
  This is my attempt to count items and put a stop in the foreach so it
only
  returns 5 items.
 
  foreach ($this-_content as $n = $item) {
  if ($n==5)

  break;
  } else

  if ($this-_content[$n] = $item['type'] == 'item'){
  $elements['ITEM_LINK'] = $this-_content[$n] =
$item['link'];
  $elements['ITEM_TITLE'] = $this-_content[$n] =
 $item['title'];
  $elements[TARGET] = $this-_target;
  $items .= PHPWS_Template::processTemplate($elements,
  phpwsrssfeeds, block_item.tpl);
  }
  }
  }

 Why don't you use a for() loop to restrict to 5 loops?:

 $count = count($this-_content);
 for ($i; $i  5; $i++) {
 ...
 }

 
  Php doesn't like the syntax on any of the,
  $this-_content[$n] = $item['type']

 Because = is a foreach() specific syntax. As far as I understand you
don't
 need $this-_content[$n] as this is the same as $item, so just omit
 '$this-_content[$n] =':

  if ($item['type'] == 'item'){
  $elements['ITEM_LINK'] = $item['link'];
  $elements['ITEM_TITLE'] = $item['title'];
  $elements[TARGET] = $this-_target;
  $items .= PHPWS_Template::processTemplate($elements,
 phpwsrssfeeds, block_item.tpl);
  }

Sorry, I mixed up the for and the foreach syntaxes. Here my (hopefully
correct) loop proposal:

for ($i; $i  5; $i++) {

 if (is_array($this-_content)  is_array($this-_content[$i]) 
$this-_content[$i]['type'] == 'item') {
   $elements['ITEM_LINK']  = $this-_content[$i]['link'];
   $elements['ITEM_TITLE'] = $this-_content[$i]['title'];
   $elements['TARGET'] = $this-_target;
   $items .= PHPWS_Template::processTemplate($elements, 'phpwsrssfeeds',
'block_item.tpl');
}
}

$elements and items should be initialized before the loop.


 Please try and report if it helped.

 Regards, Torsten

  , etc lines
 
 
  TIA,
  Verdon

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



[PHP] Re: Putting a stop in a foreach

2004-05-09 Thread Aidan Lister
Simple!

$i = 0;
foreach ($foos as $foo)
{
 // do stuff

$i++;
if ($i  5) break;
}

Cheers


Verdon Vaillancourt [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi :)

 I'm trying to put a stop in a foreach statement following the user
 suggestion here, php.net/manual/en/control-structures.foreach.php

 Not really knowing what I am doing, I am running into some synatx
problems.
 I'm sure I'm doing something really stupid, can anybody point it out?

 This is the original statement that works...

 foreach ($this-_content as $item) {
 if ($item['type'] == 'item'){
 $elements['ITEM_LINK'] = $item['link'];
 $elements['ITEM_TITLE'] = $item['title'];
 $elements[TARGET] = $this-_target;
 $items .= PHPWS_Template::processTemplate($elements,
 phpwsrssfeeds, block_item.tpl);
 }
 }


 This is my attempt to count items and put a stop in the foreach so it only
 returns 5 items.

 foreach ($this-_content as $n = $item) {
 if ($n==5) {
 break;
 } else {
 if ($this-_content[$n] = $item['type'] == 'item'){
 $elements['ITEM_LINK'] = $this-_content[$n] = $item['link'];
 $elements['ITEM_TITLE'] = $this-_content[$n] =
$item['title'];
 $elements[TARGET] = $this-_target;
 $items .= PHPWS_Template::processTemplate($elements,
 phpwsrssfeeds, block_item.tpl);
 }
 }
 }

 Php doesn't like the syntax on any of the,
 $this-_content[$n] = $item['type']
 , etc lines


 TIA,
 Verdon

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



Re: [PHP] Putting a stop in a foreach

2004-05-09 Thread Verdon Vaillancourt
Hmm, yes I see. Thank you.

I guess what I should look at then is getting the key value (internal
counter/pointer) in the array going to the foreach. Like this example...

$a = array( 1,2,3,17 );

$i =0;/* for illustrative purposes only */

foreach ( $a as $v ) {
    echo \$ a[$i ]= $v. \n ;
   $i ++; 
}

Once I have that key value (internal counter) I should be able to do
something with it? What I really want to do (since I can't easily get at the
query building the array being passed to the foreach) is get the foreach to
stop outputting results at a certain limit.

Thanks again,
Verdon


On 5/9/04 11:34 AM, Matt Schroebel [EMAIL PROTECTED] wrote:

 It's good to understand what foreach is doing:
 ?php
 $car['GM'] = 'Impala';
 $car['TOYOTA'] = 'Corolla';
 $car['HONDA'] = 'Civic';
 
 foreach ($car as $manufacturer = $ model) {
 echo $manufacturer - $model br /\n;
 }
 ?
 
 Results:
 GM - Impala
 TOYOTA - Corolla
 HONDA - Civic
 
 
 

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



[PHP] RE: preg_replace to delete all js code in string help needed

2004-05-09 Thread Dave Carrera
Thanks Greg,
That sorted that out nicely :-)

Dave Carrera


-Original Message-
From: greg [mailto:[EMAIL PROTECTED] 
Sent: 09 May 2004 14:17
To: Dave Carrera
Subject: Re: preg_replace to delete all js code in string help needed


Dave Carrera wrote:
 $text2 = preg_replace(/script[^]+.*?\/script/is,,$text2);
 
 Leaves output with language=javascript blah blah
 
 Dose anyone know of a pattern that will get rid of ALL javascript from 
 a string.
 
 Thank you for any help
 
 Dave Carrera
 
 
 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.679 / Virus Database: 441 - Release Date: 07/05/2004
  

Try $text2 = preg_replace(/script[^]*.*\/script/is,,$text2)

It works for me.

Greg


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.679 / Virus Database: 441 - Release Date: 07/05/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.679 / Virus Database: 441 - Release Date: 07/05/2004
 

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



Re: [PHP] Re: protecting web page

2004-05-09 Thread Daniel Clark
I agree.  Once the screen, text, or picture is on the clients machine they have a 
copy of it.

Petr U. wrote:
 On Sat, 08 May 2004 21:00:43 -0500
 Anguz [EMAIL PROTECTED] wrote:
 
Do you know any solution that can help me. I've find an application named
HTML guard but it only work for static html pages. I need more a class or
function to prevent for printing.
 
 There is _no way_ to really hide/protect html page on client side.. If someone
 (some knowing) would like to show your source and it's important for him, then
 he spend some time to break this ugly protection.

Just to strengthen/clarify this statement, look at it this way.  The user has 
downloaded the data to his machine.  You don't have any control over the data 
after that point.  Heck, the user can just print the screen they are looking 
at.  How you gonna stop that?

If you're just looking to discourage casual copying, then carry on. :-)  If 
it's really important, you might be able to generate non-printable PDF files, 
or generate images containing the desired text, or stuff like that.  Just to 
make copying/printing harder.




php-general Digest 9 May 2004 16:11:30 -0000 Issue 2753

2004-05-09 Thread php-general-digest-help

php-general Digest 9 May 2004 16:11:30 - Issue 2753

Topics (messages 185727 through 185747):

using cookies
185727 by: David T-G
185729 by: Richard Harb
185731 by: Aidan Lister

$myobject-$$varname doens't work ??
185728 by: greg
185730 by: Richard Harb
185732 by: Aidan Lister
185733 by: Aidan Lister
185734 by: Aidan Lister
185735 by: greg

Strange mails...
185736 by: greg

preg_replace to delete all js code in string help needed
185737 by: Dave Carrera
185740 by: Curt Zirzow
185746 by: Dave Carrera

icmp echo / ping
185738 by: news.php.net
185739 by: Aidan Lister

Putting a stop in a foreach
185741 by: Verdon Vaillancourt
185742 by: Torsten Roehr
185743 by: Torsten Roehr
185744 by: Aidan Lister
185745 by: Verdon Vaillancourt

Re: protecting web page
185747 by: Daniel Clark

Administrivia:

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

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

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
Hi, all --

I guess I need a primer on cookie usage.  I've read the manual regarding
setcookie and have gone back to look at everything having to do with
cookies on this list in the past few months (it seems that I'm not the
only one with some troubles, but most of them appear to have been having
sent some HTML output before trying to set a cookie).

I want to check to see if the user has my cookie to then log him in
automatically, and if he doesn't then I show the login screen and he logs
in and then I set the cookie if the box is checked.

Of course, $_COOKIE is set, so I have to check for my cookie name.  Even
something as simple as

  $_COOKIE['test'] = 'tested';

followed by a load of the page and a print doesn't show it.

Do I only call setcookie if the cookie isn't set, or do i call it every
time I load the page to initialize it?  Once I set it, how do I read it?
Does anyone have any pointers to a basic tutorial?


TIA  HAND

:-D
-- 
David T-G
[EMAIL PROTECTED]
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature
---End Message---
---BeginMessage---
-Original Message-
From: David T-G
Sent: Sunday, May 9, 2004, 6:09:06 AM
 Hi, all --

 I guess I need a primer on cookie usage.  I've read the manual regarding
 setcookie and have gone back to look at everything having to do with
 cookies on this list in the past few months (it seems that I'm not the
 only one with some troubles, but most of them appear to have been having
 sent some HTML output before trying to set a cookie).

 I want to check to see if the user has my cookie to then log him in
 automatically, and if he doesn't then I show the login screen and he logs
 in and then I set the cookie if the box is checked.

 Of course, $_COOKIE is set, so I have to check for my cookie name.  Even
 something as simple as

   $_COOKIE['test'] = 'tested';

Under normal circumstances you don't need to do that (unless you know
what you are doing - but it will not set a cookie on the client side,
it only modifies your superglobal variable for as long as the script
runs. I guess I'm once again stating the obvious).


 followed by a load of the page and a print doesn't show it.

 Do I only call setcookie if the cookie isn't set, or do i call it every
 time I load the page to initialize it?  Once I set it, how do I read it?

Once you setcookie() you can optionally give it something on its way:
like name, value, expire time/date, etc.

You could for example set a cookie to expire in half an hour - i.e.
for a session. It might make sense to refresh that cookie on every
page request, so that a session timeout will be postponed on each
refresh.

If you omit the expire time, it will be valid until the end of the
session (browser closes) - see the docs.


How do you get your cookie back?

If your visitor has a browser that allows cookies and you already sent
him one (or more) before, he will automatically transmit it to you as
part of the HTTP request headers. PHP does its magic and places the
values received into that Superglobal $_COOKIE (as well as $_REQUEST)
for you to play with...

So, if that array is empty that could mean two things:
1) you didn't send any cookie before (either because you already sent
your headers and thus have a f***up in your code or because the
visitor hasn't been to your page before)
2) the visitor does not allow cookies - too bad.


I guess that's all there is to it. Someone correct me or add to that
:)


 Does anyone have any pointers to a basic tutorial?

I didn't use any other page except the obvious one ...
http://www.php.net/manual/en/function.setcookie.php

I hope that answers at least part of what you were looking for ...

Richard

Re: [PHP] Putting a stop in a foreach

2004-05-09 Thread Curt Zirzow
* Thus wrote Verdon Vaillancourt ([EMAIL PROTECTED]):
 Hi :)
 
 This is the original statement that works...
 
 foreach ($this-_content as $item) {
 if ($item['type'] == 'item'){
 ..

ok. good so far.

 
 
 This is my attempt to count items and put a stop in the foreach so it only
 returns 5 items.
 
 foreach ($this-_content as $n = $item) {
 if ($n==5) { 
 break;
 } else { 
 if ($this-_content[$n] = $item['type'] == 'item'){

I'm  not sure why  you  changed all this.

All you have to do is a simple foreach loop with a counter, and
break when the counter reaches your condition:

$need = 5; /* how many we want */

foreach($this-_content as $index = $item) {

  if ($item['type'] == 'item') {
//...

/* only decrement if its an 'item' */
$need--;
  }
  if (! $need) break; /* we got everything we needed */
}


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] protecting web page

2004-05-09 Thread Curt Zirzow
* Thus wrote [EMAIL PROTECTED] ([EMAIL PROTECTED]):
 Hi,
 
 i'm designing a web application and i want to protect my web page from
 printing and if possible want to protect source code too.

You can prevent the average joe from printing by putting some css
in your document:

@media print { body { display:  none; } }



Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] Strange mails...

2004-05-09 Thread Daniel Clark
Yep.  I'm getting it too.

Each time I post a message on p.general, i receive two strange mails 
from ADVANCE CREDIT SUISSE BANK.

What's this spam ? It looks like an auto-responder is subscribed on the 
newsgroup. Spammers really s*x !

Greg

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



[PHP] feof Question

2004-05-09 Thread Harish

Hi

I am using Linux, Apache, MySql, PHP. In the below mentioned code example when the 
counter data that is displayed on the screen going to a indefinite loop. The file that 
is read has got sufficient permissions.

What are the reasons and how do I tackle the problem?

?php
$fp = fopen( 't.txt', 'r' );

while( !feof( $fp ) )
{
   print fgets( $fp );
   echo $counterval++;
   if($counterval%100==0)
   {
  flush();
   }
}
fclose( $fp );
?



Regards,
Harish Rao K


Re: [PHP] Re: Putting a stop in a foreach

2004-05-09 Thread Curt Zirzow
* Thus wrote Torsten Roehr ([EMAIL PROTECTED]):
 
 Sorry, I mixed up the for and the foreach syntaxes. Here my (hopefully
 correct) loop proposal:
 
 for ($i; $i  5; $i++) {

for($i=0; ...)

I wouldn't suggest this method, it is making the assumption that
the indexes are numeric and sequenced from 0..5


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] feof Question

2004-05-09 Thread Petr U.
On Sun, 9 May 2004 22:00:53 +0530
Harish [EMAIL PROTECTED] wrote:

  ?php
  $fp = fopen( 't.txt', 'r' );
  
  while( !feof( $fp ) )
  {
 print fgets( $fp );
 echo $counterval++;
 if($counterval%100==0)
 {
flush();
 } 
  }
  fclose( $fp );
  ?

Modify your code like this and send it's output.. 

/* or ini_set('error_reporting', E_ALL);  if your version
 * of php don't know error_reporting() */
error_reporting(E_ALL);

$fp = fopen('t.txt', 'r');
if (! $fp) {
die('Some error here!');
}

-- 
Petr U.

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



Re: [PHP] feof Question

2004-05-09 Thread Curt Zirzow
* Thus wrote Harish ([EMAIL PROTECTED]):
 
 Hi
   
 I am using Linux, Apache, MySql, PHP. In the below mentioned code example when the 
 counter data that is displayed on the screen going to a indefinite loop. The file 
 that is read has got sufficient permissions.
 
 What are the reasons and how do I tackle the problem?
 
 ?php
 $fp = fopen( 't.txt', 'r' );

if ($fp === false) {
  die('cant open file');
}

always check the result of an fopen. feof() will only work on a
valid file handle.

$fp = false;
while (!feof($fp) ) {
  //infinite loop
}

and you'll never know what hit you if your error_reporting is to
low; ensure that at minimum, E_WARNING is on.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] Re: Putting a stop in a foreach

2004-05-09 Thread Torsten Roehr
Curt Zirzow [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 * Thus wrote Torsten Roehr ([EMAIL PROTECTED]):
 
  Sorry, I mixed up the for and the foreach syntaxes. Here my (hopefully
  correct) loop proposal:
 
  for ($i; $i  5; $i++) {

 for($i=0; ...)

 I wouldn't suggest this method, it is making the assumption that
 the indexes are numeric and sequenced from 0..5

Correct, I forgot =0. But as far as I have seen his indices are numeric.

Regards, Torsten



 Curt
 --
 I used to think I was indecisive, but now I'm not so sure.

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



[PHP] Re: Putting a stop in a foreach - SOLVED

2004-05-09 Thread Verdon Vaillancourt
Hi Torsten, Aidan and Matt

Both of Torsten's and Aidan's suggestions worked, though the number of
returned results using Aidan's method isn't what I expected. This could be
the result of something else and I'm trying to puzzle out why. Matt helped
clarify my basic misunderstanding in what the foreach statement was doing.

Conceptually though, Torsten's and Aidan's suggestions both work.

On 5/9/04 12:11 PM, Torsten Roehr wrote:

 Sorry, I mixed up the for and the foreach syntaxes. Here my (hopefully
 correct) loop proposal:
 
 for ($i; $i  5; $i++) {
 
if (is_array($this-_content)  is_array($this-_content[$i]) 
 $this-_content[$i]['type'] == 'item') {
  $elements['ITEM_LINK']  = $this-_content[$i]['link'];
  $elements['ITEM_TITLE'] = $this-_content[$i]['title'];
  $elements['TARGET'] = $this-_target;
  $items .= PHPWS_Template::processTemplate($elements, 'phpwsrssfeeds',
 'block_item.tpl');
   }
 }
 
 $elements and items should be initialized before the loop.
 
 
 Please try and report if it helped.
 
 Regards, Torsten



On 5/9/04 12:11 PM, Aidan Lister wrote:

 Simple!
 
 $i = 0;
 foreach ($foos as $foo)
 {
 // do stuff
 
   $i++;
   if ($i  5) break;
 }
 
 Cheers
 
 
 Verdon Vaillancourt [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Hi :)
 
 I'm trying to put a stop in a foreach statement following the user
 suggestion here, php.net/manual/en/control-structures.foreach.php
 
 Not really knowing what I am doing, I am running into some synatx
 problems.
 I'm sure I'm doing something really stupid, can anybody point it out?
 
 This is the original statement that works...
 
 foreach ($this-_content as $item) {
 if ($item['type'] == 'item'){
 $elements['ITEM_LINK'] = $item['link'];
 $elements['ITEM_TITLE'] = $item['title'];
 $elements[TARGET] = $this-_target;
 $items .= PHPWS_Template::processTemplate($elements,
 phpwsrssfeeds, block_item.tpl);
 }
 }
 
 
 This is my attempt to count items and put a stop in the foreach so it only
 returns 5 items.
 
 foreach ($this-_content as $n = $item) {
 if ($n==5) {
 break;
 } else {
 if ($this-_content[$n] = $item['type'] == 'item'){
 $elements['ITEM_LINK'] = $this-_content[$n] = $item['link'];
 $elements['ITEM_TITLE'] = $this-_content[$n] =
 $item['title'];
 $elements[TARGET] = $this-_target;
 $items .= PHPWS_Template::processTemplate($elements,
 phpwsrssfeeds, block_item.tpl);
 }
 }
 }
 
 Php doesn't like the syntax on any of the,
 $this-_content[$n] = $item['type']
 , etc lines
 

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



[PHP] Re: Graphical calendar

2004-05-09 Thread Manuel Lemos
Hello,

On 05/08/2004 02:59 PM, Todd Cary wrote:
Works like a champ!

Question: has anyone extended the class so that when one clicks on a 
day, the year, month, day is returned?
You can use the example sub-class and change it to change the cell data 
that is stored in $columndata[data] to be a link to some page that 
will display whatever you want about the day. The class variables 
$this-year, $this-month and $this-day contain the date of the day of 
the current cell.

--

Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] hash with RIPEMD-160

2004-05-09 Thread Dennis Gearon
Please CC me as I am on digest.

Anyone using RIPEMD-160 for hashing in PHP? Is it part of Apache or the 
underlying OS?

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


[PHP] Clean Open Source PHP extranet app?

2004-05-09 Thread david david
Hello,

I am looking to create a simple extranet type
application similar to http://www.basecamphq.com/
written by 37signals.

Basically I just need a way for users to share
files/projects/messages.  

In fact, I would just go ahead and pay for Basecamp
except that it's closed source and it's only available
as a hosted service. (??!?)

Is there a similar open source application written in
PHP/MySQL?

Googling for such a project just returned a bunch of
PHPnuke/Portal type applications.  Not at all what I
need.

Any ideas?

Thanks,
David




__
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

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



[PHP] Curl cookies

2004-05-09 Thread Jason Morehouse
Has anyone tried using curl to fetch a web page and cookies?


?
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://www.php.net');
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR,'cookie.txt');
curl_setopt ($ch, CURLOPT_COOKIE,1);
$content = curl_exec ($ch);
curl_close ($ch);
$cookie = file_get_contents('cookie.txt');
print $cookie;
?


This works fine, and the cookie gets stored in the cookie.txt file, but it
only ever returns 1 cookie.  There should be 2 for php.net.  Same with
pretty much any other site.  Are there any configuration items I'm missing
for the cookie jar?


--
Jason Morehouse ([EMAIL PROTECTED])
Netconcepts LTD - Auckland, New Zealand
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Clean Open Source PHP extranet app?

2004-05-09 Thread John W. Holmes
david david wrote:

I am looking to create a simple extranet type
application similar to http://www.basecamphq.com/
written by 37signals.
Basically I just need a way for users to share
files/projects/messages.  
Maybe PHProjekt?

http://www.phprojekt.com/

I'm sure hotscripts.com will have others.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


[PHP] Does this directory detection script work for you?

2004-05-09 Thread John W. Holmes
Hello. I'm relying on the following code so that a script can 
automatically detect where it's installed and create paths and URLs from 
the information. This way absolute paths and URLs are always used.

I've had a couple people report that the script wasn't finding the paths 
correctly, though, so I'm asking if people could test this out on their 
server and see if it detects the paths or not.

?php
//Install path (path to survey.class.php)
$path = dirname($_SERVER['PATH_TRANSLATED']);
//Determine protocol of web pages
if(isset($_SERVER['HTTPS'])  
strcasecmp($_SERVER['HTTPS'],'ON') == 0)
{ $protocol = 'https://'; }
else
{ $protocol = 'http://'; }

//HTML address of this program
$dir_name = dirname($_SERVER['SCRIPT_NAME']);
if($dir_name == '\\')
{ $dir_name = ''; }
$html = $protocol . $_SERVER['SERVER_NAME'] . $dir_name;

//Determine web address of current page
$current_page = $protocol . $_SERVER['SERVER_NAME'] . 
$_SERVER['SCRIPT_NAME'];

echo Path to script: $pathbr /;
echo URL to script directory: $htmlbr /;
echo URL to current script: $current_page;
?
It should print out the file system path to where the script was placed 
as well as a URL to the directory it was placed and a URL to the file 
itself.

I've never had an issue with it personally and I've tested it on Apache 
and IIS on both Windows and Linux. So maybe it's some obscure CGI or OS 
configuration where this isn't working? I just need to know so I can 
plan accordingly.

The only two substitutions that can be made (that I know of) are:

$_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF']
and
$_SERVER['PATH_TRANSLATED'] = $_SERVER['SCRIPT_FILENAME']
If it doesn't work for you, does it work if you do one of those 
substitutions?

Also, this will test if the script is in subdirectories or not, also, so 
testing it within one and seeing if that works, too, is appreciated.

Thanks for any help and time you're willing to provide.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


Re: [PHP] Clean Open Source PHP extranet app?

2004-05-09 Thread Justin French
On 10/05/2004, at 9:11 AM, david david wrote:

Hello,

I am looking to create a simple extranet type
application similar to http://www.basecamphq.com/
written by 37signals.
Basically I just need a way for users to share
files/projects/messages.
In fact, I would just go ahead and pay for Basecamp
except that it's closed source and it's only available
as a hosted service. (??!?)
Is there a similar open source application written in
PHP/MySQL?
Googling for such a project just returned a bunch of
PHPnuke/Portal type applications.  Not at all what I
need.
Any ideas?
There's a few under Groupware at http://www.opensourcecms.com/, but I 
have no idea what any of them are like... lucky this site has demo's of 
them all :)

I don't think you'll find anything as good as Basecamp though, which is 
VERY slick.

---
Justin French
http://indent.com.au
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] PHP /\ UML

2004-05-09 Thread Matthias H. Risse
Hi,

I wonder if anyone here is aware of UML Tools
for PHP? I know of ArgoUML whichs PHP-codegenerator
seems to be very beta.
Maybe there are or are planned and well intergrated plugins for Zend 
Studio, PHPEd, TruStudio/Eclipse or alike? Basically I would be 
interrested in a solution that really makes it possible to use UML in 
the design and implementation process and which works both ways 
(code-uml, uml-code)..

I hope this is not offtopic for this list, but I couldnt find
any public OO-related one.
Yours,
Matthias
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] exclude_once(); ?

2004-05-09 Thread Matthias H. Risse
Hi again!

Question:
Does anyone know of a possibility to exclude files which
have been included _before_ my script starts on the
fly (e.g. at the first lines after the entrypoint) ?
Reasons:
This ISP of my customer somehow includes a bunch of
old PEAR files by default which I dont need or of which I
need in a later version. So when several PEAR-packages
perform a require_once('HTML/foo.php') PHP recognizes that
it has already included foo.php and does not overload with
the one specified in my user space code.
Maybe there is a general possibility from blocking
my ISP including some files by default?
Anyone knows why this has become practice by some
ISPs? (Doesnt make sense to me to have overhead
for dozens of requests which scripts most of the
dont require those classes to be used).
Yours,
M
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: using cookies

2004-05-09 Thread David T-G
Aidan (and Richard and others) --

...and then Aidan Lister said...
% 
% Hi,

Hi!


% 
% Richards email was kinda wierd, so I'll reply to your email directly

Thanks :-)  And, while I appreciated it, I didn't get a lot from it.

Of course, this one basically says just read the manual, so I'm not
getting a *whole* lot from it, either!


% 
...
% Okay, simple:
% 
% ?php
% if (isset($_COOKIE['yourcookie'])) { // they have the login cookie, so do
% what you called log them in, whatever that means }
% else { // they are not logged in, so include your login page }
% ?

Aha!  Perhaps I was unclear.  I'm sorry; it was late :-)

When the surfer returns to the page tomorrow or next week or in a month,
I want to see that I have stored his acct info in a cookie on his machine
so that I can automatically log him in rather than requiring that he type
his name and pass again.  There is a remember me type of checkbox on
the login page so that he can tell me to save the info for next time.

*That* is what I can't seem to grasp...  If I set the cookie, then I'm
stepping on the old value and so I can't automatically log him in (or
at least as I understand it, and I certainly haven't seen anything in
$_COOKIE to make me think otherwise).

Perhaps now I've given everyone better info on which to base a response :-)


TIA again  HAND

:-D
-- 
David T-G
[EMAIL PROTECTED]
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP] exclude_once(); ?

2004-05-09 Thread Justin French
On 10/05/2004, at 11:27 AM, Matthias H. Risse wrote:

Hi again!

Question:
Does anyone know of a possibility to exclude files which
have been included _before_ my script starts on the
fly (e.g. at the first lines after the entrypoint) ?
Reasons:
This ISP of my customer somehow includes a bunch of
old PEAR files by default which I dont need or of which I
need in a later version. So when several PEAR-packages
perform a require_once('HTML/foo.php') PHP recognizes that
it has already included foo.php and does not overload with
the one specified in my user space code.
Yuk.  That's awful.  The host should NOT have this set.  The host 
should allow it as an option, but not as a default.

http://www.php.net/ini_set
You can override the auto_append_file value of php.ini with a 
per-directory .htaccess file, with something like (untested):

IfModule mod_php4.c
php_value auto_append_file ''
/IfModule
OR

IfModule mod_php4.c
php_value auto_append_file NULL
/IfModule
... placed in your http document root should do the trick.  Of course, 
if the host doesn't allow per-dir .htaccess files, then you're screwed. 
 I'd move hosts very quick.

---
Justin French
http://indent.com.au
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Does this directory detection script work for you?

2004-05-09 Thread Richard Harb
Hello,

I see one potential problem with this detection in one special case.

This will only occur if you use Apache's feature PATH_INFO.

There $current_page will be inaccurate as the scriptname might
be /index.php but the URL could be /index.php/path/to/mypage or just
/index/path/to/mypage - depending on Apache's configuration and link
presentation.

I mention this because I have used this extensively to work around
having to rely on mod_rewrite.

Richard


-Original Message-
From: John W. Holmes
Sent: Monday, May 10, 2004, 2:21:36 AM
 Hello. I'm relying on the following code so that a script can 
 automatically detect where it's installed and create paths and URLs from
 the information. This way absolute paths and URLs are always used.

 I've had a couple people report that the script wasn't finding the paths
 correctly, though, so I'm asking if people could test this out on their
 server and see if it detects the paths or not.

 ?php
  //Install path (path to survey.class.php)
  $path = dirname($_SERVER['PATH_TRANSLATED']);

  //Determine protocol of web pages
  if(isset($_SERVER['HTTPS'])  
 strcasecmp($_SERVER['HTTPS'],'ON') == 0)
  { $protocol = 'https://'; }
  else
  { $protocol = 'http://'; }

  //HTML address of this program
  $dir_name = dirname($_SERVER['SCRIPT_NAME']);
  if($dir_name == '\\')
  { $dir_name = ''; }

  $html = $protocol . $_SERVER['SERVER_NAME'] . $dir_name;

  //Determine web address of current page
  $current_page = $protocol . $_SERVER['SERVER_NAME'] . 
 $_SERVER['SCRIPT_NAME'];

  echo Path to script: $pathbr /;
  echo URL to script directory: $htmlbr /;
  echo URL to current script: $current_page;
?

 It should print out the file system path to where the script was placed
 as well as a URL to the directory it was placed and a URL to the file
 itself.

 I've never had an issue with it personally and I've tested it on Apache
 and IIS on both Windows and Linux. So maybe it's some obscure CGI or OS
 configuration where this isn't working? I just need to know so I can
 plan accordingly.

 The only two substitutions that can be made (that I know of) are:

 $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF']
 and
 $_SERVER['PATH_TRANSLATED'] = $_SERVER['SCRIPT_FILENAME']

 If it doesn't work for you, does it work if you do one of those 
 substitutions?

 Also, this will test if the script is in subdirectories or not, also, so
 testing it within one and seeing if that works, too, is appreciated.

 Thanks for any help and time you're willing to provide.

 -- 
 ---John Holmes...



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



[PHP] thumbnail problems

2004-05-09 Thread Ninti Systems
I've searched the archives on this and, while I have turned up some
tips, they don't seem to solve my problem.

I an building a website for an indigenous organisation where jpg images
are uploaded, resized to a standard format, and thumbnails also
generated at the same time (so that is two resizes for each image). Most
of the time this works OK, but there are a lot of pages where many
thumbnails are just blacked out, eg:

http://waru.org/arakuwaritja.php?p=63

On some pages, all images are blacked out, eg:

http://waru.org/arakuwaritja.php?p=36

whereas on others they're all OK, eg:

http://waru.org/arakuwaritja.php?p=43

The people in the field taking and uploading the photos insist that the
format, color depth, etc, is not changing from photo to photo, and I
can't discern any differences. Yet some work, some don't.

I read somewhere that memory limitations could cause this, but still, it
only happens sometimes and not others. We are on a crowded shared server
I think.

I'm use ImageCreateTrueColor() after checking with ImageIsTrueColor(),
otherwise just ImageCreate(). The initial resizes almost always work
(down from 640x480 to 400x300), with the thumbnails it is looking like a
50% failure rate.

Thanks in advance for any assistance.

Michael Hall

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



Re: [PHP] Curl cookies

2004-05-09 Thread Curt Zirzow
* Thus wrote Jason Morehouse ([EMAIL PROTECTED]):
 Has anyone tried using curl to fetch a web page and cookies?
 
 ?
 $ch = curl_init();
 curl_setopt ($ch, CURLOPT_URL, 'http://www.php.net');
 curl_setopt ($ch, CURLOPT_HEADER, 0);
 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt ($ch, CURLOPT_COOKIEJAR,'cookie.txt');
 curl_setopt ($ch, CURLOPT_COOKIE,1);
 $content = curl_exec ($ch);
 curl_close ($ch);
 $cookie = file_get_contents('cookie.txt');
 print $cookie;
 ?

 
 This works fine, and the cookie gets stored in the cookie.txt file, but it
 only ever returns 1 cookie.  There should be 2 for php.net.  Same with
 pretty much any other site.  Are there any configuration items I'm missing
 for the cookie jar?

php's front page will only set one cookie, only in certain
conditions will it set other cookies. I have 4 total from php.net:
  LAST_SEARCH, MYPHPNET, LAST_LANG, COUNTRY

php only set's one cookie on the front page.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] Does this directory detection script work for you?

2004-05-09 Thread Curt Zirzow
* Thus wrote John W. Holmes ([EMAIL PROTECTED]):
 
 I've had a couple people report that the script wasn't finding the paths 
 correctly, though, so I'm asking if people could test this out on their 
 server and see if it detects the paths or not.

works fine with freebsd/apache-1.3.x/php5rc1

 
 ?php
 //Install path (path to survey.class.php)
 $path = dirname($_SERVER['PATH_TRANSLATED']);

This might be a problem, IIRC, some web servers will not set
PATH_TRANSLATED if no PATH_INFO is being passed.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] thumbnail problems

2004-05-09 Thread Curt Zirzow
* Thus wrote Ninti Systems ([EMAIL PROTECTED]):
 
 I read somewhere that memory limitations could cause this, but still, it
 only happens sometimes and not others. We are on a crowded shared server
 I think.

A quick sample of sizes of images does back this thoery up.  Most
pictures I sampled, the full picture's that resized properly were
~16KB, the black icon images original size were ~24KB - ~35KB

I would think that the GD library will complain at some point if
there are memory problems, make sure your settings (on the page
that generates the thumbnails) has error_reporting(E_ALL), and
monitor any errors that occure there.

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



[PHP] List() help

2004-05-09 Thread PHPDiscuss - PHP Newsgroups and mailing lists
I'm using list like
list($a,$b,$c,$d) = $MyArray
MyArray holds more than three items, 0-4 more,
my problem is that $d only gets one and I lose the others if more tha one
extra. I know I can just add more $e,f,g,h,i but how do I get the extras
into an array?

TIA
RGauthier

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



[PHP] $_SESSION - Learning

2004-05-09 Thread Ross Bateman
Hi

I am finally starting to try and use register_globals = off on my Servers.
This means a lot of code that has to be checked and changed.

Unfortunatly I am struggeling to come to grips with this new concept (new to
me that is) and was wondering if anybody could give me some pointers.

Getting stumped at my login script.
Once I have checked user and passwords, I pass a few SESSION vars to use
throughout my app.

snip
if ($status == 1)
   {
   //initiate a session
   session_start();
   //register session variables
   $_SESSION['SESSION'];
   //Get DataBase details and connect to it
   include($root_path . include/vars.php);
   $query = SELECT * FROM admin WHERE user_name = '$user';
   $result = mysql_query($query);
   $row = mysql_fetch_object($result);
   //include the username
   $_SESSION['SESSION_UNAME'] = $row-user;
   //include the user id
   $_SESSION['SESSION_UID'] = $row-admin_id;
   //set the SecLevel Session Var
   $_SESSION['SESSION_SEC'] = $row-sec_level;
   //Now do the redirect
   //redirect to Admin Page
   header(Location: ./admin_main.php);
   exit();

   }
else
/snip

Where ever I have the $SESSION['var_name'] I used to have a
session_register(SESSION_VAR);
$SESSION_VAR = $row-user;

I then redirect to my app main page and check if a session is registerd to
make sure a user is logged in:

//check that each page is secure
session_start();
//OLD CODE IN SCRIPT = if (!session_is_registered(SESSION))
if(isset($_SESSION['SESSION']))
   {
   //if session check fails, invoke error handler
   header(Location: ./../error.php?e=2);
   exit();
   }
?

That all works fine, but when I finaly start to display data on the main
page, nothing shows up.

One of the things I try to display is the name of the user logged in:
From the login script
//include the username
$_SESSION['SESSION_UNAME'] = $row-user;

then on my main page
echo logged in as b . $_SESSION['SESSION_UNAME'] . /b ;

Needless to say, no data is displayed. anybody able to point out what I
am getting wrong here. It used to work fine before the old way with
register_globals = on.

SIDE Note:
On a Windows PC with Apache, PHP and MySQL installed, even with the
register_globals = on set, the SESSION vars do not work.

Thanks and sorry for the long post,

Ross

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



php-general Digest 10 May 2004 05:31:41 -0000 Issue 2754

2004-05-09 Thread php-general-digest-help

php-general Digest 10 May 2004 05:31:41 - Issue 2754

Topics (messages 185748 through 185774):

Re: Putting a stop in a foreach
185748 by: Curt Zirzow
185752 by: Curt Zirzow
185755 by: Torsten Roehr

Re: protecting web page
185749 by: Curt Zirzow

Re: Strange mails...
185750 by: Daniel Clark

feof Question
185751 by: Harish
185753 by: Petr U.
185754 by: Curt Zirzow

Re: Putting a stop in a foreach - SOLVED
185756 by: Verdon Vaillancourt

Re: Graphical calendar
185757 by: Manuel Lemos

hash with RIPEMD-160
185758 by: Dennis Gearon

Clean Open Source PHP extranet app?
185759 by: david david
185761 by: John W. Holmes
185763 by: Justin French

Curl  cookies
185760 by: Jason Morehouse
185770 by: Curt Zirzow

Does this directory detection script work for you?
185762 by: John W. Holmes
185768 by: Richard Harb
185771 by: Curt Zirzow

PHP /\ UML
185764 by: Matthias H. Risse

exclude_once(); ?
185765 by: Matthias H. Risse
185767 by: Justin French

Re: using cookies
185766 by: David T-G

thumbnail problems
185769 by: Ninti Systems
185772 by: Curt Zirzow

List() help
185773 by: PHPDiscuss - PHP Newsgroups and mailing lists

$_SESSION - Learning
185774 by: Ross Bateman

Administrivia:

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

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

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
* Thus wrote Verdon Vaillancourt ([EMAIL PROTECTED]):
 Hi :)
 
 This is the original statement that works...
 
 foreach ($this-_content as $item) {
 if ($item['type'] == 'item'){
 ..

ok. good so far.

 
 
 This is my attempt to count items and put a stop in the foreach so it only
 returns 5 items.
 
 foreach ($this-_content as $n = $item) {
 if ($n==5) { 
 break;
 } else { 
 if ($this-_content[$n] = $item['type'] == 'item'){

I'm  not sure why  you  changed all this.

All you have to do is a simple foreach loop with a counter, and
break when the counter reaches your condition:

$need = 5; /* how many we want */

foreach($this-_content as $index = $item) {

  if ($item['type'] == 'item') {
//...

/* only decrement if its an 'item' */
$need--;
  }
  if (! $need) break; /* we got everything we needed */
}


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.
---End Message---
---BeginMessage---
* Thus wrote Torsten Roehr ([EMAIL PROTECTED]):
 
 Sorry, I mixed up the for and the foreach syntaxes. Here my (hopefully
 correct) loop proposal:
 
 for ($i; $i  5; $i++) {

for($i=0; ...)

I wouldn't suggest this method, it is making the assumption that
the indexes are numeric and sequenced from 0..5


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.
---End Message---
---BeginMessage---
Curt Zirzow [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 * Thus wrote Torsten Roehr ([EMAIL PROTECTED]):
 
  Sorry, I mixed up the for and the foreach syntaxes. Here my (hopefully
  correct) loop proposal:
 
  for ($i; $i  5; $i++) {

 for($i=0; ...)

 I wouldn't suggest this method, it is making the assumption that
 the indexes are numeric and sequenced from 0..5

Correct, I forgot =0. But as far as I have seen his indices are numeric.

Regards, Torsten



 Curt
 --
 I used to think I was indecisive, but now I'm not so sure.
---End Message---
---BeginMessage---
* Thus wrote [EMAIL PROTECTED] ([EMAIL PROTECTED]):
 Hi,
 
 i'm designing a web application and i want to protect my web page from
 printing and if possible want to protect source code too.

You can prevent the average joe from printing by putting some css
in your document:

@media print { body { display:  none; } }



Curt
-- 
I used to think I was indecisive, but now I'm not so sure.
---End Message---
---BeginMessage---
Yep.  I'm getting it too.

Each time I post a message on p.general, i receive two strange mails 
from ADVANCE CREDIT SUISSE BANK.

What's this spam ? It looks like an auto-responder is subscribed on the 
newsgroup. Spammers really s*x !

Greg
---End Message---
---BeginMessage---

Hi

I am using Linux, Apache, MySql, PHP. In the below mentioned code example when the 
counter data that is displayed on the screen going to a indefinite loop. The file that 
is read has got sufficient permissions.

What are the reasons and how do I tackle the problem?

?php
$fp = fopen( 't.txt', 'r' );

while( !feof( $fp ) )
{
   print fgets( $fp );
   echo $counterval++;
   if($counterval%100==0)
   {
  flush();
   }
}
fclose( $fp );
?



Regards,
Harish Rao K
---End Message---
---BeginMessage---
On Sun, 9 May 2004 22:00:53 +0530
Harish [EMAIL PROTECTED] wrote:

  ?php
  $fp = fopen( 

Re: [PHP] List() help

2004-05-09 Thread Adam Bregenzer
On Sun, 2004-05-09 at 21:13, PHPDiscuss - PHP Newsgroups and mailing
lists wrote:
 I'm using list like
 list($a,$b,$c,$d) = $MyArray
 MyArray holds more than three items, 0-4 more,
 my problem is that $d only gets one and I lose the others if more tha one
 extra. I know I can just add more $e,f,g,h,i but how do I get the extras
 into an array?

Try using array_shift[1] for the first few items instead of list:
$a = array_shift($MyArray);
$b = array_shift($MyArray);
$c = array_shift($MyArray);

$MyArray will have the leftovers, you can just assign it if you need a
copy:
$d = $MyArray;

If you only want $d to be an array when there is more than one entry
left do this instead:
if (count($MyArray) == 1) {
 $d = array_shift($MyArray);
} else {
 $d = $MyArray;
}

[1] http://www.php.net/array_shift

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



[PHP] Re: Does this directory detection script work for you?

2004-05-09 Thread Aidan Lister
Hi,

I use the following class to get Path information:

http://ircphp.com/users/imho/?file=Path.php

Let me know if this is helpful at all


John W. Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hello. I'm relying on the following code so that a script can
 automatically detect where it's installed and create paths and URLs from
 the information. This way absolute paths and URLs are always used.

 I've had a couple people report that the script wasn't finding the paths
 correctly, though, so I'm asking if people could test this out on their
 server and see if it detects the paths or not.

 ?php
  //Install path (path to survey.class.php)
  $path = dirname($_SERVER['PATH_TRANSLATED']);

  //Determine protocol of web pages
  if(isset($_SERVER['HTTPS']) 
 strcasecmp($_SERVER['HTTPS'],'ON') == 0)
  { $protocol = 'https://'; }
  else
  { $protocol = 'http://'; }

  //HTML address of this program
  $dir_name = dirname($_SERVER['SCRIPT_NAME']);
  if($dir_name == '\\')
  { $dir_name = ''; }

  $html = $protocol . $_SERVER['SERVER_NAME'] . $dir_name;

  //Determine web address of current page
  $current_page = $protocol . $_SERVER['SERVER_NAME'] .
 $_SERVER['SCRIPT_NAME'];

  echo Path to script: $pathbr /;
  echo URL to script directory: $htmlbr /;
  echo URL to current script: $current_page;
 ?

 It should print out the file system path to where the script was placed
 as well as a URL to the directory it was placed and a URL to the file
 itself.

 I've never had an issue with it personally and I've tested it on Apache
 and IIS on both Windows and Linux. So maybe it's some obscure CGI or OS
 configuration where this isn't working? I just need to know so I can
 plan accordingly.

 The only two substitutions that can be made (that I know of) are:

 $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF']
 and
 $_SERVER['PATH_TRANSLATED'] = $_SERVER['SCRIPT_FILENAME']

 If it doesn't work for you, does it work if you do one of those
 substitutions?

 Also, this will test if the script is in subdirectories or not, also, so
 testing it within one and seeing if that works, too, is appreciated.

 Thanks for any help and time you're willing to provide.

 -- 
 ---John Holmes...

 Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

 php|architect: The Magazine for PHP Professionals – www.phparch.com

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



[PHP] $myobject-$$varname doens't work ??

2004-05-09 Thread greg
Hello,

I was just trying this but it doesn't work :
?php
class a {
  public $foo = hello world;
}
$obj = new a();
$varname = foo;
echo $obj-$$varname;
$bar = this is working;
$varname = bar;
echo $$varname; // display this is working as expected
?
Is it a bug or is it normal ?
I didn't find anything about it in documentation (php4 / php5).
Greg

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


Re: [PHP] using cookies

2004-05-09 Thread Richard Harb
-Original Message-
From: David T-G
Sent: Sunday, May 9, 2004, 6:09:06 AM
 Hi, all --

 I guess I need a primer on cookie usage.  I've read the manual regarding
 setcookie and have gone back to look at everything having to do with
 cookies on this list in the past few months (it seems that I'm not the
 only one with some troubles, but most of them appear to have been having
 sent some HTML output before trying to set a cookie).

 I want to check to see if the user has my cookie to then log him in
 automatically, and if he doesn't then I show the login screen and he logs
 in and then I set the cookie if the box is checked.

 Of course, $_COOKIE is set, so I have to check for my cookie name.  Even
 something as simple as

   $_COOKIE['test'] = 'tested';

Under normal circumstances you don't need to do that (unless you know
what you are doing - but it will not set a cookie on the client side,
it only modifies your superglobal variable for as long as the script
runs. I guess I'm once again stating the obvious).


 followed by a load of the page and a print doesn't show it.

 Do I only call setcookie if the cookie isn't set, or do i call it every
 time I load the page to initialize it?  Once I set it, how do I read it?

Once you setcookie() you can optionally give it something on its way:
like name, value, expire time/date, etc.

You could for example set a cookie to expire in half an hour - i.e.
for a session. It might make sense to refresh that cookie on every
page request, so that a session timeout will be postponed on each
refresh.

If you omit the expire time, it will be valid until the end of the
session (browser closes) - see the docs.


How do you get your cookie back?

If your visitor has a browser that allows cookies and you already sent
him one (or more) before, he will automatically transmit it to you as
part of the HTTP request headers. PHP does its magic and places the
values received into that Superglobal $_COOKIE (as well as $_REQUEST)
for you to play with...

So, if that array is empty that could mean two things:
1) you didn't send any cookie before (either because you already sent
your headers and thus have a f***up in your code or because the
visitor hasn't been to your page before)
2) the visitor does not allow cookies - too bad.


I guess that's all there is to it. Someone correct me or add to that
:)


 Does anyone have any pointers to a basic tutorial?

I didn't use any other page except the obvious one ...
http://www.php.net/manual/en/function.setcookie.php

I hope that answers at least part of what you were looking for ...

Richard

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



Re: [PHP] $myobject-$$varname doens't work ??

2004-05-09 Thread Richard Harb
Try
echo $obj-$varname;


-Original Message-
From: greg
Sent: Sunday, May 9, 2004, 9:21:52 AM
 Hello,

 I was just trying this but it doesn't work :
 ?php

 class a {
public $foo = hello world;
 }

 $obj = new a();
 $varname = foo;
echo $obj-$$varname;

 $bar = this is working;
 $varname = bar;
 echo $$varname; // display this is working as expected
?

 Is it a bug or is it normal ?
 I didn't find anything about it in documentation (php4 / php5).

 Greg

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