[PHP] How to automate php with crontab?

2005-10-03 Thread Rasim �EN
hi,

Anybody know how to automate php with crontab. I want to generate in every 5
minute one php file.

thanks alot

rasim

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



Re: [PHP] convert array to HTML GET request

2005-10-03 Thread hope

on 2nd page you can use

global $HTTP_POST_VARS; 
print_r($HTTP_POST_VARS);


/// u can use $HTTP_GET_VARS for GET method

regards
hope 


adriano ghezzi wrote:


if i understand well you need to get an array from html post




if you use the same name for your html fields you automatically have
an array in $_POST



eg



input type=text  name=myfield value="field_1"
input type=text name=myfield value="field_2"



you'll get the array  ar_myfield = $_POS['myfield']



you should achieve the same result using myfield[key] in the name of html



hyh



by ag.




2005/10/2, Martin van den Berg <[EMAIL PROTECTED]>:

Newbe question:

How does one convert an array into a HTML GET request easely? Are
there any standard functions?

Same for HTML POST requests.

Thanks,

Martin.

--
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 automate php with crontab?

2005-10-03 Thread Petar Nedyalkov
On Monday 03 October 2005 11:20, Rasim XEN wrote:
> hi,
>
> Anybody know how to automate php with crontab. I want to generate in every
> 5 minute one php file.

crontab -e :-)

Check:
http://www.phpfreaks.com/tutorials/28/0.php
and
http://www.tech-geeks.org/contrib/mdrone/cron&crontab-howto.htm

>
> thanks alot
>
> rasim

-- 

Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)

PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436


pgpaxq4409eJm.pgp
Description: PGP signature


[PHP] Re: PHP and Active Directory

2005-10-03 Thread Mark Rees
How do I connect a php script running on linux with Active Directory on
a windows machine? I would like to have my php script autmotatically
read email addresses from the AD server. Can this be done? I've found a
bunch of ldap functions for php but they seem to require ldap to be
installed on linux. I'm confused. Thanks in advance for your help.

---

Have you seen this?
http://uk2.php.net/ldap

I've managed to do it from Windows, after a lot of trial and error, but in
the end it wasn't that complicated.  Have you got any specific questions,
based on following the steps in the manual?

Mark

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



RE: [PHP] creating a shopping cart.

2005-10-03 Thread Jay Blanchard
[snip]
What's the best approach to create a shopping cart.? 
[/snip]

I see that you have received some answers already but I wanted to point out
something very obviouslearn how to plan a software application. I know
that I am old school, but I see far too many developers today winging it. A
lot of the reason is that many languages now lend themselves to being
self-taught, and while learning the language is great it is not the only
thing a programmer needs to know about developing software.

A basic flowchart could have helped you to answer your question and broken
down the processes into their componenet parts. Heck, you don't even need
fancy flowcharting software...just write down the steps.

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



Re: [PHP] Array - partical path to the array's path (part 2)

2005-10-03 Thread Scott Fletcher
Got it figured out by now.  I noticed one small bug but I'll fix it monday
morning, so i'm going to post what I did to make this work..

I'm going to donate this code to the guy at
http://www.devdump.com/phpxml.php and hopefully he'll put some of this to a
good use as more and more people are now using xml to exchange data, so this
would be very helpful to people who may need this...

[code]
$array = array
(
  'NEWSFEED' => array
  (
'0' => array
(
  'ATTRIBUTES' => array
  (
'ID' => 'test1'
  ),
  'MESSAGE' => array
  (
'0' => array
(
  'ATTRIBUTES' => array
  (
'ID' => 'test2',
'TID' => 'test4'
  ),
  'TITLE' => array
  (
'0' => array
(
   'VALUE' => 'Title #1'
),
'1' => array
(
   'VALUE' => 'Title #2'
)
  ),
  'QUOTE' => array
  (
'0' => array ( 'VALUE' => 'Quote #1' )
  ),
  'BODY' => array
  (
'0' => array ( 'VALUE' => 'Body #1' )
  ),
  'REFERENCE' => array
  (
'0' => array ( 'VALUE' => 'Reference #1' )
  )
),
'1' => array
(
  'TITLE' => array
  (
'0' => array ( 'VALUE' => 'Title #2' )
  ),
  'BODY' => array
  (
'0' => array ( 'VALUE' => 'Body #2' )
  ),
  'REFERENCE' => array
  (
'0' => array ( 'VALUE' => '' )
  )
),
'2' => array
(
  'ATTRIBUTES' => array
  (
'ID' => 'test3'
  ),
  'TITLE' => array
  (
'0' => array ( 'VALUE' => 'Title #3' )
  ),
  'BODY' => array
  (
'0' => array ( 'VALUE' => 'Body #3' )
  ),
  'IMAGE' => array
  (
'0' => array ( 'VALUE' => 'Image #3' )
  ),
  'REFERENCE' => array
  (
'0' => array ( 'VALUE' => 'Reference #3' )
  )
)
  )
)
  ),
  'BLOG' => array
  (
'0' => array
(
  'MESSAGE' => array
  (
 '0' => array ( 'VALUE' => 'Title #1' )
  )
)
  )
);

  function XmlTreeImplode($tree, $branch_level, &$array_key, &$xml_string)
  {
 $branch_level++;

 $tab_spacer = " ";  //Options to use white spaces or html spaces,
etc...

 foreach($tree as $key => $value)
 {
if (strtoupper($key) != "ATTRIBUTES") {
   $array_key[count($array_key)] = $key;
}

if ($branch_level % 2 != 0) {  //xml tag's name...
   if (strtoupper($key) != "ATTRIBUTES") {
  if(!(is_array($value))) { //Check for VALUE or CDATA name
tag...
 $xml_string .= str_repeat($tab_spacer,
($branch_level-1))."<".$key.">".$value.""."\r";
  } else {  //Continue...
 //=
 //Grab the attribute data if any...
 //=
 if (is_array($value['0']['ATTRIBUTES'])) {
foreach($value['0']['ATTRIBUTES'] as $key1 => $value1) {
   $attribute .= " ".$key1."=\"".$value1."\"";
}
 }
 //=

 //Otherwise
 $xml_string .= str_repeat($tab_spacer,
($branch_level-1))."<".$key.$attribute.">"."\r";
 XmlTreeImplode($value, $branch_level, $array_key,
$xml_string);
 $xml_string .= str_repeat($tab_spacer,
($branch_level-1)).""."\r";
  }
   }
} else {  //xml name-tag counter...
   if ($key != 0) {
  //=
  //Grab the attribute data if any...
  //=
  if (is_array($value['ATTRIBUTES'])) {
 foreach($value['ATTRIBUTES'] as $key1 => $value1) {
$attribute .= " ".$key1."=\"".$value1."\"";
 }
  }
  //=

  $xml_string .= str_repeat($tab_spacer,
($branch_level-1)).""."\r";
  $xml_string .= str_repeat($tab_spacer,
($branch_level-1))."<".$array_key[$branch_level-2].$attribute.">"."\r";
   }

   XmlTreeImplode($value, $branch_level, $array_key, $xml_string);
}
 }
  }

  $xml_string = GetXmlStr($array);
