[PHP] [Mail]mb_encode_mimeheader

2005-09-07 Thread Sylvain Gourvil

Hi !

I need some help for mail's encoding structure.
I use this code for encoding french character like 'é' or 'è':

   mb_language('uni');
   mb_internal_encoding(mb_detect_encoding($this->subject));
   $res = mail('[EMAIL PROTECTED]', 
mb_encode_mimeheader($this->subject), $this->msgTxt.$this->msgHTML, 
$this->entete, '[EMAIL PROTECTED]');


It is working fine unless if my first word is not containing one of 
those multi-bites characters!


For example :
Subject : êtes vous francais ou étranger ? => It is well encode and all 
is fine on differents mail software and webmail
Subject : Bonjour, êtes vous francais ? => It is encode at the 
beginnning of the second word. So it is not well written on some softwre 
like Incredimail for example.


Does someone know where i am wrong ?
Thanks a lot for your help

Sylvain Gourvil






___ 
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
Téléchargez cette version sur http://fr.messenger.yahoo.com



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



Re: [PHP] Sessions , expiry times and different time zones

2005-09-07 Thread Mark Rees
Dan Rossi" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> client cookie expires hence no more session ...
>
> On 07/09/2005, at 1:57 AM, Jordan Miller wrote:
>
> > Hi  Dan,
> >
> > Couldn't you store an expiration time directly in the $_SESSION
> > variable, rather than relying on cookie expiration (if I  understand
> > your question correctly)?  Each time a page is loaded, update the
> > expiration time in this variable to +24hr from the current time (all
> > times relative to the server's time). Then, it shouldn't matter from
> > which time zone the user is browsing.


Read what he said again. Instead of expiring the session itself, store the
time of session expiry in the session (with a longer expiry time than 1 day)
and check that.

When you say a day, do you mean 24 hours or a calendar day? Are you trying
to say:

"Today is Tuesday, so expire this session at midnight on Tuesday?"

If that's what you need to do, you need to use a client-side solution -
after all, only the client knows what time it is where the client is! Be
prepared for people who have their time zone set incorrectly.

> >
> > Jordan
> >
> >
> >
> > On Sep 6, 2005, at 10:37 AM, Dan Rossi wrote:
> >
> >
> >> hi there I have run into problems with sessions , cookies and expiryt
> >> times with different time zones. Ie our server is in the States
> >> however I am browsing from Koala land downunder. I have been trying
> >> to get the session to expire in a day, however for ppl in the states
> >> this is ok, but for me its already expired so i have been
> >> experiencing issues. How do i solve this ?
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >>
> >>
> >>
> >
> >

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



Re: [PHP] regular expression for integer range

2005-09-07 Thread Robin Vickery
On 9/6/05, babu <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> 
> I want to write regular expression for checking the string format entered by 
> user.
> 
> the allowed formats are
> 
> examples:
> 10
> 10,
> 10,12-10
> 12-10
> 
> that is the valid strings are:
> 1. only integer
> 2. an integer, range of integers example 3
> 
> and no other characters must be allowed.

$re = '/^(\d+)(,\d+-\d+)?$/';
preg_match($re, $value);

This only allows
 * an integer or
 * an integer followed by a comma and a range of integers

It doesn't allow anything else - even whitespace after the comma.

 -robin

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



Re: [PHP] Parsing MS-WORD docs

2005-09-07 Thread Richard Collyer

On Wed, September 7, 2005 7:39 am, Shafiq Rehman wrote:
> Hello,
>
> I want to parse the .doc files with PHP. Anybody have some idea regarding
> this problem.
>
> Your help regarding this matter is really appreciated
>
> Regards
> --
>
> PHP is too logical for my brain (http://www.phpgurru.com)
>

Hello,

Take a look over at SquirrelMail. http://www.squirrelmail.org/

In thier Plugins section they have a script that parses all sorts of
documents. Could be a start to build your own - however this needs a
couple of extra packages (when installed in Unix).

Regards,
Richard


--
Richard Collyer
[EMAIL PROTECTED]

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



[PHP] iconv() in PHP returns 'Unknown error 0'

2005-09-07 Thread Toomas Aas

Hello!

I am managing a FreeBSD 4.11 server which is currently running PHP 
4.3.11.  The server was originally installed in 2003 with an older 
version of PHP and libiconv 1.8. All software has been installed from 
FreeBSD ports. Over the time PHP has been upgraded several times, but 
libiconv has remained untouched:


mail# pkg_info | grep iconv
libiconv-1.8_2  A character set conversion library
php4-iconv-4.3.11   The iconv shared extension for php

There was a time when PHP's iconv() function definitely worked on this 
server, but now it seems to have a problem. I copied and pasted this 
simple test script from www.php.net:


-

-

When I load this script via the browser, PHP outputs nothing. I have 
error logging set to file only, and in the log file there is this error:


[07-Sep-2005 12:10:07] PHP Notice:  iconv(): Unknown error (0) in 
/storage/www/iconvtest.php on line 2


This is the only error I see in PHP's error log or any other logfile 
with similar timestamp.


The iconv extension is loaded and can be seen in output of phpinfo().

I read that sometimes on FreeBSD you need to use libiconv() instead of 
iconv(), but this is not the case here - when I replace iconv() with 
libiconv() I get "PHP Fatal error:  Call to undefined function: 
libiconv()".


I can successfully run iconv from command line:
$ echo This is a test. > iconvtest
$ iconv -f "ISO-8859-1" -t "UTF-8" iconvtest
This is a test.

Is it possible that my problem is caused by anything *else* than iconv 
library being out of date compared to PHP's iconv extension? If I need 
to update libiconv, I also need to update lot of things that depend on 
it, and this takes some time. If there is some quicker way to get PHP's 
iconv extension functional, I'd prefer to use that for now.


--
Toomas Aas 
|arvutivõrgu peaspetsialist | head specialist on computer networks|
|Tartu Linnakantselei   | Tartu City Office   |
- +372 736 1274

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



[PHP] debugging dl()

2005-09-07 Thread Bob Pilly

Hi All

Im having problems using dl() to load an extension that someone has 
given me. I get the following output from this simple script:

//script

//output

PHP Warning:  dl(): \u?\u: Unable to initialize module
Module compiled with module API=20020429, debug=0, thread-safety=0
PHPcompiled with module API=20041030, debug=0, thread-safety=0
These options need to match


Has anyone seen this before? If not does anyone know how i can trace 
this further?


Thanks in advance for any help!!

Cheers

Bob

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



[PHP] header, location: mailto abd browsers

2005-09-07 Thread Bernard Perrot

hello,

I have a little problem with this kind of script :

mailto:$addr";);
}

mailto("[EMAIL PROTECTED]");
?>

When called from an html page, it open correctly un MUA from mailing, but with 
some browser (mozilla for example), the calling page is still displayed, and 
with some others (firefox for example), a new blank page is displayed (and I 
don't want).


Any ideas about the problem ? How to solve it ?

Best regards,

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



Re: [PHP] debugging dl()

2005-09-07 Thread Jasper Bryant-Greene

Bob Pilly wrote:

[snip]
PHP Warning:  dl(): \u?\u: Unable to initialize module
Module compiled with module API=20020429, debug=0, thread-safety=0
PHPcompiled with module API=20041030, debug=0, thread-safety=0
These options need to match


The module was compiled for an earlier version of PHP. Get your friend 
to give you an up-to-date module.


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

If you find my advice useful, please consider donating to a poor
student! You can choose whatever amount you think my advice was
worth to you. http://tinyurl.com/7oa5s

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



Re: [PHP] debugging dl()

2005-09-07 Thread Mikey

Bob Pilly wrote:


Hi All

Im having problems using dl() to load an extension that someone has 
given me. I get the following output from this simple script:

//script

//output

PHP Warning:  dl(): \u?\u: Unable to initialize module
Module compiled with module API=20020429, debug=0, thread-safety=0
PHPcompiled with module API=20041030, debug=0, thread-safety=0
These options need to match


Has anyone seen this before? If not does anyone know how i can trace 
this further?


Thanks in advance for any help!!

Cheers

Bob

Yes, this means that the module you have been given has been compiled 
against a prevous version of PHP - you will either need them to send you 
the source to compile against your version of PHP or get them to do it 
for you, or run it against the correct version of PHP.


HTH,

Mikey

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



Re: [PHP] header, location: mailto abd browsers

2005-09-07 Thread Mikey

Bernard Perrot wrote:


hello,

I have a little problem with this kind of script :

mailto:$addr";);
}

mailto("[EMAIL PROTECTED]");
?>

When called from an html page, it open correctly un MUA from mailing, 
but with some browser (mozilla for example), the calling page is still 
displayed, and with some others (firefox for example), a new blank 
page is displayed (and I don't want).


Any ideas about the problem ? How to solve it ?

Best regards,


From the HTTP RFC:

The Location response-header field is used to redirect the recipient to 
a location other than the Request-URI for completion of the request or 
identification of a new resource. For 201 (Created) responses, the 
Location is that of the new resource which was created by the request. 
For 3xx responses, the location SHOULD indicate the server's preferred 
URI for automatic redirection to the resource. The field value consists 
of a single absolute URI.


  Location   = "Location" ":" absoluteURI

Your script doesn't appear to be trying to do a re-direct, but rather open a 
client side e-mail - if you want to do this, then you will need to use 
JavaScript on the client side.

HTH,

Mikey


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



Re: [PHP] header, location: mailto abd browsers

2005-09-07 Thread Bernard Perrot

Mikey wrote:

Your script doesn't appear to be trying to do a re-direct, but rather 
open a client side e-mail - if you want to do this, then you will need 
to use JavaScript on the client side.


Yes it redirect, because PHP add a 302 response header in this case.

And the client-side email is opened. But with mozilla, the calling page is 
still displayed, and with firefow, a new blank one is displayed. That's my 
question : who is right ? Mozilla or Firefox ? And how to have always (which 
header) the calling page displayed (without javascript, because it don't works 
if client don't want...).


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



Re: [PHP] header, location: mailto abd browsers

2005-09-07 Thread Jasper Bryant-Greene

Bernard Perrot wrote:

Mikey wrote:

Your script doesn't appear to be trying to do a re-direct, but rather 
open a client side e-mail - if you want to do this, then you will need 
to use JavaScript on the client side.


Yes it redirect, because PHP add a 302 response header in this case.

And the client-side email is opened. But with mozilla, the calling page 
is still displayed, and with firefow, a new blank one is displayed. 
That's my question : who is right ? Mozilla or Firefox ? And how to have 
always (which header) the calling page displayed (without javascript, 
because it don't works if client don't want...).


This isn't *really* a redirect. You're abusing the Location: header, so 
what you're really seeing is browsers differing in their recovery from 
your abuse. Error handling is never something you can rely on.


Use JavaScript and provide a link for them to click on when JS is 
disabled. I'm sure users who disable JS are more than used to clicking 
an extra link now and then.


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

If you find my advice useful, please consider donating to a poor
student! You can choose whatever amount you think my advice was
worth to you. http://tinyurl.com/7oa5s

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



[PHP] GD2 on Linux

2005-09-07 Thread Robert Graham

Good day

I am trying to get GD2 working on my Linux Box CentOS 4.0 with php4.2.2
the installation went well, but now, I can't find the gd2.so library 
that I need to put in /usr/lib/php4 directory.


Can anyone give me some pointers on how to resolve this challange.

Regards
Robert

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



[PHP] Session object destruction failed

2005-09-07 Thread Dan Rossi
Hi there, I am using a pear session package to handle my sessions. 
However I am trying to destroy a url based non cookie session and then 
start a cookie based session however i am trying to set the session 
cookie with an expiry date, as ive been having complications with 
sessions expiring to wanted the cookie to expire in 2 days. I have 
googled and some ppl have had issues with  session a session cookie 
after session_destroy ?? Any ideas?


Here is how i set it up

 HTTP_Session::destroy();
HTTP_Session::useCookies(true);
session_cache_expire(time()+60*60*24*24);
HTTP_Session::start('FeedPlayer');
 setcookie(session_name(),session_id(),time()+3600*24*2);
HTTP_Session::setExpire(time()+60*60*24*24);
HTTP_Session::setIdle(time()+60*60*24*24);

Sep 07 06:38:28 ident [warning] session_destroy(): Session object 
destruction failed in /usr/local/lib/php/HTTP/Session.php at line 204


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



[PHP] Re: Parsing MS-WORD docs

2005-09-07 Thread zzapper
On Wed, 7 Sep 2005 09:18:03 +0100 (BST),  wrote:

>
>On Wed, September 7, 2005 7:39 am, Shafiq Rehman wrote:
>> Hello,
>>
>> I want to parse the .doc files with PHP. Anybody have some idea regarding
>> this problem.
>>
>> Your help regarding this matter is really appreciated
>>
>> Regards
>> --
>>
>> PHP is too logical for my brain (http://www.phpgurru.com)
>>
>
>Hello,
>
>Take a look over at SquirrelMail. http://www.squirrelmail.org/
>
>In thier Plugins section they have a script that parses all sorts of
>documents. Could be a start to build your own - however this needs a
>couple of extra packages (when installed in Unix).
>
Also consider antiword



-- 
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/

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



Re: [PHP] iconv() in PHP returns 'Unknown error 0'

2005-09-07 Thread Toomas Aas

Toomas Aas wrote:


-

-

When I load this script via the browser, PHP outputs nothing. I have 
error logging set to file only, and in the log file there is this error:


[07-Sep-2005 12:10:07] PHP Notice:  iconv(): Unknown error (0) in 
/storage/www/iconvtest.php on line 2


It looks like I found the solution myself. To my great surprise, the 
order of 'extension' lines in php.ini seems to be significant. As those 
of you who use FreeBSD might know, if you install PHP and a choice of 
extensions from ports, then extensions are described in separate file 
/usr/local/etc/php/extensions.ini. I moved the line describing 
'iconv.so' to the first line in this file, and the test script quoted 
above started working as expected.


--
Toomas Aas 
|arvutivõrgu peaspetsialist | head specialist on computer networks|
|Tartu Linnakantselei   | Tartu City Office   |
- +372 736 1274

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



[PHP] Cookie-question?

2005-09-07 Thread Gustav Wiberg

Hi there!

Look at following code below, and please give me a clue why this 
cookie-thing doesn't work?

$IDJoke is set before and is an ID from a row in a db
It seems to work a while, but is there a limit for the expire-parameter?

/G
http://www.varupiraten.se/


//Get cookie from users computer for current joke to tell if user is 
allowed to vote or not!

   //
   $cookieJoke = $HTTP_COOKIE_VARS["$IDJoke"];
   if ($cookieJoke == 'voted') {$showVoteValues ='N';$userVote = 'N';}

   //User wants to vote?
   //
   if ($voteNow == 'Y' AND $userVote == 'Y' AND $cookieJoke != 'voted') {

   $showVoteValues = 'N'; //Don't show values directly after 
vote...


   //Save IDJoke to a cookie with the value - voted to users 
computer
   setcookie("$IDJoke", 'voted', time()+60*60*24*30*12*100);  /* 
expires in about 100 years*/


   //END User wants to vote
   //
   } 


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



Re: [PHP] Session object destruction failed

2005-09-07 Thread Gustav Wiberg

Hi there!

How does your code look like?

/G
http://www.varupiraten.se/

- Original Message - 
From: "Dan Rossi" <[EMAIL PROTECTED]>

To: "PHP LIST" 
Sent: Wednesday, September 07, 2005 12:55 PM
Subject: [PHP] Session object destruction failed


Hi there, I am using a pear session package to handle my sessions. However 
I am trying to destroy a url based non cookie session and then start a 
cookie based session however i am trying to set the session cookie with an 
expiry date, as ive been having complications with sessions expiring to 
wanted the cookie to expire in 2 days. I have googled and some ppl have 
had issues with  session a session cookie after session_destroy ?? Any 
ideas?


Here is how i set it up

 HTTP_Session::destroy();
HTTP_Session::useCookies(true);
session_cache_expire(time()+60*60*24*24);
HTTP_Session::start('FeedPlayer');
 setcookie(session_name(),session_id(),time()+3600*24*2);
HTTP_Session::setExpire(time()+60*60*24*24);
HTTP_Session::setIdle(time()+60*60*24*24);

Sep 07 06:38:28 ident [warning] session_destroy(): Session object 
destruction failed in /usr/local/lib/php/HTTP/Session.php at line 204


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



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 2005-09-06




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



[PHP] Integer - boundary?

2005-09-07 Thread Gustav Wiberg

Hi there!

What is the boundary for an integer?

seems to be a easy question, but I can't find it... 


/G
http://www.varupiraten.se/

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



[PHP] Breaking up search terms into an array intelligently

2005-09-07 Thread Paul Groves
I want to be able to break up a number of search terms typed into an input
box into array, simple enough one would think, just use explode, e.g


$array = explode(" ", $string);


But what if I want to be able to cope with search terms seperated by > 1
space (a common typing error)? This should work:


function enhanced_explode($string) {
 $array = preg_split ("/\s+/", $string);
 return ($array);
}


But what if I want to allow "Google"-type search parameters, so that
something like the following is split into 3 search terms?:
firstsearchterm "second search term" thirdsearchterm
The following code will do the trick, but is slow and doesn't allow for
multiple spaces as the delimiter, nor the possibility of multiple delimiters
(e.g. " ", "+", "," etc.)


function explode2($delimeter, $string)
{
   for ($i = 0; $i < strlen($string); $i++)
   {
   if ($string{$i} == '"')
   {
   if ($insidequotes)
   $insidequotes = false;
   else
   $insidequotes = true;
   }
   elseif ($string{$i} == $delimeter)
   {
   if ($insidequotes)
   {
   $currentelement .= $string{$i};
   }
   else
   {
   $returnarray[$elementcount++] = $currentelement;
   $currentelement = '';
   }
   }
   else
   {
   $currentelement .= $string{$i};
   }
   }

   $returnarray[$elementcount++] = $currentelement;

   return $returnarray;
}

None of these solutions are ideal, I guess a clever regular exression
(preg_split) could solve this, but I'm not quite sure how - does anyone have
any ideas? Thanks

Paul

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



RE: [PHP] regular expression for integer range

2005-09-07 Thread Murray @ PlanetThoughtful
> Hi all,
> 
> 
> I want to write regular expression for checking the string format entered
> by user.
> 
> the allowed formats are
> 
> examples:
> 10
> 10,
> 10,12-10
> 12-10
> 
> that is the valid strings are:
> 1. only integer
> 2. an integer, range of integers example 3
> 
> and no other characters must be allowed.

Hi babu,

As you've pointed out, you have 4 distinct scenarios to deal with, and it
may be very difficult, without a great deal of tuning and tweaking, to
define a regular expression that can effectively match all 4 scenarios
without including false matches as well.

One way of dealing with this is to build more specialized and exact regular
expressions for each possible scenario and group them together in an if
statement.

Eg.

if (preg_match('/^\d+$/',$subject) || preg_match('/^\d+,$/',$subject) ||
preg_match('/^\d+,\d+-\d+$/', $subject) || ){

// code for successful match of valid data in $subject

} else {

// code for invalid data in $subject

}

Basically, the if/else statement is testing each distinct possible pattern
and executing code if any of those distinct possible patterns match.

It may not ultimately be the most graceful way of dealing with the
situation, but having spent many hours attempting to tweak complex regular
expressions looking for the magic combination, I've learned that breaking
scenarios down this way can save a lot of development time and frustration.
This doesn't mean there isn't a benefit to finding the perfect regular
expression for your needs, just that it can often be difficult to guarantee
your code won't be plagued by false matches or false exclusions as your
expression becomes more and more complex.

Hope this helps a little.

Much warmth,

Murray
---
"Lost in thought..."
http://www.planetthoughtful.org

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



RE: [PHP] Integer - boundary?

2005-09-07 Thread Shaw, Chris - Accenture

> -Original Message-
> From: Gustav Wiberg [mailto:[EMAIL PROTECTED]
>

> Hi there!
>

> What is the boundary for an integer?
>

> seems to be a easy question, but I can't find it...

>

> /G
> http://www.varupiraten.se/
>


According to the manual,


"The size of an integer is platform-dependent, although a maximum value of
about two billion is the usual value (that's 32 bits signed). PHP does not
support unsigned integers."





This message has been delivered to the Internet by the Revenue Internet e-mail 
service

*

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



Re: [PHP] Integer - boundary?

2005-09-07 Thread Gustav Wiberg


- Original Message - 
From: "Shaw, Chris - Accenture" <[EMAIL PROTECTED]>
To: "Gustav Wiberg" <[EMAIL PROTECTED]>; "PHP General" 


Sent: Wednesday, September 07, 2005 5:03 PM
Subject: RE: [PHP] Integer - boundary?




-Original Message-
From: Gustav Wiberg [mailto:[EMAIL PROTECTED]




Hi there!




What is the boundary for an integer?




seems to be a easy question, but I can't find it...







/G
http://www.varupiraten.se/




According to the manual,


"The size of an integer is platform-dependent, although a maximum value of
about two billion is the usual value (that's 32 bits signed). PHP does not
support unsigned integers."





This message has been delivered to the Internet by the Revenue Internet 
e-mail service


*


--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 2005-09-06

Hi there!

Thanx!

Hm... I would rephrase my question.. Is it possible to get the maximum 
integer-value that can be used?


/G
http://www.varupiraten.se/



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



Re: [PHP] Confused about how to best execute php scripts in /cgi-bin/

2005-09-07 Thread KEVIN ZEMBOWER
Disappointed that there was no response to this message, I nevertheless seemed 
to have solved the problem by adding "AddHandler php-script .php" to the 
 stanza for my /cgi-bin/ directory. For the archives, in case anyone 
is searching for this answer, too.

-Kevin

>>> KEVIN ZEMBOWER <[EMAIL PROTECTED]> 09/06/05 10:44AM >>>
I'm trying to allow php scripts to execute from the /cgi-bin/ directory, which 
is currently set up as a ScriptAlias in my Apache2 configuration. I've found 
lots of references to this, but there seems to be a couple of different ways to 
accomplish this, and I can't tell which one is recommended or safest. There 
seems to be lots of security risks associated with some of the solutions 
proposed.

I'm using Debian woody. This was working under Apache 1, but somehow upgrading 
to Apache 2 broke it, and I haven't been able to fix it.

I've found solutions involving changing the ScriptAlias directory to just an 
Alias, with ExecuteCGI turned on in the Apache2 configuration. I've also found 
adding an alias to the php4 executable in the cgi-bin directory and adding an 
Action and AddHandler to the configuration, but I wasn't able to get this 
working. I get the sense that changing the SafeMode section of 
/etc/php4/apache2/php.ini is the recommended, safest way, but I haven't been 
able to find any cookbook-style directions on what to change to allow the 
execution of the php scripts from /cgi-bin/.

Can anyone help me get this set up? Searching the archives of this list 
produced some information that seemed contradictory and I couldn't understand 
which methods were recommended.

Thank you for your help and advice.

-Kevin Zembower

-
E. Kevin Zembower
Internet Systems Group manager
Johns Hopkins University
Bloomberg School of Public Health
Center for Communications Programs
111 Market Place, Suite 310
Baltimore, MD  21202
410-659-6139

--
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] Breaking up search terms into an array intelligently

2005-09-07 Thread Gustav Wiberg
- Original Message - 
From: "Paul Groves" <[EMAIL PROTECTED]>

To: 
Sent: Wednesday, September 07, 2005 4:54 PM
Subject: [PHP] Breaking up search terms into an array intelligently



I want to be able to break up a number of search terms typed into an input
box into array, simple enough one would think, just use explode, e.g


$array = explode(" ", $string);


But what if I want to be able to cope with search terms seperated by > 1
space (a common typing error)? This should work:


function enhanced_explode($string) {
$array = preg_split ("/\s+/", $string);
return ($array);
}


But what if I want to allow "Google"-type search parameters, so that
something like the following is split into 3 search terms?:
firstsearchterm "second search term" thirdsearchterm
The following code will do the trick, but is slow and doesn't allow for
multiple spaces as the delimiter, nor the possibility of multiple 
delimiters

(e.g. " ", "+", "," etc.)


function explode2($delimeter, $string)
{
  for ($i = 0; $i < strlen($string); $i++)
  {
  if ($string{$i} == '"')
  {
  if ($insidequotes)
  $insidequotes = false;
  else
  $insidequotes = true;
  }
  elseif ($string{$i} == $delimeter)
  {
  if ($insidequotes)
  {
  $currentelement .= $string{$i};
  }
  else
  {
  $returnarray[$elementcount++] = $currentelement;
  $currentelement = '';
  }
  }
  else
  {
  $currentelement .= $string{$i};
  }
  }

  $returnarray[$elementcount++] = $currentelement;

  return $returnarray;
}

None of these solutions are ideal, I guess a clever regular exression
(preg_split) could solve this, but I'm not quite sure how - does anyone 
have

any ideas? Thanks

Paul

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



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 2005-09-06



Hi Paul!

I guess you're looking for something like this?

$sql = "SELECT ID From tbTempTable";

$search = $_GET["frmSearch"];
   $search = trim($search);
   $search = strtolower($search);

   //Delete all occurances of " (chr(34)) in search-string
   //Delete all occurances of \ (chr(92)) in search-string

   $search = str_replace(chr(34),"",$search);
   $search = str_replace(chr(92),"",$search);


   //Divide search - string into an array
   //
   $searcharray = explode(" ",$search);


  //Go through search-array if several words are type

  //within search-string

  //
   $firstSQL = "WHERE";

  for ($i=0;$i   $searcharray[$i] = substr($searcharray[$i],1, 
strlen($searcharray[$i])-1);


   }


   //If - then don't search for +, only rest of searcharray
   //and add NOT LIKE to search-criteria
   //

   if (substr($searcharray[$i],0,1) == "-") {

   $notset = "NOT LIKE";

   $orset ="AND";

   $searcharray[$i] = substr($searcharray[$i],1, 
strlen($searcharray[$i])-1);


   }


   $sa = mysql_real_escape_string($searcharray[$i]);


   //Freetext search
   //
   if ($_GET["frmFreeText"] == 'on') {

   $sql .= " " . $firstSQL . " (tbvotes.titleJoke $notset '%" . $sa . 
"%'";

  $sql .= " $orset tbvotes.Joke $notset '%"  . $sa . "%'";
  $sql .= " $orset nameOfUser $notset '%"  . $sa . "%'";
   $sql .= " $orset tbvotes.nrOfVotes $notset '%" . $sa . "%'";
$sql .= ")";

   }


   //Titlesearch
   //
   if ($_GET["frmTitle"] == 'on') {

   $sql .= " " . $firstSQL . " (tbvotes.titleJoke $notset '%" . $sa . 
"%'";

$sql .= ")";

   }


   //Avs search
   //
   if ($_GET["frmFrom"] == 'on') {

   $sql .= " " . $firstSQL . " (tbvotes.fromJoke $notset '%" . $sa . 
"%'";

$sql .= ")";

   }


   //Nr of votes - search
   //
   if ($_GET["frmVotes"] == 'on') {

   $sql .= " " . $firstSQL . " (tbvotes.nrOfVotes $notset '%" . $sa . 
"%'";

$sql .= ")";

   }


   //Grade - search
   //
   if ($_GET["frmGrade"] == 'on') {

   $sql .= " " . $firstSQL . " ((totalValueJoke / nrOfVotes) $notset 
'%" . $sa . "%'";

$sql .= ")";

   }



   //Set AND if more than word typed in...
   //
   $firstSQL = "AND";



  }



}
//END Search now...
//

//echo $sql;

I hope it will give you a clue into right direction... :-)

/G
http://www.varupiraten.se/

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



[PHP] Help with Class

2005-09-07 Thread Ian Barnes
Hi,

 

I am writing a site where I need to access multiple classes of the same name
located under certain directories. The reason for each directory is because
the class under that directory talks only to the files in that directory and
cant do multiple (its not my software)

 

I have it so that I choose which ones I want to "post" to via checkboxes. I
then do a foreach loop and here it is:

 

foreach ( $forums as $num=>$val )

{

$db = new db ( 'localhost' , 'user' ,
'pass' , 'db' );

$sql = 'SELECT * FROM table WHERE id =
"'.$val.'"';

$result = $db->get($sql);

$fetchd = mysql_fetch_array ( $result );

$forumid = $fetchd['forumid'];

$posterid = $fetchd['posterid'];

$title = $_POST['title'];

$desc = $_POST['desc'];

$post = $_POST['post'];

require_once (
$fetchd['path'].'sdk/ipbsdk_class.inc.php' );

$SDK =& new ipbsdk;

$info = $SDK -> get_info ( $posterid );

$postername = $info['name'];

echo "Forum ID:".$forumid;

echo "Title:".$title;

echo "Desc:".$desc;

echo "Post:".$post;

echo "PosterID:".$posterid;

echo "PosterName:".$postername;

echo "";

}

 

See at the end of that foreach loop I need to unset the class $SDK so I can
re-init it from another dir. How can I do this? I have tried some of the
following:

Unset ( $SDK);

Unset ($GLOBALS['SDK'] );

 

 

Can anyone shed any light on my predicament ?

 

Thanks in advance

Cheers

Ian

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



Re: [PHP] Integer - boundary?

2005-09-07 Thread Brian P. O'Donnell

""Gustav Wiberg"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> - Original Message -
> From: "Shaw, Chris - Accenture" <[EMAIL PROTECTED]>
> To: "Gustav Wiberg" <[EMAIL PROTECTED]>; "PHP General"
> 
> Sent: Wednesday, September 07, 2005 5:03 PM
> Subject: RE: [PHP] Integer - boundary?
>
>
>
> > -Original Message-
> > From: Gustav Wiberg [mailto:[EMAIL PROTECTED]
> >
>
> > Hi there!
> >
>
> > What is the boundary for an integer?
> >
>
> > seems to be a easy question, but I can't find it...
>
> >
>
> > /G
> > http://www.varupiraten.se/
> >
>
>
> According to the manual,
>
>
> "The size of an integer is platform-dependent, although a maximum value of
> about two billion is the usual value (that's 32 bits signed). PHP does not
> support unsigned integers."
>
>
>
> 
>
> This message has been delivered to the Internet by the Revenue Internet
> e-mail service
>
> *
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 2005-09-06
>
> Hi there!
>
> Thanx!
>
> Hm... I would rephrase my question.. Is it possible to get the maximum
> integer-value that can be used?
>
Hi

Try this code to see what it is on your platform:

Brian



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



Re: [PHP] Help with Class

2005-09-07 Thread Jason Davidson
I would have guessed unset($sqk); to work, but also try $sdk = null;

Jason

On 9/7/05, Ian Barnes <[EMAIL PROTECTED]> wrote:
> 
> Hi,
> 
> 
> 
> I am writing a site where I need to access multiple classes of the same 
> name
> located under certain directories. The reason for each directory is 
> because
> the class under that directory talks only to the files in that directory 
> and
> cant do multiple (its not my software)
> 
> 
> 
> I have it so that I choose which ones I want to "post" to via checkboxes. 
> I
> then do a foreach loop and here it is:
> 
> 
> 
> foreach ( $forums as $num=>$val )
> 
> {
> 
> $db = new db ( 'localhost' , 'user' ,
> 'pass' , 'db' );
> 
> $sql = 'SELECT * FROM table WHERE id =
> "'.$val.'"';
> 
> $result = $db->get($sql);
> 
> $fetchd = mysql_fetch_array ( $result );
> 
> $forumid = $fetchd['forumid'];
> 
> $posterid = $fetchd['posterid'];
> 
> $title = $_POST['title'];
> 
> $desc = $_POST['desc'];
> 
> $post = $_POST['post'];
> 
> require_once (
> $fetchd['path'].'sdk/ipbsdk_class.inc.php' );
> 
> $SDK =& new ipbsdk;
> 
> $info = $SDK -> get_info ( $posterid );
> 
> $postername = $info['name'];
> 
> echo "Forum ID:".$forumid;
> 
> echo "Title:".$title;
> 
> echo "Desc:".$desc;
> 
> echo "Post:".$post;
> 
> echo "PosterID:".$posterid;
> 
> echo "PosterName:".$postername;
> 
> echo "";
> 
> }
> 
> 
> 
> See at the end of that foreach loop I need to unset the class $SDK so I 
> can
> re-init it from another dir. How can I do this? I have tried some of the
> following:
> 
> Unset ( $SDK);
> 
> Unset ($GLOBALS['SDK'] );
> 
> 
> 
> 
> 
> Can anyone shed any light on my predicament ?
> 
> 
> 
> Thanks in advance
> 
> Cheers
> 
> Ian
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>


Re: [PHP] Integer - boundary?

2005-09-07 Thread M. Sokolewicz

Brian P. O'Donnell wrote:

""Gustav Wiberg"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]


- Original Message -
From: "Shaw, Chris - Accenture" <[EMAIL PROTECTED]>
To: "Gustav Wiberg" <[EMAIL PROTECTED]>; "PHP General"

Sent: Wednesday, September 07, 2005 5:03 PM
Subject: RE: [PHP] Integer - boundary?





-Original Message-
From: Gustav Wiberg [mailto:[EMAIL PROTECTED]




Hi there!




What is the boundary for an integer?




seems to be a easy question, but I can't find it...



/G
http://www.varupiraten.se/




According to the manual,


"The size of an integer is platform-dependent, although a maximum value of
about two billion is the usual value (that's 32 bits signed). PHP does not
support unsigned integers."





This message has been delivered to the Internet by the Revenue Internet
e-mail service

*


--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 2005-09-06

Hi there!

Thanx!

Hm... I would rephrase my question.. Is it possible to get the maximum
integer-value that can be used?



Hi

Try this code to see what it is on your platform:

Brian



or, easier, simply make this script:


and you're done :P The maximum integer value is stored in PHP_INT_MAX as 
of 4.4.0 and PHP 5.0.5


before that, you had to use a way as the one Brian posted

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



Re: [PHP] Breaking up search terms into an array intelligently

2005-09-07 Thread Paul Groves

Gustav Wiberg wrote:
- Original Message - From: "Paul Groves" 
<[EMAIL PROTECTED]>

To: 
Sent: Wednesday, September 07, 2005 4:54 PM
Subject: [PHP] Breaking up search terms into an array intelligently


I want to be able to break up a number of search terms typed into an 
input

box into array, simple enough one would think, just use explode, e.g


$array = explode(" ", $string);


But what if I want to be able to cope with search terms seperated by > 1
space (a common typing error)? This should work:


function enhanced_explode($string) {
$array = preg_split ("/\s+/", $string);
return ($array);
}


But what if I want to allow "Google"-type search parameters, so that
something like the following is split into 3 search terms?:
firstsearchterm "second search term" thirdsearchterm
The following code will do the trick, but is slow and doesn't allow for
multiple spaces as the delimiter, nor the possibility of multiple 
delimiters

(e.g. " ", "+", "," etc.)


function explode2($delimeter, $string)
{
  for ($i = 0; $i < strlen($string); $i++)
  {
  if ($string{$i} == '"')
  {
  if ($insidequotes)
  $insidequotes = false;
  else
  $insidequotes = true;
  }
  elseif ($string{$i} == $delimeter)
  {
  if ($insidequotes)
  {
  $currentelement .= $string{$i};
  }
  else
  {
  $returnarray[$elementcount++] = $currentelement;
  $currentelement = '';
  }
  }
  else
  {
  $currentelement .= $string{$i};
  }
  }

  $returnarray[$elementcount++] = $currentelement;

  return $returnarray;
}

None of these solutions are ideal, I guess a clever regular exression
(preg_split) could solve this, but I'm not quite sure how - does 
anyone have

any ideas? Thanks

Paul

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



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 
2005-09-06




Hi Paul!

I guess you're looking for something like this?

$sql = "SELECT ID From tbTempTable";

$search = $_GET["frmSearch"];
   $search = trim($search);
   $search = strtolower($search);

   //Delete all occurances of " (chr(34)) in search-string
   //Delete all occurances of \ (chr(92)) in search-string

   $search = str_replace(chr(34),"",$search);
   $search = str_replace(chr(92),"",$search);


   //Divide search - string into an array
   //
   $searcharray = explode(" ",$search);


  //Go through search-array if several words are type

  //within search-string

  //
   $firstSQL = "WHERE";

  for ($i=0;$i   $searcharray[$i] = substr($searcharray[$i],1, 
strlen($searcharray[$i])-1);


   }


   //If - then don't search for +, only rest of searcharray
   //and add NOT LIKE to search-criteria
   //

   if (substr($searcharray[$i],0,1) == "-") {

   $notset = "NOT LIKE";

   $orset ="AND";

   $searcharray[$i] = substr($searcharray[$i],1, 
strlen($searcharray[$i])-1);


   }


   $sa = mysql_real_escape_string($searcharray[$i]);


   //Freetext search
   //
   if ($_GET["frmFreeText"] == 'on') {

   $sql .= " " . $firstSQL . " (tbvotes.titleJoke $notset '%" . $sa 
. "%'";

  $sql .= " $orset tbvotes.Joke $notset '%"  . $sa . "%'";
  $sql .= " $orset nameOfUser $notset '%"  . $sa . "%'";
   $sql .= " $orset tbvotes.nrOfVotes $notset '%" . $sa . "%'";
$sql .= ")";

   }


   //Titlesearch
   //
   if ($_GET["frmTitle"] == 'on') {

   $sql .= " " . $firstSQL . " (tbvotes.titleJoke $notset '%" . $sa 
. "%'";

$sql .= ")";

   }


   //Avs search
   //
   if ($_GET["frmFrom"] == 'on') {

   $sql .= " " . $firstSQL . " (tbvotes.fromJoke $notset '%" . $sa . 
"%'";

$sql .= ")";

   }


   //Nr of votes - search
   //
   if ($_GET["frmVotes"] == 'on') {

   $sql .= " " . $firstSQL . " (tbvotes.nrOfVotes $notset '%" . $sa 
. "%'";

$sql .= ")";

   }


   //Grade - search
   //
   if ($_GET["frmGrade"] == 'on') {

   $sql .= " " . $firstSQL . " ((totalValueJoke / nrOfVotes) $notset 
'%" . $sa . "%'";

$sql .= ")";

   }



   //Set AND if more than word typed in...
   //
   $firstSQL = "AND";



  }



}
//END Search now...
//

//echo $sql;

I hope it will give you a clue into right direction... :-)

/G
http://www.varupiraten.se/





Thanks  - this helps to an extent (espc. with how to deal with "+" and 
"-" delimiters), but doesn't (I think) solve the problem of how to treat 
parts of search terms in quotes as single search terms (like Google 
does), espc. as quotes get stripped out in your example. Nor does it 
deal with the problem of muliple spaces between search terms, though 
that's relatively easy to fix using the enhanced_explode() function above.


reg

Re: [PHP] Integer - boundary?

2005-09-07 Thread Brian P. O'Donnell

""M. Sokolewicz"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> or, easier, simply make this script:
>  echo PHP_INT_MAX;
> ?>
>
> and you're done :P The maximum integer value is stored in PHP_INT_MAX as
> of 4.4.0 and PHP 5.0.5
>
> before that, you had to use a way as the one Brian posted


Ahhh, I see. I am running 4.3.9

Thanks; I'll know that when I upgrade.

Brian

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



[PHP] OCI8 1.1 announce

2005-09-07 Thread Antony Dovgal

Hi all,

Yesterday OCI8 extension have been updated in the PHP CVS (HEAD only).
This updated driver resolves a large amount of bug reports and adds 
some improvements both functionality and performance, and much better 
documentation (see here: http://php.net/oci8).


A lot of time has been invested in updating this driver including 
help from Wez Furlong and the OCI team which gave a lot of feedback 
on how to do things the best and most efficient way.


Version 1.1 is available through PECL (http://pecl.php.net). 
It works with PHP 5 and PHP 4, so please go ahead and install it.
Feel free to send me feedback or open a bug report via bugs.php.net 
if you find something.


This new version should be 100% compatible with the old one, so you 
don't have to make any changes to your scripts to switch to the 
new version.


To install it run this command:
pear install oci8-beta

Make sure that you have PHP built without oci8 enabled if 
you're going to build the new oci8 as a shared extension.


The following is a list of many issues that were dealt with including 
new functionality (such as statement caching and data prefetching):


Major changes:
--
- The connection handling algorithm was rewritten. That should add 
stability and fix all non-reproducible crashes etc;
- The extension was refactored and divided into several files to 
improve readability and to make it easier to maintain;

- Added support for statement caching;
- Added support for privileged connections using external credentials;
- Added new INI options to manage persistent connections;
- Fixed oci_close() to close connections correctly.

Fixed bugs:
---
#33915 - crash in _oci_close_session
#26393 - Segfault during request shutdown in _oci_close_session() (oci8.c:2443)

#32741 - hang on ociexecute() with collections (only with 10g, works with 9i)
#32325 - can't retrieve collection using OCI8
#33583 - Apache1.3.33 Segmentation fault with php5 & OCI_New_Collection

#32361 - connection oci_connect stay persist after process the php
#29013 - multiple logins cause handles become invalid
#28944 - OCITypeByName: OCI-21522 with two connections

Fixed by rewriting the connection handling

#32140 - NVARCHAR columns are truncated
#31042 - oci_fetch_* sets field value to false
#27156 - OCIFetchInto returns false as column value when column 
contains >1 umlaut


Fixed by multiplying the buffer size by 3.

#33866 - OCIlogon do not returns conn resource for account with expired paswd
#33365 - logon fails when password expires

Fixed by adding the new oci_password_change() call syntax.

#33159 - DB-connect via webserver fails after DB-restart ORA-24327
#30808 - oci8 cannot connect after restarting DB
#30127 - lost oracle connection. need restart apache.
#29902 - oci8 doesn't disconnect sessions, overloads oracle server
#29779 - (the same issue with the Oracle server going offline)
#26829 - Killed Oracle Sessions openned with OCIPLogon()

Fixed by adding oci8.ping_interval option.

#32988 - ext/oci8: OCI doesn't support DB external authentication

Fixed by adding support of external credentials (turned off by default).

New features:
-
- Connections are now using private environment handles (this fixed a 
lot of mysterious segfaults especially under high load)


-Implemented statement caching (if supported by the Oracle version). 
Use oci8.statement_cache_size option to tune the cache size or turn 
caching off.


- Persistent connections are checked for liveness. Use 
oci8.ping_interval option to tune frequency of these checks.


- Implemented privileged connects using oci_connect()/ocilogon() 
functions. Use oci8.privileged_connect option to turn it On/Off.


- oci_password_change() can be used to change password in case you 
are not able to connect to the Oracle server. To do that call use 
oci_password_change($dbname, $user, $old_password, $new_password) syntax.



New ini options:

- oci8.statement_cache_size Used to tune statement cache size or to 
turn statement caching off (with -1). The default value is 20.


- oci8.ping_interval Used to tune the frequency of checks done on 
persistent connections or to turn pings off (with -1). The default 
value is 60, which means that a ping will be initiated on each call 
to oci_pconnect() that takes place after the connection has been idle 
for 60 seconds.


- oci8.max_persistent Used to specify the maximum number of 
persistent connections per process. The default value is -1, which 
means there is no limit.


- oci8.persistent_timeout
Used to specify the maximum length of time a persistent connection 
will be held idle. The default value is -1, which means there is no limit.


- oci8.privileged_connect
Used to turn on/off ability to connect to Oracle server as 
SYSDBA/SYSOPER using external credentials. The default value is Off.


- oci8.default_prefetch
Used to specify size of the buffer which is used when prefetching 
statements. The default value is -1, which me

[PHP] Assign values in foreach-loop

2005-09-07 Thread Sabine

Hello to all,

is it possible to assign values to the array for which I do the 
foreach-loop?


foreach ($_SESSION['arr1'] as $arr1) {
   foreach ($_SESSION['arr2'] as $arr2) {
   if ($arr1['id'] == $arr2['id']) {
   $arr1['selected'] = true;
   }
   }   
}


I think $arr1 is only a temp-var, so the assignment won't reflect on 
$_SESSION['arr1'] . Is that right?
Surely I can do it with a for-loop, but those arrays are a bit complex 
and a foreach would be much easier to read.


Thanks in advance for your answers
Sabine

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



Re: [PHP] Assign values in foreach-loop

2005-09-07 Thread Edward Vermillion

Sabine wrote:

Hello to all,

is it possible to assign values to the array for which I do the 
foreach-loop?


foreach ($_SESSION['arr1'] as $arr1) {
   foreach ($_SESSION['arr2'] as $arr2) {
   if ($arr1['id'] == $arr2['id']) {
   $arr1['selected'] = true;
   }
   }   }

I think $arr1 is only a temp-var, so the assignment won't reflect on 
$_SESSION['arr1'] . Is that right?
Surely I can do it with a for-loop, but those arrays are a bit complex 
and a foreach would be much easier to read.


Thanks in advance for your answers
Sabine



Short answer is no.

foreach works on a copy of the array, so any chnges you make inside the 
foreach loop are "lost" once you're outside of it. Although *inside* the 
foreach the changes *are* valid.


What you can do is:

$newArray = array();

foreach ($_SESSION['arr1'] as $arr1) {
foreach ($_SESSION['arr2'] as $arr2) {
if ($arr1['id'] == $arr2['id']) {
$newArray['selected'] = true;
}
}   }

Then reference $newArray instead of $arr1.

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



Re: [PHP] Assign values in foreach-loop

2005-09-07 Thread Jordan Miller

Hello,

You simply need the $key variable, then you can set a new value for  
$arr[$key] for each array element:

 $value) {
   $arr[$key] = $value * 2;
}
// $arr is now array(2, 4, 6, 8)
?>


http://www.php.net/foreach
If you have PHP 5, you can perhaps more efficiently do this:


As of PHP 5, you can easily modify array's elements by preceding  
$value with &. This will assign reference instead of copying the  
value.









Jordan




On Sep 7, 2005, at 12:14 PM, Sabine wrote:




Hello to all,

is it possible to assign values to the array for which I do the  
foreach-loop?


foreach ($_SESSION['arr1'] as $arr1) {
   foreach ($_SESSION['arr2'] as $arr2) {
   if ($arr1['id'] == $arr2['id']) {
   $arr1['selected'] = true;
   }
   }   }

I think $arr1 is only a temp-var, so the assignment won't reflect  
on $_SESSION['arr1'] . Is that right?
Surely I can do it with a for-loop, but those arrays are a bit  
complex and a foreach would be much easier to read.


Thanks in advance for your answers
Sabine

--
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] Assign values in foreach-loop

2005-09-07 Thread tg-php
Yeah, you can assign values, but you have to keep track of keys, so you'll want 
to use the => operator for foreach (pardon my reformatted, I feel naked without 
my braces):

foreach ($_SESSION['arr1'] as $key1 => $arr1)  {
foreach ($_SESSION['arr2'] as $key2 => $arr2) {
if ($arr1['id'] == $arr2['id']) {
# $arr1['selected'] = true;
$_SESSION['arr1'][$key1]['selected'] = true;
}
}
}

Is that what you were trying to do?

-TG




= = = Original message = = =

Hello to all,

is it possible to assign values to the array for which I do the 
foreach-loop?

foreach ($_SESSION['arr1'] as $arr1) 
foreach ($_SESSION['arr2'] as $arr2) 
if ($arr1['id'] == $arr2['id']) 
$arr1['selected'] = true;

   


I think $arr1 is only a temp-var, so the assignment won't reflect on 
$_SESSION['arr1'] . Is that right?
Surely I can do it with a for-loop, but those arrays are a bit complex 
and a foreach would be much easier to read.

Thanks in advance for your answers
Sabine

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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] Assign values in foreach-loop

2005-09-07 Thread Jordan Miller

sorry,

i didn't fully answer the questions... if i understand your  
multidimensional array correctly, your code should be something like:


foreach ($_SESSION['arr1'] as $key => $arr1) {
   foreach ($_SESSION['arr2'] as $arr2) {
   if ($arr1['id'] == $arr2['id']) {
   $_SESSION['arr1'][$key]['selected'] = true;
   }
   }   }

Jordan



On Sep 7, 2005, at 12:22 PM, Jordan Miller wrote:


foreach ($_SESSION['arr1'] as $arr1) {
   foreach ($_SESSION['arr2'] as $arr2) {
   if ($arr1['id'] == $arr2['id']) {
   $arr1['selected'] = true;
   }
   }   }




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



[PHP] Assign values in foreach-loop: Problem solved

2005-09-07 Thread Sabine

Thanks a lot for your fast answers,

I'll do it like -TG and Jordan in his last post suggested!

Sabine

 Original-Nachricht 
Betreff:[PHP] Assign values in foreach-loop
Datum:  Wed, 07 Sep 2005 19:14:40 +0200
Von:Sabine <[EMAIL PROTECTED]>
Antwort an: [EMAIL PROTECTED]
An: PHP general 



Hello to all,

is it possible to assign values to the array for which I do the 
foreach-loop?


foreach ($_SESSION['arr1'] as $arr1) {
  foreach ($_SESSION['arr2'] as $arr2) {
  if ($arr1['id'] == $arr2['id']) {
  $arr1['selected'] = true;
  }
  }   
}


I think $arr1 is only a temp-var, so the assignment won't reflect on 
$_SESSION['arr1'] . Is that right?
Surely I can do it with a for-loop, but those arrays are a bit complex 
and a foreach would be much easier to read.


Thanks in advance for your answers
Sabine

--
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] Assign values in foreach-loop

2005-09-07 Thread Edward Vermillion

Jordan Miller wrote:

Hello,

You simply need the $key variable, then you can set a new value for  
$arr[$key] for each array element:

 $value) {
   $arr[$key] = $value * 2;
}
// $arr is now array(2, 4, 6, 8)
?>


http://www.php.net/foreach
If you have PHP 5, you can perhaps more efficiently do this:


As of PHP 5, you can easily modify array's elements by preceding  
$value with &. This will assign reference instead of copying the  value.









Jordan


Or you can do it like that...

Totally brain-faded on the $key bit. I've been bitten by this so many 
times that it's just in my head that you can't permanently modify the array.


Cool stuff on the v5 referencing, I guess I'm gonna have to go back 
through the manual on everything and not just the new stuff.


Thanks!

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



Re: [PHP] Integer - boundary?

2005-09-07 Thread Gustav Wiberg

Thanx for the scripts! :-)

Appreciated!

/G
http://www.varupiraten.se/¨

- Original Message - 
From: "Brian P. O'Donnell" <[EMAIL PROTECTED]>

To: 
Sent: Wednesday, September 07, 2005 5:53 PM
Subject: Re: [PHP] Integer - boundary?




""M. Sokolewicz"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]


or, easier, simply make this script:


and you're done :P The maximum integer value is stored in PHP_INT_MAX as
of 4.4.0 and PHP 5.0.5

before that, you had to use a way as the one Brian posted



Ahhh, I see. I am running 4.3.9

Thanks; I'll know that when I upgrade.

Brian

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



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 2005-09-06




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



Re: [PHP] Breaking up search terms into an array intelligently

2005-09-07 Thread Gustav Wiberg
- Original Message - 
From: "Paul Groves" <[EMAIL PROTECTED]>

To: "Gustav Wiberg" <[EMAIL PROTECTED]>
Cc: "PHP General" 
Sent: Wednesday, September 07, 2005 5:45 PM
Subject: Re: [PHP] Breaking up search terms into an array intelligently



Gustav Wiberg wrote:
- Original Message - From: "Paul Groves" 
<[EMAIL PROTECTED]>

To: 
Sent: Wednesday, September 07, 2005 4:54 PM
Subject: [PHP] Breaking up search terms into an array intelligently


I want to be able to break up a number of search terms typed into an 
input

box into array, simple enough one would think, just use explode, e.g


$array = explode(" ", $string);


But what if I want to be able to cope with search terms seperated by > 1
space (a common typing error)? This should work:


function enhanced_explode($string) {
$array = preg_split ("/\s+/", $string);
return ($array);
}


But what if I want to allow "Google"-type search parameters, so that
something like the following is split into 3 search terms?:
firstsearchterm "second search term" thirdsearchterm
The following code will do the trick, but is slow and doesn't allow for
multiple spaces as the delimiter, nor the possibility of multiple 
delimiters

(e.g. " ", "+", "," etc.)


function explode2($delimeter, $string)
{
  for ($i = 0; $i < strlen($string); $i++)
  {
  if ($string{$i} == '"')
  {
  if ($insidequotes)
  $insidequotes = false;
  else
  $insidequotes = true;
  }
  elseif ($string{$i} == $delimeter)
  {
  if ($insidequotes)
  {
  $currentelement .= $string{$i};
  }
  else
  {
  $returnarray[$elementcount++] = $currentelement;
  $currentelement = '';
  }
  }
  else
  {
  $currentelement .= $string{$i};
  }
  }

  $returnarray[$elementcount++] = $currentelement;

  return $returnarray;
}

None of these solutions are ideal, I guess a clever regular exression
(preg_split) could solve this, but I'm not quite sure how - does anyone 
have

any ideas? Thanks

Paul

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



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 
2005-09-06




Hi Paul!

I guess you're looking for something like this?

$sql = "SELECT ID From tbTempTable";

$search = $_GET["frmSearch"];
   $search = trim($search);
   $search = strtolower($search);

   //Delete all occurances of " (chr(34)) in search-string
   //Delete all occurances of \ (chr(92)) in search-string

   $search = str_replace(chr(34),"",$search);
   $search = str_replace(chr(92),"",$search);


   //Divide search - string into an array
   //
   $searcharray = explode(" ",$search);


  //Go through search-array if several words are type

  //within search-string

  //
   $firstSQL = "WHERE";

  for ($i=0;$i   $searcharray[$i] = substr($searcharray[$i],1, 
strlen($searcharray[$i])-1);


   }


   //If - then don't search for +, only rest of searcharray
   //and add NOT LIKE to search-criteria
   //

   if (substr($searcharray[$i],0,1) == "-") {

   $notset = "NOT LIKE";

   $orset ="AND";

   $searcharray[$i] = substr($searcharray[$i],1, 
strlen($searcharray[$i])-1);


   }


   $sa = mysql_real_escape_string($searcharray[$i]);


   //Freetext search
   //
   if ($_GET["frmFreeText"] == 'on') {

   $sql .= " " . $firstSQL . " (tbvotes.titleJoke $notset '%" . $sa . 
"%'";

  $sql .= " $orset tbvotes.Joke $notset '%"  . $sa . "%'";
  $sql .= " $orset nameOfUser $notset '%"  . $sa . "%'";
   $sql .= " $orset tbvotes.nrOfVotes $notset '%" . $sa . "%'";
$sql .= ")";

   }


   //Titlesearch
   //
   if ($_GET["frmTitle"] == 'on') {

   $sql .= " " . $firstSQL . " (tbvotes.titleJoke $notset '%" . $sa . 
"%'";

$sql .= ")";

   }


   //Avs search
   //
   if ($_GET["frmFrom"] == 'on') {

   $sql .= " " . $firstSQL . " (tbvotes.fromJoke $notset '%" . $sa . 
"%'";

$sql .= ")";

   }


   //Nr of votes - search
   //
   if ($_GET["frmVotes"] == 'on') {

   $sql .= " " . $firstSQL . " (tbvotes.nrOfVotes $notset '%" . $sa . 
"%'";

$sql .= ")";

   }


   //Grade - search
   //
   if ($_GET["frmGrade"] == 'on') {

   $sql .= " " . $firstSQL . " ((totalValueJoke / nrOfVotes) $notset 
'%" . $sa . "%'";

$sql .= ")";

   }



   //Set AND if more than word typed in...
   //
   $firstSQL = "AND";



  }



}
//END Search now...
//