[/code]

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



[PHP] Upper case problem

2005-10-03 Thread Merlin

Hi there,

I am having problems with users who upload text that only contains upper case 
letters. For example "SEARCHING FOR".  Is there a way to detect this via PHP?`
I would like to have the script return him to the form and inform him that this 
is not allowed.

So basicly I need a sort of regex which does detect upper case letters in a row.
Has anybody ann idea how such an regex could look like?

Thank you for any hint,

Merlin

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



RE: [PHP] Upper case problem

2005-10-03 Thread Jay Blanchard
[snip]
I am having problems with users who upload text that only contains upper
case 
letters. For example "SEARCHING FOR".  Is there a way to detect this via
PHP?`
I would like to have the script return him to the form and inform him that
this 
is not allowed.
So basicly I need a sort of regex which does detect upper case letters in a
row.
Has anybody ann idea how such an regex could look like?
[/snip]

/A-Z/

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



[PHP] session save path

2005-10-03 Thread jonathan
I'm looking for where apache / php will be saving the user session  
files. when I do a phpinfo(), it tells me that session.save_path will  
be temp but when I look at the files in there, there are only a  
couple of files and they say nwIN;


Is there any way to directly access the session files in this way to  
get at the values?


-jon 


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



Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread Robert Cummings
On Sun, 2005-10-02 at 01:01, Robert Cummings wrote:
>
> If you go with an array system might I suggest the following change to
> what I wrote:

I'm resending a better way to do the simple trolley since you seemed to
have created a Frankensteinian merge of the two examples I sent
previously. This version uses functions which should probably be put
into their own source file and included (let's call it lib.trolley.php).

\n"
.implode( ',', array_keys( $_SESSION['TrolleyContents'] ) )
."\n\n";
}

?>

Now the following would facilitate the action you appear to be
performing in your example for adding to the trolley:

';

if( 'add' == $_POST['ShopAction'] )
{
echo 'Adding '.$_POST['RNum'].'...';

trolleyItemAdd( $_POST['RNum'], 1 );
}
else
if( 'delete' == $_POST['ShopAction'] )
{
echo 'Deleting '.$_POST['RNum'].'...';

trolleyItemRemove( $_POST['RNum'], 1 );
}
}
else
{
echo 'No action specified!!';
}

trolleyPrint();

?>

-- 
..
| 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] Upper case problem

2005-10-03 Thread Georgi Ivanov