//echo $sql;

I hope it will give you a clue into right direction... :-)

/G
http://www.varupiraten.se/





Thanks  - this helps to an extent (espc. with how to deal with "+" and "-" 
delimiters), but doesn't (I think) solve the problem of how to treat parts 
of search terms in quotes as single

[PHP] user registration/login - admin functions...

2005-09-07 Thread bruce
hi...

i'm creating a couple of sites that are going to need a user
registration/login functin as well as an admin function. rather than
reinvent the wheel, it thought i'd turn to you guys, to see if you've run
across any app that you thought was good regarding the functions. i'm more
than willing to rip off, copy/paste functionality!

user registration/login:
 -allow user to enter basic information
 -allow user to enter username/passwd
 -ensure unique username
 -email confirmation of user registration
 -password regeneration (forgot passwd)
 -handle forgot username/password
 -ip blocking
 -email blocking
 -security graphic verification (capcha??)
 -admin notification
 -aadmin enable/authorize
 -Session var generation on successful login
 -limit login attempts for invalid logins
 -ensure only single usage of login at a time
 -ensure that multiple logins of a login is
  within a geographic/IP range
 -IP/User tracking
 -


Admin functionality:
 -IP Tracking
 -IP blocking
 -User Management
 -User Enable/Disable function
 -User Auth/Verification function
 -User Email Function
 -User Password regeneration function
 -Site Mamagement
 -List Users
 -Track User Actions within site
 -Allow User to be a member of a given group
 -Create Groups
 -Assign User Roles/Groups
 -
 -
 -
 -