On Monday 03 October 2005 16:28, Merlin wrote:
> Hi there,
>
> I am having problems with users who upload text that only contains upper
> case letters. For example "SEARCHING FOR".  Is there a way to detect this
> via PHP?` I would like to have the script return him to the form and inform
> him that this is not allowed.
> So basicly I need a sort of regex which does detect upper case letters in a
> row. Has anybody ann idea how such an regex could look like?
>
> Thank you for any hint,
>
> Merlin

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



Re: [PHP] decrypting query string back into $_GET['var'] [resend]

2005-10-03 Thread Graham Anderson

Is this the safest way to send GET variables ?
Guess I am trying to improve my code :)


//--
//  'Sending'  PHP script:

require_once("/home/includes/encryption.inc");

$str 
=encrypt(urlencode("movie=mymovie.mov&mask=mask.gif&drag=drag.gif"));

$finalURLString = $pathtoReceivingScript.$str ;


//--
//  'Receiving' PHP script:

require_once("/home/includes/encryption.inc");

$str =$_SERVER['QUERY_STRING'];
parse_str(urldecode(decrypt($str)),$getVarArray);
$movie = $getVarArray['movie'];
$mask = $getVarArray['mask'];
$drag = $getVarArray['drag'];
//echo "$movie,$mask,$drag";


//--
//  Encryption.inc

// Encrypt
function encrypt($encrypt) {
$key = "6r9qEJg6";
   srand((double) microtime() * 100); //for sake of MCRYPT_RAND
   $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, 
MCRYPT_MODE_ECB), MCRYPT_RAND);
   $passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $encrypt, 
MCRYPT_MODE_ECB, $iv);

   $encode = base64_encode($passcrypt);
 return $encode;
 }

// Decrypt
 function decrypt($decrypt) {
   global $key;
   $key = "6r9qEJg6";
   $decoded = base64_decode($decrypt);
   $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, 
MCRYPT_MODE_ECB), MCRYPT_RAND);
   $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $decoded, 
MCRYPT_MODE_ECB, $iv);

 return $decrypted;
}

On Sep 29, 2005, at 9:33 AM, Jochem Maas wrote:


Graham Anderson wrote:

What is the best way to decrypt a query string  back into  variables ?
$root = "http://www.myserver.com/script.php";;
$queryString = "?test=mytest&color=red";
myEncrypt($queryString);  //add mCrypt encryption
$finalURL = $root.$encryptedQueryString;
what is the proper what to decrypt the GET variables on the other 
side ?



Do you need to decrypt the query string first ?


yes - if you have a query string like

4509134534068953534875104584437043134081743

or whatever then php won't turn it into a $_GET var.
although your query string could contain &'s and/or ?'s and/or ='s
in which case you might have cruft in the $_GET array which you would
want to clean out before extracting your decrypted string into
$_GET ..


decrypt($_SERVER['QUERY_STRING']);
Once you have decrypted it, can you pass it along to a $_GET as you 
would with an unencrypted query string ?

$test = $_GET['test'];
Or, do you need to parse the string to extract variables?


yes you do, but this being php - there is a function that will do it 
for you :-)


http://php.net/parse_str


many thanks
g


--
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] passing a variable with php_self

2005-10-03 Thread Jeffrey Sambells


can someone show me the right way to do the following...




I want to pass a variable to a  self submitting link.

Thanks,








$PHP_SELF should not be used because it will not work without  
register_globals being enabled. Rather, you should use $_SERVER 
['PHP_SELF'] for it as above however...


Don't forget to check for XSS! Using PHP_SELF you could simply change  
the URL in the browser to:


/path/to/script.php">alert('hello');


-Jeff

~~
Jeffrey Sambells
Director of Research and Development
Zend Certified Engineer (ZCE)

We-Create Inc.
[EMAIL PROTECTED] email
519.745.7374 office
519.897.2552 mobile

~~
Get Mozilla Firefox at
http://spreadfirefox.com

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



Re: [PHP] passing a variable with php_self

2005-10-03 Thread Jeffrey Sambells

oops, that should be htmlentities, not htmlspecialchars.

- Jeff

On 3-Oct-05, at 11:51 AM, Jeffrey Sambells wrote:


$PHP_SELF should not be used because it will not work without  
register_globals being enabled. Rather, you should use $_SERVER 
['PHP_SELF'] for it as above however...


Don't forget to check for XSS! Using PHP_SELF you could simply  
change the URL in the browser to:


/path/to/script.php">alert('hello');




~~
Jeffrey Sambells
Director of Research and Development
Zend Certified Engineer (ZCE)

We-Create Inc. ~ Internet Solutions
http://wecreate.com
[EMAIL PROTECTED]
office: 519.745.7374
cell: 519.897.2552
~~
Get Mozilla Firefox at http://spreadfirefox.com/community/? 
q=affiliates&id=466&t=50

Re: [PHP] Upper case problem

2005-10-03 Thread John Nichel

Jay Blanchard wrote:

[snip]
I am having problems with users who upload text that only contains upper
case 
letters. For example "SEARCHING FOR".  Is there a way to detect this via

PHP?`
I would like to have the script return him to the form and inform him that
this 
is not allowed.

So basicly I need a sort of regex which does detect upper case letters in a
row.
Has anybody ann idea how such an regex could look like?
[/snip]

/A-Z/



/[A-Z]/

Freaking Windows users. ;)

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] Image resizing...

2005-10-03 Thread Matt Darby

Sonia wrote:


Hi All

I've been working on finishing a project SGML2IMAGE and I am sort of having
trouble with resizing of images. I am trying to just use the GD library so
when I distro the package it will not need any other things installed to be
used. Now I am using...

imagecreatetruecolor ();
imagecreatefrom___ ();
imagecopyresampled ();
image___ ();

But the thumbnails look blurry for any image less than 50% of the original
image created by the PHP SGML parser. So my question seeing I am not very
good with the GD library. Am I using the best functions to do the resize or
should I be using some other image function(s) that may give better results!
To give you a idea of what I am doing see the demo running on my note
book

http://24.218.192.217/capture.php

Thanks

sonia

 


Here is the method I use:

   $destimg=imagecreatetruecolor($aspect_w, $aspect_h);
   $srcimg=imagecreatefromjpeg($path.$files[$i]);
   imageantialias($destimg,true);
   
imagecopyresized($destimg,$srcimg,0,0,0,0,$aspect_w,$aspect_h,ImageSX($srcimg),ImageSY($srcimg));

   imagejpeg($destimg,$dest_dir.$image_name);