This is kind of a basic/starting point. I'm looking at a few CMS apps, but
i'm curious to know if you guys have seen any app (open source) that has
what i'm looking for...

thanks

bruce
[EMAIL PROTECTED]

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



Re: [PHP] Assign values in foreach-loop

2005-09-07 Thread Gustav Wiberg


- Original Message - 
From: "Sabine" <[EMAIL PROTECTED]>

To: "PHP general" 
Sent: Wednesday, September 07, 2005 7:14 PM
Subject: [PHP] Assign values in foreach-loop



Hello to all,

is it possible to assign values to the array for which I do the 
foreach-loop?


foreach ($_SESSION['arr1'] as $arr1) {
   foreach ($_SESSION['arr2'] as $arr2) {
   if ($arr1['id'] == $arr2['id']) {
   $arr1['selected'] = true;
   }
   }   }

I think $arr1 is only a temp-var, so the assignment won't reflect on 
$_SESSION['arr1'] . Is that right?
Surely I can do it with a for-loop, but those arrays are a bit complex and 
a foreach would be much easier to read.


Thanks in advance for your answers
Sabine

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



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 2005-09-06



Hi there!

Why not set $_SESSION['arr1'] = true ?


foreach ($_SESSION['arr1'] as $arr1) {
   foreach ($_SESSION['arr2'] as $arr2) {
   if ($arr1['id'] == $arr2['id']) {
   $_SESSION['arr1'] = true;
   }
   }   }