imageantialias() might do some good in your case.

HTH!
Matt Darby

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



Re: [PHP] PHP & SOAP for production

2005-10-03 Thread Ben
Reuben D. Budiardja said the following on 10/01/05 14:41:
> Hello,
> On Saturday 01 October 2005 17:13, jonathan wrote:
> 
>>you could try the native SOAP extension in php5.

> 
> I've looked at the php.net and saw "(no version information, might be only in 
> CVS)" in the docs. So is this already in the released version of PHP 5 or 
> not ? 

Yes, already in the release version:
http://ca3.php.net/manual/en/ref.soap.php

For php4 try nusoap:
http://sourceforge.net/projects/nusoap/

- Ben

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



Re: [PHP] Image resizing...

2005-10-03 Thread Matt Darby

Sonia wrote:


Hi All

I've been working on finishing a project SGML2IMAGE and I am sort of having
trouble with resizing of images. I am trying to just use the GD library so
when I distro the package it will not need any other things installed to be
used. Now I am using...

imagecreatetruecolor ();
imagecreatefrom___ ();
imagecopyresampled ();
image___ ();

But the thumbnails look blurry for any image less than 50% of the original
image created by the PHP SGML parser. So my question seeing I am not very
good with the GD library. Am I using the best functions to do the resize or
should I be using some other image function(s) that may give better results!
To give you a idea of what I am doing see the demo running on my note
book

http://24.218.192.217/capture.php

Thanks

sonia

 

Actually, imagecopyresized() would be what you're looking for; 
imageantialias() can't hurt either ;)


Matt Darby

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



Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread John Taylor-Johnston
Excellent. Thanks. I think I follow what you have done. But to clarify, 
and learn, what are you doing with -= ?

$trolley[$item] -= $quantity;
Likewise, i had not followed what you were doing with the lines I 
commented out. They did not seem to work, and I succeeded in doing what 
I wanted without them. I'm a prof, as you can tell, and always have a 
question for an answer ;).

Thanks for your time and patience,
John

  //Delete an entry:
  if( isset( $_SESSION['TrolleyContents'][$_POST['RNum']] ) )
  {
  #$_SESSION['TrolleyContents'][$_POST['RNum']] -= 1;
  #if( $_SESSION['TrolleyContents'][$_POST['RNum']] <= 0 )
  #{
  unset( $_SESSION['TrolleyContents'][$_POST['RNum']] );
  #}
  }

Robert Cummings wrote:


On Sun, 2005-10-02 at 01:01, Robert Cummings wrote:


If you go with an array system might I suggest the following change to
what I wrote:



I'm resending a better way to do the simple trolley since you seemed to
have created a Frankensteinian merge of the two examples I sent
previously.
if( isset( $trolley[$item] ) )
{
$trolley[$item] -= $quantity;

if( $trolley[$item] < 1 )
{
unset( $trolley[$item] );
}
}





Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread Robert Cummings
On Mon, 2005-10-03 at 14:11, John Taylor-Johnston wrote:
> Excellent. Thanks. I think I follow what you have done. But to
> clarify, and learn, what are you doing with -= ?
> $trolley[$item] -= $quantity;
> Likewise, i had not followed what you were doing with the lines I
> commented out. They did not seem to work, and I succeeded in doing
> what I wanted without them. I'm a prof, as you can tell, and always
> have a question for an answer ;).
> Thanks for your time and patience,
> John

> > if( isset( $trolley[$item] ) )

"isset" checks that the item with ID $item is in the trolley. No need to
decrease the quantity if it's not there.

> > {
> > $trolley[$item] -= $quantity;

The expression:

$trolley[$item] -= $quantity;

is a short form for the following:

$trolley[$item] = $trolley[$item] - $quantity;

Essentially we decrease the quantity of the given item by $quantity.

> > if( $trolley[$item] < 1 )
> > {

Above we check if we subtracted more items than is physically possible
:)

> > unset( $trolley[$item] );

If there are 0 or less items then there's no point having 0 of the item
in the trolley, so we unset the item from the array, which essentially
removes it completely. To view the difference at each step you can do
the following:

";
trolleyPrint();

$trolley[$item] -= $quantity;

echo "Trolley after removing $quantity of $item";
trolleyPrint();

if( $trolley[$item] < 1 )
{
unset( $trolley[$item] );

echo "Trolley after cleaning up empty entry for $item";
trolleyPrint();
}
}

?>

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] session_name("CCLTrolley")

2005-10-03 Thread John Taylor-Johnston
Is that over kill? No matter how I slam it, still referring to my 
Frankensteinian merge, "unset" does the job.

http://testesp.flsh.usherbrooke.ca/db/trolley.php
But then again, I will not require a quanity of items. The visitor will 
only want one copy of a bibliographic entry :-\ - I hope?!
You were checking to see if there was a greater than 1 quantity of 
post[RNum], right?

Thanks,
John

   //Delete an entry:
   if( isset( $_SESSION['TrolleyContents'][$_POST['RNum']] ) )
   {
   #$_SESSION['TrolleyContents'][$_POST['RNum']] -= 1;
   #if( $_SESSION['TrolleyContents'][$_POST['RNum']] <= 0 )
   #{
   unset( $_SESSION['TrolleyContents'][$_POST['RNum']] );
   #}
   }

Robert Cummings wrote:


Thanks for your time and patience,
John
   


The expression:
   $trolley[$item] -= $quantity;
is a short form for the following:
   $trolley[$item] = $trolley[$item] - $quantity;
Essentially we decrease the quantity of the given item by $quantity.
if( $trolley[$item] < 1 )
{
#Above we check if we subtracted more items than is physically possible
unset( $trolley[$item] );
#If there are 0 or less items then there's no point having 0 of the item
#in the trolley, so we unset the item from the array, which essentially
#removes it completely. To view the difference at each step you can do
#the following:

";
   trolleyPrint();

   $trolley[$item] -= $quantity;

   echo "Trolley after removing $quantity of $item";
   trolleyPrint();

   if( $trolley[$item] < 1 )
   {
   unset( $trolley[$item] );

   echo "Trolley after cleaning up empty entry for $item";
   trolleyPrint();
   }
}

?>

Cheers,
Rob.
 



--
John Taylor-Johnston
-
"If it's not Open Source, it's Murphy's Law."

 ' ' 'Collège de Sherbrooke:
ô¿ôhttp://www.collegesherbrooke.qc.ca/languesmodernes/
   - 819-569-2064

 °v°   Bibliography of Comparative Studies in Canadian, Québec and Foreign 
Literatures
/(_)\  Université de Sherbrooke
 ^ ^   http://compcanlit.ca/ T: 819.569.2064



Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread Robert Cummings
On Mon, 2005-10-03 at 14:51, John Taylor-Johnston wrote:
> Is that over kill? No matter how I slam it, still referring to my 
> Frankensteinian merge, "unset" does the job.
> http://testesp.flsh.usherbrooke.ca/db/trolley.php
> But then again, I will not require a quanity of items. The visitor will 
> only want one copy of a bibliographic entry :-\ - I hope?!
> You were checking to see if there was a greater than 1 quantity of 
> post[RNum], right?

Yep the frankensteinian version should work fine if you never want a
quantity greater than one, I was just trying to head off problems before
they occurred, but confused the issue since you don't need quantities :)

I took a look at your link and it appears to be working fine, though you
haven't yet wired up the viewcart.php page :)

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] Making MYSQL's RAND() more random

2005-10-03 Thread Graham Anderson

what would be the best way to make MYSQL's RAND() more random ?

my random result set always seems pretty predictable.  The first record 
in the result set always seems to be the same 4 tracks :(
Would adding some kind of random seed like RAND($randomNumberGenerator) 
work ?

If so, how do you implement this ?


$sql = "SELECT media.id,
artist.name as artist,
artist.spanish as bio,
artist.purchaseLink,
artist.picture,
media.spanish as trackName,
media.path,
media.quality,
mediaType.id as mediaType
FROM artist, media, playlistItems, mediaType
WHERE playlistItems.playlist_id = $myID
AND playlistItems.media_id = media.id
AND media.artist_id = artist.id
AND media.mediaType_id = mediaType.id
ORDER BY RAND($randomSeed) LIMIT 0, 30";

many thanks in advance

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



Re: [PHP] Making MYSQL's RAND() more random

2005-10-03 Thread Greg Donald
On 10/3/05, Graham Anderson <[EMAIL PROTECTED]> wrote:
> what would be the best way to make MYSQL's RAND() more random ?

http://dev.mysql.com/doc/mysql/en/mathematical-functions.html:


RAND() is not meant to be a perfect random generator, but instead a
fast way to generate ad hoc random numbers that is portable between
platforms for the same MySQL version.


You might try pulling the results into a PHP array and then use PHP's
random functions instead.  I always got good randomness with
mt_rand().


--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/


Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread John Taylor-Johnston

Robert Cummings wrote:
>I took a look at your link and it appears to be working fine, though you
>haven't yet wired up the viewcart.php

When I create viewcart.php, what is the best way to extract and display 
the contents of $_SESSION['TrolleyContents'] ?


Do I use my $sql value?
or in my while statement where
$mydata->RNum = $_SESSION['TrolleyContents'][??]] echo $mydata->RNum, 
$mydata->field1, $mydata->field2


Do I implode or explode $_SESSION['TrolleyContents']?

John


$myconnection = mysql_connect($server,$user,$pass);
mysql_select_db($db,$myconnection);
$sql = select * where RNum ... ?
$news = mysql_query($sql1) or die ...
   while ($mydata = mysql_fetch_object($news))
   {
while $_SESSION['TrolleyContents'][??]
echo $mydata->RNum -
   }

echo implode( ',', $_SESSION['TrolleyContents'] );  gives me a comma 
delimited.

http://ca3.php.net/explode
http://ca3.php.net/implode

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



Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread Robert Cummings
On Mon, 2005-10-03 at 16:38, John Taylor-Johnston wrote:
> Robert Cummings wrote:
>  >I took a look at your link and it appears to be working fine, though you
>  >haven't yet wired up the viewcart.php
> 
> When I create viewcart.php, what is the best way to extract and display 
> the contents of $_SESSION['TrolleyContents'] ?
> 
> Do I use my $sql value?
> or in my while statement where
> $mydata->RNum = $_SESSION['TrolleyContents'][??]] echo $mydata->RNum, 
> $mydata->field1, $mydata->field2
> 
> Do I implode or explode $_SESSION['TrolleyContents']?

Use "foreach" to traverse the array and display each trolly entry nicely
(probably as you do in the search results).

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] session_name("CCLTrolley")

2005-10-03 Thread John Taylor-Johnston