I think $arr1 is only a temp-var, so the assignment won't reflect on 
$_SESSION['arr1'] . Is that right?


I might add that is not always a good thing to use true or false with 
sessions. Use 1 and 0 instead. (or two diffrent numbers or anything else but 
true or false)


/G
http://www.varupiraten.se/

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



Re: [PHP] Assign values in foreach-loop

2005-09-07 Thread Jason Davidson
In case it hasnt been said already, as long as your array has numeric and 
consecutive keys, you could use 'for' instead of 'foreach'. 

Jason

On 9/7/05, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
> 
> 
> - Original Message -
> From: "Sabine" <[EMAIL PROTECTED]>
> To: "PHP general" 
> Sent: Wednesday, September 07, 2005 7:14 PM
> Subject: [PHP] Assign values in foreach-loop
> 
> 
> > Hello to all,
> >
> > is it possible to assign values to the array for which I do the
> > foreach-loop?
> >
> > foreach ($_SESSION['arr1'] as $arr1) {
> > foreach ($_SESSION['arr2'] as $arr2) {
> > if ($arr1['id'] == $arr2['id']) {
> > $arr1['selected'] = true;
> > }
> > } }
> >
> > I think $arr1 is only a temp-var, so the assignment won't reflect on
> > $_SESSION['arr1'] . Is that right?
> > Surely I can do it with a for-loop, but those arrays are a bit complex 
> and
> > a foreach would be much easier to read.
> >
> > Thanks in advance for your answers
> > Sabine
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> > --
> > No virus found in this incoming message.
> > Checked by AVG Anti-Virus.
> > Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 
> 2005-09-06
> >
> >
> Hi there!
> 
> Why not set $_SESSION['arr1'] = true ?
> 
> > foreach ($_SESSION['arr1'] as $arr1) {
> > foreach ($_SESSION['arr2'] as $arr2) {
> > if ($arr1['id'] == $arr2['id']) {
> > $_SESSION['arr1'] = true;
> > }
> > } }
> >
> > I think $arr1 is only a temp-var, so the assignment won't reflect on
> > $_SESSION['arr1'] . Is that right?
> 
> I might add that is not always a good thing to use true or false with
> sessions. Use 1 and 0 instead. (or two diffrent numbers or anything else 
> but
> true or false)
> 
> /G
> http://www.varupiraten.se/
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>