In the search results, I use something longwinded:




You are talking about doing this, below. It looks a little clunky, 
doesn't it?


foreach ($_SESSION['TrolleyContents'] as $value) {

$sql = "select * where RNum= $value";
$news = mysql_query($sql1) or die ...
  while ($mydata = mysql_fetch_object($news))
  {
  echo "$mydata->RNum - $mydata->field1: $mydata->field2.";
  }
}

Thanks,
John



Robert Cummings wrote:


On Mon, 2005-10-03 at 16:38, John Taylor-Johnston wrote:
 


Robert Cummings wrote:
>I took a look at your link and it appears to be working fine, though you
>haven't yet wired up the viewcart.php

When I create viewcart.php, what is the best way to extract and display 
the contents of $_SESSION['TrolleyContents'] ?


Do I use my $sql value?
or in my while statement where
$mydata->RNum = $_SESSION['TrolleyContents'][??]] echo $mydata->RNum, 
$mydata->field1, $mydata->field2


Do I implode or explode $_SESSION['TrolleyContents']?
   



Use "foreach" to traverse the array and display each trolly entry nicely
(probably as you do in the search results).

 





Re: [PHP] session_name("CCLTrolley")

2005-10-03 Thread John Taylor-Johnston

>Use "foreach" to traverse the array and display each trolly entry nicely

This might be cleaner? I'm not sure if I'm using while and list right, 
but somehting like that?


$glquery = mysql_query($sql);
while ($mydata = mysql_fetch_object($glquery)) {

 while (list($_SESSION['TrolleyContents'], $value) = $mydata->RNum)
 {
 echo "$mydata->RNum - $mydata->field1: $mydata->field2.";
 }

}

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



RE: [PHP] creating a shopping cart.

2005-10-03 Thread Chris W. Parker
Jay Blanchard 
on Monday, October 03, 2005 5:30 AM said:

> A basic flowchart could have helped you to answer your question and
> broken down the processes into their componenet parts. Heck, you
> don't even need fancy flowcharting software...just write down the
> steps.

Believe it or not (you who have not actually used a flowchart for
planning your code) you really *will* find flaws before you waste time
coding.

Another thing I've found is that it's not important to get hung up on
what-shapes-do-what* in your flowchart. Just start making the chart and
revising it as necessary, putting as much detail as you can.



Chris.

* Except for diamonds being logic gates (e.g. is the value hot or cold?
yes/no), hotdogs being beginning and ending markers of a
process/function/page, and squares being a process itself (e.g. "add 5
to the variable"). Having those in mind will help you keep things
organized. You can later branch out into all the other shapes.

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



[PHP] Can I call .html file as a form action instead of .php?

2005-10-03 Thread MI SOOK LEE

Hello,
Some guy told me that I can call the .html file as a form action instead of 
..php file.

So he said I could do something like this,
echo "Edit";

instead
echo "Edit";

editStaff.html and editStaff.php have the same content, only the file name 
is different. But if I do the former way(call editStaff.html as a form 
action), it doesn't work. It calls some files but looks horrible.

So the advice of the guy was wrong, or did I do something wrong?

Thanks,

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



Re: [PHP] Can I call .html file as a form action instead of .php?

2005-10-03 Thread Stephen Johnson
This should work fine -- more then likely you do not have your apache (or
whatever web server you use) configured to allow .html files to be parsed as
php files. 

You will need to update your web server configuration.


On 10/3/05 6:31 AM, "MI SOOK LEE" <[EMAIL PROTECTED]> wrote:

> Hello,
> Some guy told me that I can call the .html file as a form action instead of
> ..php file.
> So he said I could do something like this,
> echo "Edit";
> 
> instead
> echo "Edit";
> 
> editStaff.html and editStaff.php have the same content, only the file name
> is different. But if I do the former way(call editStaff.html as a form
> action), it doesn't work. It calls some files but looks horrible.
> So the advice of the guy was wrong, or did I do something wrong?
> 
> Thanks,

-- 
Stephen Johnson
The Lone Coder

http://www.ouradoptionblog.com
*Join us on our adoption journey*

[EMAIL PROTECTED]
http://www.thelonecoder.com

*Continuing the struggle against bad code*
--

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



Re: [PHP] Can I call .html file as a form action instead of .php?

2005-10-03 Thread Chris Shiflett

MI SOOK LEE wrote:

Some guy told me that I can call the .html file as a form action
instead of .php file.


You can, but unless you configure your web server to consider .html 
files to be PHP scripts, it doesn't make much sense. HTML documents are 
static, so you wouldn't be able to do anything with the data.


Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

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



Re: [PHP] Can I call .html file as a form action instead of .php?

2005-10-03 Thread Jasper Bryant-Greene

Chris Shiflett wrote:

MI SOOK LEE wrote:


Some guy told me that I can call the .html file as a form action
instead of .php file.



You can, but unless you configure your web server to consider .html 
files to be PHP scripts, it doesn't make much sense. HTML documents are 
static, so you wouldn't be able to do anything with the data.


Two things to add:

1/ Setting your webserver to consider all .html files to be PHP scripts 
is good and bad. It is sometimes considered good because it hides the 
fact that you're using PHP from potential attackers (but they'd have to 
know about a vulnerability in PHP first, so as long as you keep 
up-to-date...), but it's sometimes bad because it causes PHP to process 
all HTML files, even if they don't have any PHP in them, which slows 
things down.


2/ Passing parameters in the query string to a static HTML page can very 
occasionally be useful if you intend to do something with those 
parameters in JavaScript.


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



[PHP] Handling competing edits in a wiki engine?

2005-10-03 Thread Murray @ PlanetThoughtful

Hi All,

I've recently been working on building my own wiki engine for my blog
site. While the majority of the engine is complete, a remaining concern
I have is how to handle competing edits (ie when two or more people are
editing the same wiki page simultaneously).

I'm wondering if anyone else on the list has given this some thought?
How would / do you handle competing edits to the same entry in a wiki
application?

Just to add a little extra information: all 'edits' are in fact
'inserts'. Entries are stored in a mysql table. The engine simply
displays the most recent record for the entry being viewed. This is, of
course, to allow for retrieval of an historical version of the entry
should one or more entries be vandalized.

Much warmth,

Murrray @ PlanetThoughftul
---
"A man, a canoe, and a dream to climb Mt Everest..."
http://www.planetthoughtful.org

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



Re: [PHP] Handling competing edits in a wiki engine?

2005-10-03 Thread Jasper Bryant-Greene

Murray @ PlanetThoughtful wrote:

I've recently been working on building my own wiki engine for my blog
site. While the majority of the engine is complete, a remaining concern
I have is how to handle competing edits (ie when two or more people are
editing the same wiki page simultaneously).

I'm wondering if anyone else on the list has given this some thought?
How would / do you handle competing edits to the same entry in a wiki
application?


Just like Wikipedia -- that is, send a timestamp in a hidden form field 
with the edit box. When the form is submitted, throw an error if there 
is an edit more recent than that timestamp (an "edit conflict").


If your pages have sections, like Wikipedia's, then you can configure 
your software to only throw an error if there is an edit conflict with 
that section.


Also, it's probably a good idea to make use of transactions in an 
ACID-compliant storage engine like MySQL's InnoDB, if possible.


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



Re: [PHP] Handling competing edits in a wiki engine?

2005-10-03 Thread Philip Hallstrom

I've recently been working on building my own wiki engine for my blog
site. While the majority of the engine is complete, a remaining concern
I have is how to handle competing edits (ie when two or more people are
editing the same wiki page simultaneously).

I'm wondering if anyone else on the list has given this some thought?
How would / do you handle competing edits to the same entry in a wiki
application?

Just to add a little extra information: all 'edits' are in fact
'inserts'. Entries are stored in a mysql table. The engine simply
displays the most recent record for the entry being viewed. This is, of
course, to allow for retrieval of an historical version of the entry
should one or more entries be vandalized.


Seems like you have a couple of choices.

1 - Lock the page when the first user edits it until they save their 
changes.  Has the advantage that it's pretty easy code-wise.  The 
disadvantage being that if that first user leaves, but doesn't save/cancel 
his edit, how/when do you decide to release lock?  This would be similar 
to how Visual Source Safe or RCS does it.


2 - Allow shared edits and programatically merge the changes back into the 
master document.  This is how CVS does it.  So you could do something like 
this:


- user A starts editing document.

- user B starts editing document.

- user A saves his changes.  this copy is now the most recent as the 
system would check to see that no changes were made to the "master copy" 
while user A was making changes.


- user B saves his changes.  the system would see that the "master copy" 
had been updated and would merge the changes into B's copy and save that.


In this last step you could do it a couple of different ways.

When user B saves his changes, the system could create a diff file between 
the most recent version of the document and the one that was the basis for 
B's changes -- this would be the changes user A made.  Then you could 
merge those changes into B's document.   If there was a conflict (ie. user 
A and user B made changes to the same line) user B would have to resolve 
the differences.  This is exactly how CVS handles it.


Or, you could just create a diff file and make user B manually apply the 
patch until he's happy.


If you have access to a unix box take a look at the 'diff' and 'patch' 
commands...


good luck!

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



[PHP] chown function

2005-10-03 Thread Keith Spiller
Hello,

I'm using:

chown("$endpath", "admin");

to try to change the owner of directories after using mkdir()
to create them.  It continues to fail on my remote Fedora server.

I know the path is correct because mkdir() works perfectly.
Apache sets the owner as 48 when the directory is created.

I am not running in safe mode.

The php.net documentation does not make certain things
clear to me...  For example, do I need to be using a user id
number instead of a name?  Will the chown only work if
the server is setup as a super user?

Any help would be greatly appreciated.


Larentium

Re: [PHP] chown function

2005-10-03 Thread Jasper Bryant-Greene

Keith Spiller wrote:

I'm using:

chown("$endpath", "admin");

to try to change the owner of directories after using mkdir()
to create them.  It continues to fail on my remote Fedora server.


With what error message? Have you tried logging in with SSH or similar 
and trying the same command?