[PHP] install-pear.phar errors

2005-09-07 Thread Greg Donald
-- 
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/

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



[PHP] Stripping control M character (^M)

2005-09-07 Thread Paul Nowosielski

Hello All,

I'm having some issues with carriage returns. Specifically the control M
character (^M). I have attempted to clean and validate the file I'm
creating. Here's the code.

 while ($row = mysql_fetch_array($result)){

// assign and clean vars
$artist = trim($row[artist]);
$tdDate = trim($row[start_date]);
$venue = trim($row[venue]);
$city = trim($row[CITY]);
$state = trim($row[STATE]);
$country = trim($row[COUNTRY]);
$tdId = trim($row[td_id]);

// create string

$line = "$artist|||$tdDate||$venue|$city|$state|$country|$tdId\n";

// validate the string

   if(preg_match("/.*.|||.*.||.*.|.*.|.*.|.*.|.*.n\//", $line)){
   // record is correct so write line to file
   fwrite($handle,$line);
   }




}


So ^M slips right by trim and my preg_match line.

Any ideas??

TIA
-- 
Paul Nowosielski
Webmaster CelebrityAccess.com
Tel: 303.440.0666 ext:219 
Cell: 303.827.4257

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



Re: [PHP] Assign values in foreach-loop

2005-09-07 Thread Sabine

Thanks, Gustav for your answer.

I already solved my problem (see below) with help of other members of 
the list.

Gustav Wiberg schrieb:



- Original Message - From: "Sabine" <[EMAIL PROTECTED]>
To: "PHP general" 
Sent: Wednesday, September 07, 2005 7:14 PM
Subject: [PHP] Assign values in foreach-loop



I might add that is not always a good thing to use true or false with 
sessions. Use 1 and 0 instead. (or two diffrent numbers or anything 
else but true or false)


Why? What is wrong with using true or false with sessions? What may happen?

Sabine



/G
http://www.varupiraten.se/



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



[PHP] Re: user registration/login - admin functions...

2005-09-07 Thread Aaron Greenspan

Bruce,

If your project isn't commercial in nature, you can use Lampshade for 
free...


http://www.thinkcomputer.com/software/lampshade/index.html

The Lampshade Starter Kit should already have a schema outlined for user 
and security management that you can integrate into your own application.


Aaron

Aaron Greenspan
President & CEO
Think Computer Corporation

http://www.thinkcomputer.com

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



Re: [PHP] Stripping control M character (^M)

2005-09-07 Thread Philip Hallstrom

Hello All,

I'm having some issues with carriage returns. Specifically the control M
character (^M). I have attempted to clean and validate the file I'm
creating. Here's the code.

while ($row = mysql_fetch_array($result)){

   // assign and clean vars
   $artist = trim($row[artist]);
   $tdDate = trim($row[start_date]);
   $venue = trim($row[venue]);
   $city = trim($row[CITY]);
   $state = trim($row[STATE]);
   $country = trim($row[COUNTRY]);
   $tdId = trim($row[td_id]);

   // create string

   $line = "$artist|||$tdDate||$venue|$city|$state|$country|$tdId\n";

   // validate the string

  if(preg_match("/.*.|||.*.||.*.|.*.|.*.|.*.|.*.n\//", $line)){
  // record is correct so write line to file
  fwrite($handle,$line);
  }
}


So ^M slips right by trim and my preg_match line.


Where is the carriage return appearing in your line of output?  Trim 
will remove these, but only at the beginning/end of a string so if $artist 
= "Paul\rNowosielski" that won't get cleaned up...


Maybe run them through ereg_replace() using "[\n\r]" as a pattern?

-philip

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



Re: [PHP] Breaking up search terms into an array intelligently

2005-09-07 Thread Brent Baisley
It sounds like you are trying to build a full text search string,  
perhaps for searching a MySQL database? Below is the function I came  
up with a while ago. It's worked fine, although it currently does not  
check for multiple spaces, but that should be easy to change. It uses  
a space as a delimiter and it checks for quotes for searching on  
phrases. It returns the search string for a MySQL full text boolean  
mode search. You should be able to easily adapt it to your specific  
needs.