More than likely the user apache is running as doesn't have permissions 
to chown -- in fact I believe that in order to chown files one must be 
root (at least that's the way it seems to work on my system).


You could use chmod instead to allow the "admin" user access to your files.

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



Re: [PHP] Handling competing edits in a wiki engine?

2005-10-03 Thread Terence



Murray @ PlanetThoughtful wrote:

Hi All,

I've recently been working on building my own wiki engine for my blog
site. While the majority of the engine is complete, a remaining concern
I have is how to handle competing edits (ie when two or more people are
editing the same wiki page simultaneously).

I'm wondering if anyone else on the list has given this some thought?
How would / do you handle competing edits to the same entry in a wiki
application?



We use a combination of locking the record using a simple boolean column 
together with the user id who has locked the item and the timestamp.


The locking prevents another user from opening the form  and happily 
editing away without realising his changes will be lost when he presses 
submit. The user id is to inform the second user who has opened the 
document, and the timestemp is so that the first guy doesnt open the 
document and go out for lunch leaving it locked. We default it to 5 
minutes after which someone else can open the document and edit it.


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



Re: [PHP] PHP and Active Directory

2005-10-03 Thread Rory Browne
Check out the user contributed notes on the manual page - www.php.net/ldap

A few of them refer to Active Directory.

If you installed PHP from source, then you need to install OpenLDAP or
some other ldap package to get the client libraries.

If you installed PHP from packages, then you need to install the
php-ldap package(assuming the functions do not currently work)

If someone else installed PHP, then you need to get them to install
the LDAP extensions to PHP.

On 9/29/05, Miretsky, Anya <[EMAIL PROTECTED]> wrote:
> Hi,
>
> How do I connect a php script running on linux with Active Directory on
> a windows machine? I would like to have my php script autmotatically
> read email addresses from the AD server. Can this be done? I've found a
> bunch of ldap functions for php but they seem to require ldap to be
> installed on linux. I'm confused. Thanks in advance for your help.
>
>
> Anya
>
>

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



[PHP] domit and XML

2005-10-03 Thread Erik Barba
hi im new in the list i dont know where to write the email so i did it here,
i am having a problem
 I have a xml file and im parsing with domit 1.0 but im from mexico, and we
use " é í ó ú á ñ "
the xml acept it but when the php show the code in html, i cant see the
letters


Re: [PHP] array_shift not working?

2005-10-03 Thread Rory Browne
[snip]
>  How can i remove the 'count' from the array?

www.php.net/unset

>  Regards,
>  Frank
>
>

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



Re: [PHP] chown function

2005-10-03 Thread Keith Spiller

Hi Jasper,

When using my Php script, I don't see any error messages.

I have logged in using SSH, but the directories created are
owned by 48 and not my ftp user and so I have to switch
to a super user to make any changes.

Also, even though I use:
mkdir("$endpath", 0777);
The resulting directories end up as 755.

Yeah I have a feeling that you are right, that apache on
my server does not have chown permissions.

Thank you very mych for your help.


Keith

- Original Message - 
From: "Jasper Bryant-Greene" <[EMAIL PROTECTED]>

To: 
Sent: Monday, October 03, 2005 11:27 PM
Subject: Re: [PHP] chown function



Keith Spiller wrote:

I'm using:

chown("$endpath", "admin");

to try to change the owner of directories after using mkdir()
to create them.  It continues to fail on my remote Fedora server.


With what error message? Have you tried logging in with SSH or similar and 
trying the same command?


More than likely the user apache is running as doesn't have permissions to 
chown -- in fact I believe that in order to chown files one must be root 
(at least that's the way it seems to work on my system).


You could use chmod instead to allow the "admin" user access to your 
files.


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

--
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] Handling competing edits in a wiki engine?

2005-10-03 Thread Murray @ PlanetThoughtful

Terence wrote:




Murray @ PlanetThoughtful wrote:


Hi All,

I've recently been working on building my own wiki engine for my blog
site. While the majority of the engine is complete, a remaining concern
I have is how to handle competing edits (ie when two or more people are
editing the same wiki page simultaneously).

I'm wondering if anyone else on the list has given this some thought?
How would / do you handle competing edits to the same entry in a wiki
application?



We use a combination of locking the record using a simple boolean 
column together with the user id who has locked the item and the 
timestamp.


The locking prevents another user from opening the form  and happily 
editing away without realising his changes will be lost when he 
presses submit. The user id is to inform the second user who has 
opened the document, and the timestemp is so that the first guy doesnt 
open the document and go out for lunch leaving it locked. We default 
it to 5 minutes after which someone else can open the document and 
edit it.


I think I'm going to go with Jasper's suggestion, re: simply 
timestamping the current edit from the preceding version and testing 
that timestamp against the existence of more recent edits and throwing 
back to the user a request to resolve their changes against the now 
'current' version.


I had been thinking about a timed locking strategy (5 minutes seems 
short, though, for content creation, and what do you currently do when 
person A comes back from lunch, person B has made an edit in the same 
entry after person A's lock timed out, and person A commits their now 
aged edit? Do you basically throw an error anyway, and ask person A to 
resolve?), and perhaps implementing a simple javascript countdown on the 
page to alert the person editing the page when time for their edit is 
running out, but in all honesty I think throwing back the error, and 
perhaps presenting a diff of the newer version of the entry, and the 
version the user has edited, might be the way to go.


Either way, gives me plenty to think about.

Out of curiosity, does anyone know if it's possible to tell whether an 
individual session is still alive from PHP? I don't mean from within 
code being run for a particular user, but in code that, for example, 
might be executed by a cron job, which would examine a table in which 
session ids have been recorded automatically for each visitor, and 
determining which of those sessions are still theoretically alive? I 
suspect this isn't possible, but I've also learned to never 
underestimate the ingenuity of those faced with things that aren't possible.


Much warmth,

Murrray @ PlanetThoughftul
---
"A man, a canoe, and a dream to climb Mt Everest..."
http://www.planetthoughtful.org

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