function prepFullTextSearch($searchVal) {
//Split words into list
$word_List= explode(' ',stripslashes(trim 
($searchVal)));

//Step through word list to get search phrases
$i= 0;
$isPhrase= false;
foreach($word_List as $word) {
$searchItems[$i]= trim(($isPhrase?$searchItems[$i].'  
'.$word:$word));

//Check for start of Phrase
if(substr($searchItems[$i],0,1) == '"') {
$isPhrase= true;
}
//If not building a phrase, append wildcard (*) to end  
of word

if(!$isPhrase) {
$searchItems[$i].= '*';
$i++;
}
//Check for end of Phrase
if(substr($searchItems[$i],-1) == '"') {
$isPhrase= false;
$i++;
}
}
$searchVal= '+'.implode(' +',$searchItems);
return $searchVal;
}



On Sep 7, 2005, at 10:54 AM, Paul Groves wrote:

I want to be able to break up a number of search terms typed into  
an input

box into array, simple enough one would think, just use explode, e.g


$array = explode(" ", $string);


But what if I want to be able to cope with search terms seperated  
by > 1

space (a common typing error)? This should work:


function enhanced_explode($string) {
 $array = preg_split ("/\s+/", $string);
 return ($array);
}


But what if I want to allow "Google"-type search parameters, so that
something like the following is split into 3 search terms?:
firstsearchterm "second search term" thirdsearchterm
The following code will do the trick, but is slow and doesn't allow  
for
multiple spaces as the delimiter, nor the possibility of multiple  
delimiters

(e.g. " ", "+", "," etc.)


function explode2($delimeter, $string)
{
   for ($i = 0; $i < strlen($string); $i++)
   {
   if ($string{$i} == '"')
   {
   if ($insidequotes)
   $insidequotes = false;
   else
   $insidequotes = true;
   }
   elseif ($string{$i} == $delimeter)
   {
   if ($insidequotes)
   {
   $currentelement .= $string{$i};
   }
   else
   {
   $returnarray[$elementcount++] = $currentelement;
   $currentelement = '';
   }
   }
   else
   {
   $currentelement .= $string{$i};
   }
   }

   $returnarray[$elementcount++] = $currentelement;

   return $returnarray;
}

None of these solutions are ideal, I guess a clever regular exression
(preg_split) could solve this, but I'm not quite sure how - does  
anyone have

any ideas? Thanks

Paul

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





--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

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



[PHP] Checking a date for validity

2005-09-07 Thread Todd Cary
I need to check the input of a user to make sure the date is valid and 
correctly formatted.  Are there any examples available?


Here is one solution I created:

  /* Is date good */
  function is_date_good($date) {
if (strtotime($date) == -1) {
  $retval = 0;
} else {
  if (strpos($date, "/") > 0) {
$parts = explode("/", $date);
  } elseif (strpos($date, "-") > 0) {
$parts2 = explode("-", $date);
$parts[0] = $parts2[1];
$parts[1] = $parts2[2];
$parts[2] = $parts2[0];
  } else {
$parts = explode(".", $date);
  }
  //print_r($parts);
  if (checkdate($parts[0], $parts[1], $parts[2]) )
return 1;
  else
return 0;
}
return $retval;
  }

Is there a simplier solution?

Many thanks..

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



[PHP] Learning PHP - question about hidden form fields

2005-09-07 Thread Iggep
Hey all!  I sat down and started learning PHP today and ran into a bit of a 
spot.  Hoped someone here could lead me in the right direction.  I created a 
simple test form called form.php.  I thought I had this strait in my mind 
when I created it, but obviously it didn't work.  All I want to do is create 
a static value and pass it back to the page which then triggers a statement 
for the user to read.

Problem I'm running into is that I can't seem to find a way to pass that 
variable correctly with all this being on a single file.   I'd prefer to do 
this in a single file if possible.

Any ideas?



Test Form



Thank you for submitting your trouble ticket.  We have 
received your 
trouble ticket and will be in touch with you about it as soon as 
possible.";
echo "If you wish to submit another ticket, please use the form 
below.";
}

echo "";
echo "";
echo "";
echo "";
echo "Last Name:";
echo "First Name:";
echo "Email Address:";
echo "Trouble:";
echo "";
echo "";
echo "";
echo "";
?>



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



Re: [PHP] Checking a date for validity

2005-09-07 Thread Jordan Miller
writing a parse script is okay, but it will be very difficult to  
always ensure they are inputting it correctly. I recommend putting a  
popup calendar next to the input field. If the field is automatically  
populated in this way you will have a much easier time parsing it  
correctly. I can't recommend a good one offhand, but there are  
several that are DHTML and JS only, so that should be a good starting  
point for standards compliance. See:

http://www.dynarch.com/projects/calendar/
and
http://www.google.com/search?q=dhtml+popup+calendar

Jordan


On Sep 7, 2005, at 5:39 PM, Todd Cary wrote:

I need to check the input of a user to make sure the date is valid  
and correctly formatted.  Are there any examples available?


Here is one solution I created:

  /* Is date good */
  function is_date_good($date) {
if (strtotime($date) == -1) {
  $retval = 0;
} else {
  if (strpos($date, "/") > 0) {
$parts = explode("/", $date);
  } elseif (strpos($date, "-") > 0) {
$parts2 = explode("-", $date);
$parts[0] = $parts2[1];
$parts[1] = $parts2[2];
$parts[2] = $parts2[0];
  } else {
$parts = explode(".", $date);
  }
  //print_r($parts);
  if (checkdate($parts[0], $parts[1], $parts[2]) )
return 1;
  else
return 0;
}
return $retval;
  }

Is there a simplier solution?

Many thanks..

--
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] Checking a date for validity

2005-09-07 Thread Todd Cary

Jordan Miller wrote:
writing a parse script is okay, but it will be very difficult to  always 
ensure they are inputting it correctly. I recommend putting a  popup 
calendar next to the input field. If the field is automatically  
populated in this way you will have a much easier time parsing it  
correctly. I can't recommend a good one offhand, but there are  several 
that are DHTML and JS only, so that should be a good starting  point for 
standards compliance. See:

http://www.dynarch.com/projects/calendar/
and
http://www.google.com/search?q=dhtml+popup+calendar

Jordan


On Sep 7, 2005, at 5:39 PM, Todd Cary wrote:

I need to check the input of a user to make sure the date is valid  
and correctly formatted.  Are there any examples available?


Here is one solution I created:

  /* Is date good */
  function is_date_good($date) {
if (strtotime($date) == -1) {
  $retval = 0;
} else {
  if (strpos($date, "/") > 0) {
$parts = explode("/", $date);
  } elseif (strpos($date, "-") > 0) {
$parts2 = explode("-", $date);
$parts[0] = $parts2[1];
$parts[1] = $parts2[2];
$parts[2] = $parts2[0];
  } else {
$parts = explode(".", $date);
  }
  //print_r($parts);
  if (checkdate($parts[0], $parts[1], $parts[2]) )
return 1;
  else
return 0;
}
return $retval;
  }

Is there a simplier solution?

Many thanks..

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




My need has to do with claimants for class action lawsuits, so I guess 
having drop downs for months, days and years is one answer.


Todd

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



Re: [PHP] Learning PHP - question about hidden form fields

2005-09-07 Thread James Kaufman
On Wed, Sep 07, 2005 at 06:47:28PM -0400, Iggep wrote:
> Hey all!  I sat down and started learning PHP today and ran into a bit of a 
> spot.  Hoped someone here could lead me in the right direction.  I created a 
> simple test form called form.php.  I thought I had this strait in my mind 
> when I created it, but obviously it didn't work.  All I want to do is create 
> a static value and pass it back to the page which then triggers a statement 
> for the user to read.
> 
> Problem I'm running into is that I can't seem to find a way to pass that 
> variable correctly with all this being on a single file.   I'd prefer to do 
> this in a single file if possible.
> 
> Any ideas?
> 
> 
> 
>   Test Form
> 
> 
> 
>  if (defined('form_submitted')){
>   echo "Thank you for submitting your trouble ticket.  We have 
> received your 
> trouble ticket and will be in touch with you about it as soon as 
> possible.";
>   echo "If you wish to submit another ticket, please use the form 
> below.";
> }
> 
> echo "";
> echo "";
> echo "";
> echo "";
>   echo "Last Name: type='text'>";
>   echo "First Name: type='text'>";
>   echo "Email Address: type='text'>";
>   echo "Trouble:";
>   echo "";
>   echo "";
> echo "";
> echo "";
> ?>
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Jim Kaufman
Linux Evangelist
public key 0x6D802619
CCNA, CISSP# 65668
---
Scientists inhabit quite an inhuman world, and so they tend to believe in a
universe beyond people. And young people destined to become good scientists
tend to be more curious about the universe around them than about other people.
-- Jerry Ostriker (Astrophysicist)

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



RE: [PHP] Checking a date for validity

2005-09-07 Thread Chris W. Parker
Todd Cary 
on Wednesday, September 07, 2005 3:39 PM said:

>/* Is date good */
>function is_date_good($date) {
>  if (strtotime($date) == -1) {
>$retval = 0;
>  } else {
>if (strpos($date, "/") > 0) {
>  $parts = explode("/", $date);
>} elseif (strpos($date, "-") > 0) {
>  $parts2 = explode("-", $date);
>  $parts[0] = $parts2[1];
>  $parts[1] = $parts2[2];
>  $parts[2] = $parts2[0];

Why $parts2?

Just use $parts instead, like you did in the other two blocks.

Change it to:

>if (strpos($date, "/") > 0) {
>  $parts = explode("/", $date);
>} elseif (strpos($date, "-") > 0) {
>  $parts = explode("-", $date);
>} else {
>  $parts = explode(".", $date);
>}

> Is there a simplier solution?

How about strtotime()? In your function you're pretty much only
accepting a certain number of formats for your date already so you could
probably go with just passing the date (in whatever format it's given)
to strtotim() and check for a 'false' or a timestamp.


Chris.

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



Re: [PHP] Checking a date for validity

2005-09-07 Thread Ben

Todd Cary wrote:

My need has to do with claimants for class action lawsuits, so I guess 
having drop downs for months, days and years is one answer.


Drop down menus can certainly make your life easier, especially if 
you're dealing with an international audience and wondering what order 
to put the year, month, and day.  Once the info has been submitted you 
can check them against the checkdate function 
(http://ca3.php.net/manual/en/function.checkdate.php) to make sure 
they're valid (ie February 31st, etc.).


- Ben

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



RE: [PHP] Learning PHP - question about hidden form fields

2005-09-07 Thread bruce
iggep...

what are you trying to do with the following:
>>echo "";
>>echo "";

if i had to guess, i'm pretty sure you're trying to assign the val of
'preform_submitted' to 'form_submitted'... but i'm not sure why...

$preform_submitted will not have the val you think it does.. in fact, from
your sample, it's not defined... in your sample, when you call the form.php
using the POST method, the elements in the form are available via the $_POST
array...

so you could simply check for the val of $_POST['preform_submitted'] and
assign that to the hidden val..

in a similar manner, you could also check in your logic using the $_POST[]
val...

-bruce


-Original Message-
From: Iggep [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 07, 2005 3:47 PM
To: php-general@lists.php.net
Subject: [PHP] Learning PHP - question about hidden form fields


Hey all!  I sat down and started learning PHP today and ran into a bit of a
spot.  Hoped someone here could lead me in the right direction.  I created a
simple test form called form.php.  I thought I had this strait in my mind
when I created it, but obviously it didn't work.  All I want to do is create
a static value and pass it back to the page which then triggers a statement
for the user to read.

Problem I'm running into is that I can't seem to find a way to pass that
variable correctly with all this being on a single file.   I'd prefer to do
this in a single file if possible.

Any ideas?



Test Form



Thank you for submitting your trouble ticket.  We have received
your
trouble ticket and will be in touch with you about it as soon as
possible.";
echo "If you wish to submit another ticket, please use the form
below.";
}

echo "";
echo "";
echo "";
echo "";
echo "Last Name:";
echo "First Name:";
echo "Email Address:";
echo "Trouble:";
echo "";
echo "";
echo "";
echo "";
?>



--
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] Learning PHP - question about hidden form fields

2005-09-07 Thread Iggep
Wanted to thank the handful of you who wrote me with some hints.  I really 
appreciate the guidance.  :)  The test form is working like a champ.

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



Re: [PHP] Cookie-question?

2005-09-07 Thread Jose Miguel
Ok, please correct me if i'm wrong...

First of all, i'd rather use $_COOKIE instead of $HTTP_COOKIE_VARS.

And in the line...

if ($voteNow == 'Y' AND $userVote == 'Y' AND $cookieJoke != 'voted') {

Why don't you use the operator NOT IDENTICAL (!==), cause != will also 
return true if the variables are the same type sometimes.

On 9/7/05, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
> 
> Hi there!
> 
> Look at following code below, and please give me a clue why this
> cookie-thing doesn't work?
> $IDJoke is set before and is an ID from a row in a db
> It seems to work a while, but is there a limit for the expire-parameter?
> 
> /G
> http://www.varupiraten.se/
> 
> 
> //Get cookie from users computer for current joke to tell if user is
> allowed to vote or not!
> //
> $cookieJoke = $HTTP_COOKIE_VARS["$IDJoke"];
> if ($cookieJoke == 'voted') {$showVoteValues ='N';$userVote = 'N';}
> 
> //User wants to vote?
> //
> if ($voteNow == 'Y' AND $userVote == 'Y' AND $cookieJoke != 'voted') {
> 
> $showVoteValues = 'N'; //Don't show values directly after
> vote...
> 
> //Save IDJoke to a cookie with the value - voted to users
> computer
> setcookie("$IDJoke", 'voted', time()+60*60*24*30*12*100); /*
> expires in about 100 years*/
> 
> //END User wants to vote
> //
> }
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Jose Arce
http://sinexion.com - http://josearce.com


[PHP] Re: Checking a date for validity

2005-09-07 Thread JamesBenson

I would use something like:-



$date = '09/09/2005';

list($month, $day, $year) = explode("/", $date);

if(checkdate($month, $day, $year)) {
/* valid date */
} else {
/* invalid date */
}






Todd Cary wrote:
I need to check the input of a user to make sure the date is valid and 
correctly formatted.  Are there any examples available?


Here is one solution I created:

  /* Is date good */
  function is_date_good($date) {
if (strtotime($date) == -1) {
  $retval = 0;
} else {
  if (strpos($date, "/") > 0) {
$parts = explode("/", $date);
  } elseif (strpos($date, "-") > 0) {
$parts2 = explode("-", $date);
$parts[0] = $parts2[1];
$parts[1] = $parts2[2];
$parts[2] = $parts2[0];
  } else {
$parts = explode(".", $date);
  }
  //print_r($parts);
  if (checkdate($parts[0], $parts[1], $parts[2]) )
return 1;
  else
return 0;
}
return $retval;
  }

Is there a simplier solution?

Many thanks..


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



Re: [PHP] Cookie-question?

2005-09-07 Thread Gustav Wiberg
 Original Message - 
  From: Jose Miguel 
  To: Gustav Wiberg 
  Cc: PHP General 
  Sent: Thursday, September 08, 2005 3:26 AM
  Subject: Re: [PHP] Cookie-question?


  Ok, please correct me if i'm wrong...

  First of all, i'd rather use $_COOKIE instead of $HTTP_COOKIE_VARS.

  And in the line...

  if ($voteNow == 'Y' AND $userVote == 'Y' AND $cookieJoke != 'voted') {

  Why don't you use the operator NOT IDENTICAL (!==), cause != will also return 
true if the variables are the same type sometimes.


  On 9/7/05, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
Hi there! 

Look at following code below, and please give me a clue why this
cookie-thing doesn't work?
$IDJoke is set before and is an ID from a row in a db
It seems to work a while, but is there a limit for the expire-parameter? 

/G
http://www.varupiraten.se/


//Get cookie from users computer for current joke to tell if user is
allowed to vote or not!
//
$cookieJoke = $HTTP_COOKIE_VARS["$IDJoke"]; 
if ($cookieJoke == 'voted') {$showVoteValues ='N';$userVote = 'N';}

//User wants to vote?
//
if ($voteNow == 'Y' AND $userVote == 'Y' AND $cookieJoke != 'voted') {

$showVoteValues = 'N'; //Don't show values directly after
vote...

//Save IDJoke to a cookie with the value - voted to users
computer
setcookie("$IDJoke", 'voted', time()+60*60*24*30*12*100);  /*
expires in about 100 years*/

//END User wants to vote
//
}

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





  -- 
  Jose Arce
  http://sinexion.com - http://josearce.com 


--


  No virus found in this incoming message.
  Checked by AVG Anti-Virus.
  Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 2005-09-06

  Hi

  Ok, Thanx for the input! :-)

  /G
  http://www.varupiraten.se/


RE: [PHP] Help with Class

2005-09-07 Thread Ian Barnes
Hi,

 

Thanks for the help, but none of those worked. 

 

Anyone else got any suggestions? Or possibly another way of achieving this ?

 

Cheers

Ian

 

  _  

From: Jason Davidson [mailto:[EMAIL PROTECTED] 
Sent: 07 September 2005 05:47 PM
To: Ian Barnes
Cc: PHP General
Subject: Re: [PHP] Help with Class

 

I would have guessed unset($sqk); to work, but also try $sdk = null;

Jason

On 9/7/05, Ian Barnes <[EMAIL PROTECTED]> wrote:

Hi,



I am writing a site where I need to access multiple classes of the same name
located under certain directories. The reason for each directory is because
the class under that directory talks only to the files in that directory and

cant do multiple (its not my software)



I have it so that I choose which ones I want to "post" to via checkboxes. I
then do a foreach loop and here it is:



foreach ( $forums as $num=>$val )

{

$db = new db ( 'localhost' , 'user' ,
'pass' , 'db' );

$sql = 'SELECT * FROM table WHERE id =
"'.$val.'"';

$result = $db->get($sql);

$fetchd = mysql_fetch_array ( $result );

$forumid = $fetchd['forumid'];

$posterid = $fetchd['posterid'];

$title = $_POST['title'];

$desc = $_POST['desc'];

$post = $_POST['post'];

require_once (
$fetchd['path'].'sdk/ipbsdk_class.inc.php' );

$SDK =& new ipbsdk;

$info = $SDK -> get_info ( $posterid );

$postername = $info['name'];

echo "Forum ID:".$forumid;

echo "Title:".$title;

echo "Desc:".$desc;

echo "Post:".$post;

echo "PosterID:".$posterid;

echo "PosterName:".$postername;

echo "";

}



See at the end of that foreach loop I need to unset the class $SDK so I can
re-init it from another dir. How can I do this? I have tried some of the 
following:

Unset ( $SDK);

Unset ($GLOBALS['SDK'] );





Can anyone shed any light on my predicament ?



Thanks in advance

Cheers

Ian

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

 



RE: [PHP] Help with Class

2005-09-07 Thread Ian Barnes
Hi,

 

Thanks for the help, but none of those worked. 

 

Anyone else got any suggestions? Or possibly another way of achieving this ?

 

Cheers

Ian

 

  _  

From: Jason Davidson [mailto:[EMAIL PROTECTED] 
Sent: 07 September 2005 05:47 PM
To: Ian Barnes
Cc: PHP General
Subject: Re: [PHP] Help with Class

 

I would have guessed unset($sqk); to work, but also try $sdk = null;

Jason

On 9/7/05, Ian Barnes <[EMAIL PROTECTED]> wrote:

Hi,



I am writing a site where I need to access multiple classes of the same name
located under certain directories. The reason for each directory is because
the class under that directory talks only to the files in that directory and

cant do multiple (its not my software)



I have it so that I choose which ones I want to "post" to via checkboxes. I
then do a foreach loop and here it is:



foreach ( $forums as $num=>$val )

{

$db = new db ( 'localhost' , 'user' ,
'pass' , 'db' );

$sql = 'SELECT * FROM table WHERE id =
"'.$val.'"';

$result = $db->get($sql);

$fetchd = mysql_fetch_array ( $result );

$forumid = $fetchd['forumid'];

$posterid = $fetchd['posterid'];

$title = $_POST['title'];

$desc = $_POST['desc'];

$post = $_POST['post'];

require_once (
$fetchd['path'].'sdk/ipbsdk_class.inc.php' );

$SDK =& new ipbsdk;

$info = $SDK -> get_info ( $posterid );

$postername = $info['name'];

echo "Forum ID:".$forumid;

echo "Title:".$title;

echo "Desc:".$desc;

echo "Post:".$post;

echo "PosterID:".$posterid;

echo "PosterName:".$postername;

echo "";

}



See at the end of that foreach loop I need to unset the class $SDK so I can
re-init it from another dir. How can I do this? I have tried some of the 
following:

Unset ( $SDK);

Unset ($GLOBALS['SDK'] );





Can anyone shed any light on my predicament ?



Thanks in advance

Cheers

Ian

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

 



[PHP] PHP wiki recommendations

2005-09-07 Thread Murray @ PlanetThoughtful
Hi All,

I want to add a wiki to my blog site to help create a knowledgebase of the
characters, localities, stories I write to make it easier for new visitors
to delve into the areas that interest them.

I've been experimenting with a couple of different wiki packages, but am
always interested in others' thoughts and recommendations.

In particular, I've looked at MediaWiki and PmWiki. Of the two, I like
MediaWiki's 'completeness', but it's also quite slow and doesn't strike me
as being particularly (or easily?) customizable. PmWiki is probably my
current candidate, but again I'd like to make sure I'm not missing a more
obvious choice.

My shopping list for the ideal wiki application is:

- wiki entries preferably stored in MySQL tables. I'm not adamant about this
(eg PmWiki uses files rather than a db backend), but it would suit my
purposes better to be able to draw from the wiki tables from the front page
of my blog to show lists of recently added and recently updated wiki entries

- non-reliance on CamelCase wiki links. Many of my characters etc use joined
CamelCase names (eg KillFork and DangerSpoon), and to avoid confusion I'd
rather explicitly define links to wiki content

- ability to categorize wiki entries

- ability to compare history of wiki edits and easily reinstate older edits
if wiki pages get 'graffiti'd' 

- ability to allow others to edit / create wiki entries, thru a user id /
password system, so that regulars who would like to participate can do so

- ability to customize presentation of wiki pages, presumably through CSS
etc, so that I can maintain the 'look and feel' of my blog thru the wiki
content

- PHP based, though my host does run Perl, so if the killer wiki app is a
Perl-based one, I'm sure I can muddle thru implementing it

If anyone has any recommendations for other wiki applications I should look
at before making a decision, I'd love to hear from you!

Much warmth,

Murray
---
"Lost in thought..."
http://www.planetthoughtful.org

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