[PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Dave M G

PHP List,

This regular expression stuff is way tricky.

Thanks to help from this list, I have an expression that will select the 
first word of a string, up to the first white space:

#^(.*)\s#iU

But after some consideration, I realized that I wanted to keep both 
parts of the original text. The first word, and then everything that 
came after it, should be divided and stored in separate variables.


I looked through the php.net manual, and found preg_split().

At first I thought using my original expression would work, if I 
included the PREG_SPLIT_DELIM_CAPTURE parameter. It would pull out the 
first word, but also keep it.


Turns out that's not true. It removes the first word and the space, and 
looks for something before and after and only finds something after. 
Thus, in my current situation, it returns only one variable, which 
contains everything after the first space.


I realized what I need to do in this case is not select everything up to 
the first space, but to find the first space without selecting what 
comes before it. So the expression I had wasn't suitable for preg_split().


So then, what is the right expression?

Looking back over previous discussion and resources about regular 
expression syntax, I thought I had to say:

Start at the beginning: ^
Ignore anything that isn't a space: [^\s]
Select the space character: \s
Be case insensitive and not greedy: iU

Thus, my expression should be (using hash marks, #, as delimiters):
#^[^\s]|s#iU

More specifically, my preg_split() syntax is:
$parts = preg_split(#^[^\s]|s#iU, $word, PREG_SPLIT_DELIM_CAPTURE);

But it returns a two element array, where the first element is empty, 
and the second element is the whole original string.


Where did I go wrong this time?

Thank you for all your time and help.

--
Dave M G

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



Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 15:30 +0900, Dave M G wrote:
 PHP List,
 
 This regular expression stuff is way tricky.
 
 Thanks to help from this list, I have an expression that will select the 
 first word of a string, up to the first white space:
 #^(.*)\s#iU
 
 But after some consideration, I realized that I wanted to keep both 
 parts of the original text. The first word, and then everything that 
 came after it, should be divided and stored in separate variables.
 
 I looked through the php.net manual, and found preg_split().
 
 At first I thought using my original expression would work, if I 
 included the PREG_SPLIT_DELIM_CAPTURE parameter. It would pull out the 
 first word, but also keep it.
 
 Turns out that's not true. It removes the first word and the space, and 
 looks for something before and after and only finds something after. 
 Thus, in my current situation, it returns only one variable, which 
 contains everything after the first space.
 
 I realized what I need to do in this case is not select everything up to 
 the first space, but to find the first space without selecting what 
 comes before it. So the expression I had wasn't suitable for preg_split().
 
 So then, what is the right expression?
 
 Looking back over previous discussion and resources about regular 
 expression syntax, I thought I had to say:
 Start at the beginning: ^
 Ignore anything that isn't a space: [^\s]
 Select the space character: \s
 Be case insensitive and not greedy: iU
 
 Thus, my expression should be (using hash marks, #, as delimiters):
 #^[^\s]|s#iU
 
 More specifically, my preg_split() syntax is:
 $parts = preg_split(#^[^\s]|s#iU, $word, PREG_SPLIT_DELIM_CAPTURE);
 
 But it returns a two element array, where the first element is empty, 
 and the second element is the whole original string.
 
 Where did I go wrong this time?

Use preg_match() and pay special attention to the manual as it refers to
the third parameter :) The expression you need follows:

   #^([^\\s]*)\\s(.*)$#U

You don't need the insensitive modifier btw since you aren't actually
matching anything that is applicable.

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

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



Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 02:57 -0400, Robert Cummings wrote:
 On Wed, 2006-08-09 at 15:30 +0900, Dave M G wrote:
  PHP List,
  
  This regular expression stuff is way tricky.
  
  Thanks to help from this list, I have an expression that will select the 
  first word of a string, up to the first white space:
  #^(.*)\s#iU
  
  But after some consideration, I realized that I wanted to keep both 
  parts of the original text. The first word, and then everything that 
  came after it, should be divided and stored in separate variables.
  
  I looked through the php.net manual, and found preg_split().
  
  At first I thought using my original expression would work, if I 
  included the PREG_SPLIT_DELIM_CAPTURE parameter. It would pull out the 
  first word, but also keep it.
  
  Turns out that's not true. It removes the first word and the space, and 
  looks for something before and after and only finds something after. 
  Thus, in my current situation, it returns only one variable, which 
  contains everything after the first space.
  
  I realized what I need to do in this case is not select everything up to 
  the first space, but to find the first space without selecting what 
  comes before it. So the expression I had wasn't suitable for preg_split().
  
  So then, what is the right expression?
  
  Looking back over previous discussion and resources about regular 
  expression syntax, I thought I had to say:
  Start at the beginning: ^
  Ignore anything that isn't a space: [^\s]
  Select the space character: \s
  Be case insensitive and not greedy: iU
  
  Thus, my expression should be (using hash marks, #, as delimiters):
  #^[^\s]|s#iU
  
  More specifically, my preg_split() syntax is:
  $parts = preg_split(#^[^\s]|s#iU, $word, PREG_SPLIT_DELIM_CAPTURE);
  
  But it returns a two element array, where the first element is empty, 
  and the second element is the whole original string.
  
  Where did I go wrong this time?
 
 Use preg_match() and pay special attention to the manual as it refers to
 the third parameter :) The expression you need follows:
 
#^([^\\s]*)\\s(.*)$#U
 
 You don't need the insensitive modifier btw since you aren't actually
 matching anything that is applicable.

Also you don't need the ungreedy modifier either since you can't
overshoot with the above expression.

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

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



RE: [PHP] Cron running 'Hello world' script dies with Could not startup.

2006-08-09 Thread Ivo F.A.C. Fokkema
On Tue, 08 Aug 2006 17:01:13 +0200, Arno Kuhl wrote:
 Is there anything in your error log that says why it failed? (whatever
 error_log points to in php.ini, or maybe what ErrorLog points to in
 httpd.conf)
 
 Arno

Hi Arno, thanks for your reply.

However, the PHP-cli binary doesn't use the Apache error logs to dump
error information. I have tracked this problem down to the PHP-cli's
php.ini (see other post).

Thanks for thinking with me!

Ivo

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



Re: [PHP] Cron running 'Hello world' script dies with Could not startup.

2006-08-09 Thread Ivo F.A.C. Fokkema
On Tue, 08 Aug 2006 17:07:29 +0200, Ivo F.A.C. Fokkema wrote:

 On Tue, 08 Aug 2006 10:01:41 -0500, Ray Hauge wrote:
 
 On Tuesday 08 August 2006 09:01, Ivo F.A.C. Fokkema wrote:
 On Tue, 08 Aug 2006 09:01:42 -0500, Ray Hauge wrote:
  On Tuesday 08 August 2006 08:47, Ivo F.A.C. Fokkema wrote:
   Does the user running the cron have permission to execute the php
   binary?
 
  Yes, the file's owner is me and it's my crontab. Also, I've made the
  file readable to all, just in case. All directories up the directory
  tree are readable/executable, as well.
 
  I think he's asking if the php program is executable to you, the user. 
  It is possible that it would only have execute for owner and group, not
  other.

 Sorry, yes, The PHP binary is executable by all. Actually, I'm very sure
 the error message Could not startup. is generated by PHP-cli. When
 googling on that exact message, I found it in the PHP-cli source code
 (including the period at the end). However, I cannot determine from the
 PHP-cli source code what's up.
 
 It looks like when you run the script, then it works just fine, but it blows 
 up when you run it through cron.
 
 Two things I would check:
 
 1) Cron can read your *.php files.
 
 2) Cron can run php
 
 to test #2, have cron do a php -i and see what happens.
 
 1) was OK, but 2) didn't return anything, not even an error... this has
 started me thinking, and when using -ni it works...! -n makes PHP-cli
 ignore the .ini file. When looking at my .ini file, the modification date
 is July 31st, the day it all stopped working. I need to leave now, but
 will investigate tomorrow to see what's up with my .ini files, on both
 machines, and check if my scripts run with -n or after tweaking of the
 .ini.
 
 Thanks!

OK guys... guess what? It was the php.ini file from PHP-cli. I had been
messing around with PHP-GTK and had edited PHP-cli's php.ini to load the
gtk.so library (on both machines). Apparently, this stops PHP-cli to
function completely from cron. Even the 'Hello world' script didn't run.
The suggestion to try php -i got me thinking. Since that
didn't return anything, I thought about trying php -h (worked) and php -ni
(ignore .ini file). Suddenly, it worked...

SO: Loading the GTK library in your /etc/php4/cli/php.ini, KILLS the
PHP-cli functionality from cron. On Ubuntu Dapper, that is. Not sure about
other distros.

Thanks guys, for all of your suggestions!

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



Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Dave M G

Robert,

Thank you for your quick response and helpful advice.

Use preg_match() and pay special attention to the manual as it refers to
the third parameter :) The expression you need follows:
   #^([^\\s]*)\\s(.*)$#U


This works perfectly.

I now see that the preg_match() function returns an array with the 
original text, the selected text, and the discarded text. That wasn't 
clear to me before when I wasn't looking for that kind of behavior. But 
now that you point it out I see how it works.


But I am still confused about the expression you used. I can't quite 
break it down:

The opening ^ says to start at the beginning of the line.
The brackets indicate a sub-expression.
The square brackets indicate a character class (?).
The ^ inside the square brackets means not.

First question, why is there an extra backslash before the space marker 
\s? Isn't that an escape character, so wouldn't that turn the 
following space marker into a literal backslash followed by an s?


The * says to select everything matching the preceeding conditions.

There's that double backslash and s again.

Hmm... does the (.*) after the second \s mean to match all the 
whitespace found? For example if there happened to be two space 
characters instead of just one?


The PHP manual says the $ means to assert end of subject. Which I 
think means stop looking for any more matches.


So basically I'm confused about the extra escape slashes.

--
Dave M G

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



[PHP] preg_match

2006-08-09 Thread Peter Lauri
Hi,

 

How do I add so that it checks for a comma , in this preg_match. I think the
documentation is not that good for the pref_match:

 

preg_match('/^[a-z0-9-_\'() +]*$/i', $s);

 

/Peter

 

 



Re: [PHP] preg_match

2006-08-09 Thread Dave Goodchild

On 09/08/06, Peter Lauri [EMAIL PROTECTED] wrote:


Hi,



How do I add so that it checks for a comma , in this preg_match. I think
the
documentation is not that good for the pref_match:



preg_match('/^[a-z0-9-_\'() +]*$/i', $s);



Check for a comma inside a range - use a comma!









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


[PHP] Re: Cron running 'Hello world' script dies with Could not startup.

2006-08-09 Thread Colin Guthrie

Ivo F.A.C. Fokkema wrote:

SO: Loading the GTK library in your /etc/php4/cli/php.ini, KILLS the
PHP-cli functionality from cron. On Ubuntu Dapper, that is. Not sure about
other distros.

Thanks guys, for all of your suggestions!


Ahh it probably *needs* an X Server to work properly. I'll bet if you 
logged into your machine via SSH or the console without beign logged 
into a graphical env. that it would also fail.


Well found tho', this would seem like a bug in the GTK stuff tho'.

Col.

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



Re: [PHP] preg_match

2006-08-09 Thread Jochem Maas
Peter Lauri wrote:
 Hi,
 
  
 
 How do I add so that it checks for a comma , in this preg_match. I think the
 documentation is not that good for the pref_match:

it's a lot better than you spelling of preg_match. the subject of regexps is 
very
complex, the documentation reflects that - but to call them 'not that good' is
rather a disservice to the people that wrote them imho.

I taught myself regexps primarily using the php docs -
which is a testament to how good they are. :-)

 
  
 
 preg_match('/^[a-z0-9-_\'() +]*$/i', $s);


$q = chr(39); // makes for easier cmdline testing !?E#$@
function test($s) {
global $q;
echo \$s\ is ,(preg_match(#^[a-z0-9\\-_\\$q\\(\\), \\+]*$#i, 
$s)?true:false),\n;
// I escaped everything char that has special meaning in a regexp
// backslashes are themselves escaped in double quotes strings.
// I used different regexp delimiters (#) - just my preference
}

test(foo);
test(,);
test(());
test((123));
test((123,456));
test((+123,456));
test( (+123,456) );
test( $q(+123,456) $q);

 
  
 
 /Peter
 
  
 
  
 
 

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



[PHP] sessions no longer work

2006-08-09 Thread blackwater dev

Hello,

I have a site that was coded a while ago.  I was just told that the admin
side no longer works.  I looked and the host recently put php 4.4.2 on the
site.  I have tried a few things but nothing seems to work.  The problem is
once you log in the admin page always kicks you back, doesn't see the
session vars.  What could be wrong?  Here is the code:

?php  require_once('Connections/db.php'); ?
? if (isset($_POST[uname])){
$uname=$_POST[uname];
$pword=md5($_POST[pword]);
 $SQL=select * from users where admin=1 and pword='$pword' and
uname='$uname';
mysql_select_db($database, $wards);
   $Result1 = mysql_query($SQL, $wards) or die(mysql_error());
   $affected_rows = mysql_num_rows($Result1);
if ($affected_rows0){
session_start();
 $_SESSION['wardadmin']=yes;
 header(location: admin.php);
 }
   else {$bad=Incorrect username and Password;}
}

I can echo out the session here and see yes, but I have this code in
admin.php

?
session_start();
if ($_SESSION['wardadmin']!=yes) { header(location: login.php);
exit;
}
?

Thanks!


Re: [PHP] sessions no longer work

2006-08-09 Thread Jochem Maas
blackwater dev wrote:
 Hello,
 
 I have a site that was coded a while ago.  I was just told that the admin
 side no longer works.  I looked and the host recently put php 4.4.2 on the
 site.  I have tried a few things but nothing seems to work.  The problem is
 once you log in the admin page always kicks you back, doesn't see the
 session vars.  What could be wrong?  Here is the code:
 
 ?php  require_once('Connections/db.php'); ?
 ? if (isset($_POST[uname])){
 $uname=$_POST[uname];
 $pword=md5($_POST[pword]);
  $SQL=select * from users where admin=1 and pword='$pword' and
 uname='$uname';
 mysql_select_db($database, $wards);
$Result1 = mysql_query($SQL, $wards) or die(mysql_error());
$affected_rows = mysql_num_rows($Result1);
 if ($affected_rows0){
 session_start();
  $_SESSION['wardadmin']=yes;

try this here:

session_write_close();

  header(location: admin.php);
  }
else {$bad=Incorrect username and Password;}
 }
 
 I can echo out the session here and see yes, but I have this code in
 admin.php
 
 ?
 session_start();
 if ($_SESSION['wardadmin']!=yes) { header(location: login.php);
 exit;
 }
 ?
 
 Thanks!
 

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



[PHP] returning to the same page after log in

2006-08-09 Thread Sjef
Hello all!
This is a bit difficult to explain.
On a site I am building I sometimes use the GET method to forward values to 
the next page. There are certain pages that you need to be logged in to to 
be able to see data. So you arrive at the page, you realize that you are not 
logged in, so you type your username/password and hit 'log in'. Then the 
page gets severely messed up as the GET data are not forwarded (at least, I 
think that's the problem). Any ideas how to solve this?
I tried to send a header(location: ...) with the document_root and 
request_uri as the location, but that doesn't do the trick. 

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



[PHP] problem with quotes (single and double) in forms

2006-08-09 Thread afan
Hi to all.

Have a web site on server where magic quote is turned On. Because of
problems with quotes within forms, I was thinking to turn it Off. I wonder
how much work I'll have to change code to accept new setting? Are we
talking about major changes or something that could be done in day or two
(the site has few couple-pages long forms and about 10 regular contact
us/register/edit membership/edit account/... forms)?

I have access to php.ini. Could I just turn magic quotes Off to see what's
going on and what forms will not work and how to fix it?

On http://www.zend.com/manual/security.magicquotes.disabling.php that
ini_set() is not an option, but there is an solution to disable magic
quotes at runtime. Means, I can use this to change code (prepare for
turning off) on pages with forms? Correct?

Thanks for any help.

-afan

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



Re: [PHP] question about how php handles post'd and get'd data

2006-08-09 Thread tedd

At 10:27 AM +1000 8/9/06, Ligaya Turmelle wrote:

jonathan wrote:
i was having a conversation and was wondering where in the source 
code for php is the process for writing get'd and post'd data to 
their corresponding arrays? Also, is there a way to view the source 
code online?


thanks,

jonathan

PHP's cvs is available online at 
http://cvs.php.net/viewvc.cgi/php-src/.  Drill down far enough and 
you will get the source code.


Ex:
http://cvs.php.net/viewvc.cgi/php-src/main/fopen_wrappers.c?revision=1.183view=markup



Damn, that's a lot of GET.

Where's the reference(s) for how to add your own code? Sorry, I 
haven't a clue as to where to look.


tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] I only want x number of lines of data

2006-08-09 Thread Ross
At the mometn I have this


function display_result($module_no) {

if ($module_no != ) {
$module_no =unserialize ($module_no);
foreach ($module_no as $number = $data) {

$count=$count+1;?

Q.?=$count; ?- span style=font-weight:bold?=$data;?/spanBR /
?
}
}

which outputs all the data in the array..typically..

Q.1- pass
Q.2- pass
Q.3- pass
Q.4- pass
Q.5- pass


but what if i only want q1-q3 output? any ideas how I can modify the script 
to give me x number of outputted answers? 

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



Re: [PHP] sessions no longer work

2006-08-09 Thread blackwater dev

Sorry if you are getting this multiple times, email is acting a bit screwy.

Nope. still doesn't work.  Sessions just aren't saved.


On 8/9/06, Jochem Maas [EMAIL PROTECTED] wrote:


blackwater dev wrote:
 Hello,

 I have a site that was coded a while ago.  I was just told that the
admin
 side no longer works.  I looked and the host recently put php 4.4.2 on
the
 site.  I have tried a few things but nothing seems to work.  The problem
is
 once you log in the admin page always kicks you back, doesn't see the
 session vars.  What could be wrong?  Here is the code:

 ?php  require_once('Connections/db.php'); ?
 ? if (isset($_POST[uname])){
 $uname=$_POST[uname];
 $pword=md5($_POST[pword]);
  $SQL=select * from users where admin=1 and pword='$pword' and
 uname='$uname';
 mysql_select_db($database, $wards);
$Result1 = mysql_query($SQL, $wards) or die(mysql_error());
$affected_rows = mysql_num_rows($Result1);
 if ($affected_rows0){
 session_start();
  $_SESSION['wardadmin']=yes;

try this here:

session_write_close();

  header(location: admin.php);
  }
else {$bad=Incorrect username and Password;}
 }

 I can echo out the session here and see yes, but I have this code in
 admin.php

 ?
 session_start();
 if ($_SESSION['wardadmin']!=yes) { header(location: login.php);
 exit;
 }
 ?

 Thanks!





Re: [PHP] returning to the same page after log in

2006-08-09 Thread Andrei

When u know the user is not logged in and you have to redirect him to
login page, get all variables that are in $_GET and in $_POST (if u have
data that u send in post also) and form a string with them as a return
context string like:

The code that you have to put in the page where you redirect the user to
login page and where user will land back after login.

$return_context = $PHP_SELF.?;
foreach( $_GET as $key = $val )
   $return_context .= .$key.=.$val;
foreach( $_POST as $key = $val )
   $return_context .= .$key.=.$val;

header( Location: login.php?back_page=.urlencode( utf8_encode(
$return_context ) ) );

In login page, after you created the session or whatever you do at login
pagrt you do:

if( empty( $back_page ) )
$back_page = $_GET[back_page];

if( !empty( $back_page ) )
header( Location: .utf8_decode( urldecode( $back_page ) ) );
else
header( Location: somewhere_else.php );
exit;

The code is not checked. It's only to have an ideea...

Andy

Sjef wrote:
 Hello all!
 This is a bit difficult to explain.
 On a site I am building I sometimes use the GET method to forward values to 
 the next page. There are certain pages that you need to be logged in to to 
 be able to see data. So you arrive at the page, you realize that you are not 
 logged in, so you type your username/password and hit 'log in'. Then the 
 page gets severely messed up as the GET data are not forwarded (at least, I 
 think that's the problem). Any ideas how to solve this?
 I tried to send a header(location: ...) with the document_root and 
 request_uri as the location, but that doesn't do the trick. 
 

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



Re: [PHP] I only want x number of lines of data

2006-08-09 Thread Brad Bonkoski



Ross wrote:

At the mometn I have this


function display_result($module_no) {

  

   $count = 0; //Of course you *should* initialize $count
   $start = 1;
   $end = 3;

if ($module_no != ) {
$module_no =unserialize ($module_no);
foreach ($module_no as $number = $data) {

$count=$count+1;

  

   if( $count = $start  $count = $end ) { ?

Q.?=$count; ?- span style=font-weight:bold?=$data;?/spanBR /
  
?
  

   }

}
  
}


which outputs all the data in the array..typically..

Q.1- pass
Q.2- pass
Q.3- pass
Q.4- pass
Q.5- pass


but what if i only want q1-q3 output? any ideas how I can modify the script 
to give me x number of outputted answers? 

  


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



Re: [PHP] returning to the same page after log in

2006-08-09 Thread Sjef
I think I solved the problem.
I've set the action of the login form to $_SERVER['REQUEST_URI'] instead of 
$_SERVER['PHP_SELF']. It works fine.
May not be the proper way but hey ...

Sjef

Andrei [EMAIL PROTECTED] schreef in bericht 
news:[EMAIL PROTECTED]

 When u know the user is not logged in and you have to redirect him to
 login page, get all variables that are in $_GET and in $_POST (if u have
 data that u send in post also) and form a string with them as a return
 context string like:

 The code that you have to put in the page where you redirect the user to
 login page and where user will land back after login.

 $return_context = $PHP_SELF.?;
 foreach( $_GET as $key = $val )
   $return_context .= .$key.=.$val;
 foreach( $_POST as $key = $val )
   $return_context .= .$key.=.$val;

 header( Location: login.php?back_page=.urlencode( utf8_encode(
 $return_context ) ) );

 In login page, after you created the session or whatever you do at login
 pagrt you do:

 if( empty( $back_page ) )
$back_page = $_GET[back_page];

 if( !empty( $back_page ) )
 header( Location: .utf8_decode( urldecode( $back_page ) ) );
 else
 header( Location: somewhere_else.php );
 exit;

 The code is not checked. It's only to have an ideea...

 Andy

 Sjef wrote:
 Hello all!
 This is a bit difficult to explain.
 On a site I am building I sometimes use the GET method to forward values 
 to
 the next page. There are certain pages that you need to be logged in to 
 to
 be able to see data. So you arrive at the page, you realize that you are 
 not
 logged in, so you type your username/password and hit 'log in'. Then the
 page gets severely messed up as the GET data are not forwarded (at least, 
 I
 think that's the problem). Any ideas how to solve this?
 I tried to send a header(location: ...) with the document_root and
 request_uri as the location, but that doesn't do the trick.
 

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



Re: [PHP] sessions no longer work

2006-08-09 Thread blackwater dev

It doesn't matter if I just surf to the page and they do seem to get the
same phpsessionid..interestingly enough the first three cars are 'BAD'.  Not
sure if the path is writable through.

On 8/9/06, Jochem Maas [EMAIL PROTECTED] wrote:


blackwater dev wrote:
 Sorry if you are getting this multiple times, email is acting a bit
screwy.

 Nope. still doesn't work.  Sessions just aren't saved.

check that the session save path is writable and have a look to
see if you are getting a new session id each time.



 On 8/9/06, Jochem Maas [EMAIL PROTECTED] wrote:

 blackwater dev wrote:
  Hello,
 
  I have a site that was coded a while ago.  I was just told that the
 admin
  side no longer works.  I looked and the host recently put php 4.4.2on
 the
  site.  I have tried a few things but nothing seems to work.  The
 problem
 is
  once you log in the admin page always kicks you back, doesn't see the
  session vars.  What could be wrong?  Here is the code:
 
  ?php  require_once('Connections/db.php'); ?
  ? if (isset($_POST[uname])){
  $uname=$_POST[uname];
  $pword=md5($_POST[pword]);
   $SQL=select * from users where admin=1 and pword='$pword' and
  uname='$uname';
  mysql_select_db($database, $wards);
 $Result1 = mysql_query($SQL, $wards) or die(mysql_error());
 $affected_rows = mysql_num_rows($Result1);
  if ($affected_rows0){
  session_start();
   $_SESSION['wardadmin']=yes;

 try this here:

 session_write_close();

   header(location: admin.php);
   }
 else {$bad=Incorrect username and Password;}
  }
 
  I can echo out the session here and see yes, but I have this code in
  admin.php
 
  ?
  session_start();
  if ($_SESSION['wardadmin']!=yes) { header(location: login.php);
  exit;
  }
  ?
 
  Thanks!
 







Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 19:07 +0900, Dave M G wrote:
 Robert,
 
 Thank you for your quick response and helpful advice.
  Use preg_match() and pay special attention to the manual as it refers to
  the third parameter :) The expression you need follows:
 #^([^\\s]*)\\s(.*)$#U
 
 This works perfectly.
 
 I now see that the preg_match() function returns an array with the 
 original text, the selected text, and the discarded text. That wasn't 
 clear to me before when I wasn't looking for that kind of behavior. But 
 now that you point it out I see how it works.
 
 But I am still confused about the expression you used. I can't quite 
 break it down:
 The opening ^ says to start at the beginning of the line.
 The brackets indicate a sub-expression.
 The square brackets indicate a character class (?).
 The ^ inside the square brackets means not.
 
 First question, why is there an extra backslash before the space marker 
 \s? Isn't that an escape character, so wouldn't that turn the 
 following space marker into a literal backslash followed by an s?
 
 The * says to select everything matching the preceeding conditions.
 
 There's that double backslash and s again.
 
 Hmm... does the (.*) after the second \s mean to match all the 
 whitespace found? For example if there happened to be two space 
 characters instead of just one?
 
 The PHP manual says the $ means to assert end of subject. Which I 
 think means stop looking for any more matches.
 
 So basically I'm confused about the extra escape slashes.

The extra slashes are to properly escape the backslash character since
you are using double quotes. While it is true that your expression works
because \s has no meaning in PHP, you can't rely on that being
indefinitely true. You are relying on a side effect of an unrecognized
special character. In all honesty, I should have escaped the $ character
also since it denotes a variable in double quotes. In case you didn't
know, double quotes indicate interpolated strings, single quotes
indicate literal strings. This is why you can produce newline, tab, and
other special characters in double quotes, but not in single quotes. The
best way to write your string since you do not intend to perform any
interpolation is the following:

'#^([^\s]*)\s(.*)$#'

As for the meaning of the individual parts of the pattern...

The first ^ anchors the matching to the beginning of the string to
match.

The open square braces indicates a character range (which can include
character classes such as \s for whitespace. The ^ within the range
negates the semantics of the range, so as you say... do NOT match the
enclosed range. The * following the square brackets say that there can
be 0 to infinity characters matched (this means if your value being
matched has a lead space then you can get a blank first match... you may
actually want + here instead of *, but I think you're trimming anyways
and I followed your original). the following \s then matches the first
whitespace following the initial block. You might actually want to put
a ? after this so that if the end of the value is reached without any
whitespace then you still match the initial portion. The .* portion says
match 0 to infinity characters of any value and the trailing $ anchors
the matching to the end of the value thus forcing .* to match all
characters from the space to the end of the string.

As I said you may want the following pattern in cases where no space
exists:

'#^([^\s]*)\s?(.*)$#'

In this usage the ? makes it match only if it exists. it's the same as
\s{0,1} but obviously shorter :)

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

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



Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Kevin Murphy



On Aug 8, 2006, at 11:30 PM, Dave M G wrote:


PHP List,

This regular expression stuff is way tricky.

Thanks to help from this list, I have an expression that will  
select the first word of a string, up to the first white space:

#^(.*)\s#iU

But after some consideration, I realized that I wanted to keep both  
parts of the original text. The first word, and then everything  
that came after it, should be divided and stored in separate  
variables.


Now, I would do this different. Probably wrong but instead of a  
regular expression here, I would do something like this:


$array = explode( ,$string);
$first_word = $array[0];
$rest_words = substr_replace($string,,0,strlen($first_word));

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326



Re: [PHP] I only want x number of lines of data

2006-08-09 Thread Jochem Maas
? phpinfo(); ?PROMISE? phpinfo(); ?TO? phpinfo(); ?STOP? phpinfo(); 
?BREAKING? phpinfo(); ?IN? phpinfo();
?AND? phpinfo(); ?OUT? phpinfo(); ?OF? phpinfo(); ?PHP? phpinfo(); 
?TO? phpinfo(); ?OUTPUT? phpinfo();
?STRINGS? phpinfo(); ?TO? phpinfo(); ?THE? phpinfo(); ?BROWSER? 
phpinfo();

evil_grineasy to read don't you think?/evil_grin

Ross wrote:
 At the mometn I have this
 
 
 function display_result($module_no) {
 
 if ($module_no != ) {
 $module_no =unserialize ($module_no);
 foreach ($module_no as $number = $data) {
 
 $count=$count+1;?

why $count when you already have $number

 
 Q.?=$count; ?- span style=font-weight:bold?=$data;?/spanBR /
 ?
 }
 }

function display_result($module_no, $max = null)
{
if (is_string($module_no)  $module_no)
$module_no = unserialize($module_no); // god knows why your 
using this
if (!is_array($module_no)) return;

if (!$max || !is_int($max)) $max = count($module_no);

$count = 0;
foreach ($module_no as $number = $data) {
if ($count  $max) break;
echo Q., $count++,' - strong',$data,'/strongbr /';
}
}


PS - generally is better when function don't echo stuff... it makes them
more flexible.
 
 which outputs all the data in the array..typically..
 
 Q.1- pass
 Q.2- pass
 Q.3- pass
 Q.4- pass
 Q.5- pass
 
 
 but what if i only want q1-q3 output? any ideas how I can modify the script 
 to give me x number of outputted answers? 

hunderds - see simple idea number one above to get started.

 

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



Re: [PHP] I only want x number of lines of data

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 16:39 +0200, Jochem Maas wrote:
 ? phpinfo(); ?PROMISE? phpinfo(); ?TO? phpinfo(); ?STOP? phpinfo(); 
 ?BREAKING? phpinfo(); ?IN? phpinfo();
 ?AND? phpinfo(); ?OUT? phpinfo(); ?OF? phpinfo(); ?PHP? phpinfo(); 
 ?TO? phpinfo(); ?OUTPUT? phpinfo();
 ?STRINGS? phpinfo(); ?TO? phpinfo(); ?THE? phpinfo(); ?BROWSER? 
 phpinfo();
 
 evil_grineasy to read don't you think?/evil_grin
 
 Ross wrote:
  At the mometn I have this
  
  
  function display_result($module_no) {
  
  if ($module_no != ) {
  $module_no =unserialize ($module_no);
  foreach ($module_no as $number = $data) {
  
  $count=$count+1;?
 
 why $count when you already have $number

And even if you really want to use $count, why not use the faster +=
operator:

$count += 1;

Or if 1 is always going to be your increment:

$count++;

Or if you know how ++ works and want to eke just a tad more speed out:

++$count;

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

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



Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 08:11 -0700, Kevin Murphy wrote:
 
 On Aug 8, 2006, at 11:30 PM, Dave M G wrote:
 
  PHP List,
 
  This regular expression stuff is way tricky.
 
  Thanks to help from this list, I have an expression that will  
  select the first word of a string, up to the first white space:
  #^(.*)\s#iU
 
  But after some consideration, I realized that I wanted to keep both  
  parts of the original text. The first word, and then everything  
  that came after it, should be divided and stored in separate  
  variables.
 
 Now, I would do this different. Probably wrong but instead of a  
 regular expression here, I would do something like this:
 
 $array = explode( ,$string);
 $first_word = $array[0];
 $rest_words = substr_replace($string,,0,strlen($first_word));

This presumes a space and not just whitespace. What does the adaptation
look like if you account for space, tab, newline, carriage return? :)

That said, if we were to only match on a space character:

?php

$text = The nimble fox jumped over the river.;

if( ($splitPoint = strpos( $text, ' ' )) !== false )
{
$word = substr( $text, 0, $splitPoint );
$rest = substr( $text, $splitPoint + 1 );
}
else
{
$word = $text;
$rest = '';
}

echo [$word] [$rest]\n;

?

But then yours is more concise (though not as concise as the regular
expression). This is just faster. Depends on what you want ;)

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

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



[PHP] Create an EUC-JP encoded file just for download, not to be kept on server

2006-08-09 Thread Dave M G

PHP List,

In the last stage of my current script, I need to take a bunch of data 
from the database and put it into a text file for the user to save to 
their computer and import into an application.


The file being created is just a list of Japanese words and definitions 
delineated by tabs.


The file format should be a text file. Actually, it could also be CSV 
file, since it's tab delineated data.


The application being imported to only accepts EUC-JP encoding for text 
files that include Japanese text, so my data, which is stored in the 
database as UTF-8, will need to be converted to EUC-JP at some point 
along the way to being written to the file.


This file need not ever be stored on the server. In fact, I'd rather it 
not so as to avoid any headaches with permissions settings (which always 
give me a headache, but that's a rant for another day).


So, I'm looking on php.net for functions that would be able to create a 
file out of some data and pass it along to the user.


But it seems that the assumption of all the file functions (that I've 
found) such as fwrite(), fopen(), file(), readfile(), and others are all 
about taking an existing file and working with it. And more importantly, 
all of them seem to assume that the place where the file would be stored 
is on the servers system, and not immediately passed on to the user.


I have a suspicion that this is one of those situations where the 
starting point is assumed to be so simple that no one goes out of their 
way to document or explain it.


I'm too lost to know where to begin.

How do I create a file that the user saves, and is not stored on the server?

--
Dave M G

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



[PHP] script stopped worling

2006-08-09 Thread Ross
This script is meant to download serialized data (array) from the db, 
unserialize it and output it. It has stopped working (not outputing 
anything).

I have been looking at it for an hour and cannot see why! It was working 
earlier on - can you see the mistake?



?
global $submitted, $count, $module1;
include('admin/connect.php');
$link=images/logo_small.gif;
$up= ;



function display_result($module_no) {

if ($module_no != ) {
$module_no =unserialize ($module_no);
foreach ($module_no as $number = $data) {

$count=$count+1;?

Q.?=$count; ?- span style=font-weight:bold?=$data;?/spanBR /
?
}
}

}

$query = SELECT * FROM consultants WHERE username='myuser';

// Execute the query and put results in $result

  $result= mysql_query($query);

  while  ($row = @mysql_fetch_array($result, MYSQL_ASSOC)){

// Get number of rows in $result.
$module1= $row['module1'];
$module2= $row['module2'];
$module3= $row['module3'];
$module4= $row['module4'];
$module5= $row['module5'];
$module6= $row['module6'];
$module7= $row['module7'];

}

?


body
div id=main_box


div id=content_holder

? include ('header.php'); ?



div id=left style=line-height: 180%; text-align:right; color:#99; 
font-weight:boldModule Evaluation Result:/div

div id=right style=padding-left: 5px; 
  div style=padding-left: 10px; padding-top:  0px
span class=red_text/span
table width=326 border=0 cellpadding=0 cellspacing=20
  tr valign=top
td width=162Module 1 Resultsbr /
  br /
?
display_result($module1);?
/td
td width=148Module 2 Resultsbr /
  br /

? display_result($module2);?/td
  /tr
  tr valign=top
tdModule 3 Resultsbr /br /

? display_result($module3);?/td
tdModule 4 Resultsbr /br /

? display_result($module4);?/td
  /tr
  tr valign=top
tdModule 5 Resultsbr /br /

? display_result($module6);?/td
tdModule 6 Resultsbr /br /

? display_result($module4);?/td
  /tr
  tr
tdModule 7 Resultsbr /br /

? display_result($module7);?/td
td/td
  /tr
/table








 

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



[PHP] Best way to get PHP5

2006-08-09 Thread Chris W. Parker
Hello,

Generally (well, actually 100%) I just use whatever version of PHP is
included with a certain distro (Redhat pre-Fedora, Fedora Core, CentOS).
None of the versions I've used have come with PHP5 and I'd really like
to get with the times and use PHP5.

I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some negative
things about it in general (FC5).

I've never compiled PHP myself so admittedly I'm a bit skeered... Is the
recommended path to just go with whatever distro I prefer and then
download PHP5 from php.net and install it myself?



Thanks,
Chris.

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



Re: [PHP] Create an EUC-JP encoded file just for download, not to be kept on server

2006-08-09 Thread Robert Cummings
On Thu, 2006-08-10 at 01:20 +0900, Dave M G wrote:
 PHP List,
 
 In the last stage of my current script, I need to take a bunch of data 
 from the database and put it into a text file for the user to save to 
 their computer and import into an application.
 
 The file being created is just a list of Japanese words and definitions 
 delineated by tabs.
 
 The file format should be a text file. Actually, it could also be CSV 
 file, since it's tab delineated data.
 
 The application being imported to only accepts EUC-JP encoding for text 
 files that include Japanese text, so my data, which is stored in the 
 database as UTF-8, will need to be converted to EUC-JP at some point 
 along the way to being written to the file.
 
 This file need not ever be stored on the server. In fact, I'd rather it 
 not so as to avoid any headaches with permissions settings (which always 
 give me a headache, but that's a rant for another day).
 
 So, I'm looking on php.net for functions that would be able to create a 
 file out of some data and pass it along to the user.
 
 But it seems that the assumption of all the file functions (that I've 
 found) such as fwrite(), fopen(), file(), readfile(), and others are all 
 about taking an existing file and working with it. And more importantly, 
 all of them seem to assume that the place where the file would be stored 
 is on the servers system, and not immediately passed on to the user.
 
 I have a suspicion that this is one of those situations where the 
 starting point is assumed to be so simple that no one goes out of their 
 way to document or explain it.
 
 I'm too lost to know where to begin.
 
 How do I create a file that the user saves, and is not stored on the server?

It's all about the headers... I use the following:

function uploadStream( $filename=null, $csv=null )
{
if( $csv === null )
{
$csv = $this-csv;
}

if( $filename === null )
{
$filename = 'download.csv';
}

header( Content-type: text/csv );
header( Content-disposition: inline; filename=$filename );   

echo $csv;

exit();
}

You can feel free to adapt it since I ripped it out of my CSV writer
service and so it won't work as-is.

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

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



Re: [PHP] Best way to get PHP5

2006-08-09 Thread Jonathan Duncan


On Wed, 9 Aug 2006, Chris W. Parker wrote:


Hello,

Generally (well, actually 100%) I just use whatever version of PHP is
included with a certain distro (Redhat pre-Fedora, Fedora Core, CentOS).
None of the versions I've used have come with PHP5 and I'd really like
to get with the times and use PHP5.

I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some negative
things about it in general (FC5).

I've never compiled PHP myself so admittedly I'm a bit skeered... Is the
recommended path to just go with whatever distro I prefer and then
download PHP5 from php.net and install it myself?

Thanks,
Chris.




Yes, I would recommend that.  If you are serious about using PHP for a 
while it would be benefitial to you to understand the installation aspect 
of the language.  If you are comfortable with the command line this should 
be pretty easy for you.  If not it will be a bit harder but still very 
possible.  Here are installation instructions from php.net:


http://www.php.net/manual/en/install.unix.php

Good luck!

Jonathan

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



Re: [PHP] Create an EUC-JP encoded file just for download, not to be kept on server

2006-08-09 Thread Ray Hauge
On Wednesday 09 August 2006 11:20, Dave M G wrote:
 PHP List,

 In the last stage of my current script, I need to take a bunch of data
 from the database and put it into a text file for the user to save to
 their computer and import into an application.

 The file being created is just a list of Japanese words and definitions
 delineated by tabs.

 The file format should be a text file. Actually, it could also be CSV
 file, since it's tab delineated data.

 The application being imported to only accepts EUC-JP encoding for text
 files that include Japanese text, so my data, which is stored in the
 database as UTF-8, will need to be converted to EUC-JP at some point
 along the way to being written to the file.

 This file need not ever be stored on the server. In fact, I'd rather it
 not so as to avoid any headaches with permissions settings (which always
 give me a headache, but that's a rant for another day).

 So, I'm looking on php.net for functions that would be able to create a
 file out of some data and pass it along to the user.

 But it seems that the assumption of all the file functions (that I've
 found) such as fwrite(), fopen(), file(), readfile(), and others are all
 about taking an existing file and working with it. And more importantly,
 all of them seem to assume that the place where the file would be stored
 is on the servers system, and not immediately passed on to the user.

 I have a suspicion that this is one of those situations where the
 starting point is assumed to be so simple that no one goes out of their
 way to document or explain it.

 I'm too lost to know where to begin.

 How do I create a file that the user saves, and is not stored on the
 server?

 --
 Dave M G

For re-encoding to EUC-JP, I would check out the multibyte functions... 
specifically mb_convert_encoding:

http://us2.php.net/manual/en/function.mb-convert-encoding.php

HTH
-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Best way to get PHP5

2006-08-09 Thread Ray Hauge
On Wednesday 09 August 2006 12:03, Jonathan Duncan wrote:
 On Wed, 9 Aug 2006, Chris W. Parker wrote:
  Hello,
 
  Generally (well, actually 100%) I just use whatever version of PHP is
  included with a certain distro (Redhat pre-Fedora, Fedora Core, CentOS).
  None of the versions I've used have come with PHP5 and I'd really like
  to get with the times and use PHP5.
 
  I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some negative
  things about it in general (FC5).
 
  I've never compiled PHP myself so admittedly I'm a bit skeered... Is the
  recommended path to just go with whatever distro I prefer and then
  download PHP5 from php.net and install it myself?
 
  Thanks,
  Chris.

 Yes, I would recommend that.  If you are serious about using PHP for a
 while it would be benefitial to you to understand the installation aspect
 of the language.  If you are comfortable with the command line this should
 be pretty easy for you.  If not it will be a bit harder but still very
 possible.  Here are installation instructions from php.net:

 http://www.php.net/manual/en/install.unix.php

 Good luck!

 Jonathan

Also, when compiling it yourself you can specify what extensions you want.  
This allows you to keep your install as minimal as possible for your needs, 
which increases the performance of PHP.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Best way to get PHP5

2006-08-09 Thread Brad Bonkoski



Chris W. Parker wrote:

Hello,

Generally (well, actually 100%) I just use whatever version of PHP is
included with a certain distro (Redhat pre-Fedora, Fedora Core, CentOS).
None of the versions I've used have come with PHP5 and I'd really like
to get with the times and use PHP5.

I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some negative
things about it in general (FC5).

I've never compiled PHP myself so admittedly I'm a bit skeered... Is the
recommended path to just go with whatever distro I prefer and then
download PHP5 from php.net and install it myself?



Thanks,
Chris.
  
Build PHP from sourceno reason to be scared, it really is quite 
painless, and the docs are fairly easy to follow.
(and I *believe* php 5.1.2 has some security issues, as well as none of 
the nice updates for the Oracle driver if you are using Oracle, so go 
with 5.1.4)


-Brad

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



[PHP] create multidimensional array with n depth

2006-08-09 Thread Gunter Sammet
Hi all:
I've been trying to create a multidimensional array with n depth in php. 
Tried to use a recursive function passing array references by pointers but 
seems like it's not possible or I still don't understand this subject 
enough. Finally managed to get it going using the eval function. The code 
below converts a seperated string into a multi dimensional array with n 
depth:

e.g. $array['1_20-2_16-7_14'] = 12 will become 
$eval_array[1][20][2][16][7][14] = 12

  foreach(array_keys($this-quantity_array) AS $key){
if($this-quantity_array[$key]  0){
  $combinations = explode('-', $key);
  $eval_string = '$eval_array';
  foreach(array_keys($combinations) AS $key2){
$option_key_value = explode('_', $combinations[$key2]);
$eval_string .= 
'['.$option_key_value[0].']['.$option_key_value[1].']';
  }
  $eval_string .= ' = '.$this-quantity_array[$key].';';
  eval($eval_string);
}
  }

Using eval() for it seems a bit expensive to me. So I've been wondering if 
there is an easier way?
TIA

Gunter 

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



Re: [PHP] Best way to get PHP5

2006-08-09 Thread Jack Gates
On Wednesday 09 August 2006 12:02, Chris W. Parker wrote:
 I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some
 negative things about it in general (FC5).

What sort of negative things have you heard in general about (FC5)?

-- 
Jack Gates http://www.morningstarcom.net/

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



Re: [PHP] Best way to get PHP5

2006-08-09 Thread Jochem Maas
Chris W. Parker wrote:
 Hello,
 
 Generally (well, actually 100%) I just use whatever version of PHP is
 included with a certain distro (Redhat pre-Fedora, Fedora Core, CentOS).
 None of the versions I've used have come with PHP5 and I'd really like
 to get with the times and use PHP5.
 
 I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some negative
 things about it in general (FC5).
 
 I've never compiled PHP myself so admittedly I'm a bit skeered... Is the
 recommended path to just go with whatever distro I prefer and then
 download PHP5 from php.net and install it myself?

roll your own - it's easy enough, and once you have mastered it you'll have a
warm fuzzy feeling - when you initially get start you might
run into a bit of trouble with regard to required libs/developer files needed
by certain extensions that are not installed (use your fav package manager to
grab those) but the basic premise is this (at the cmdline):

$ mkdir ~/some-work-dir
$ cd ~/some-work-dir
$ wget http://nl2.php.net/get/php-5.1.4.tar.gz/from/this/mirror
$ tar -xvvf php-5.1.4.tar.gz
$ cd ./php-5.1.4
$ ./configure
$ make
$ make test
$ make install

you now have a basic php build on your system

1. you can skip 'make test'
2. if in doubt do 'make clean' before 'make'
3. rinse and repeat 'configure', 'make', 'make install' as required
4. do './configure --help' to see all the options you can pass to configure
5. get stuck with a configure option (for instance enabling GD) come back here 
:-)



 
 
 
 Thanks,
 Chris.ne`qc   
 

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



Re: [PHP] create multidimensional array with n depth

2006-08-09 Thread Jochem Maas
Gunter Sammet wrote:
 Hi all:
 I've been trying to create a multidimensional array with n depth in php. 
 Tried to use a recursive function passing array references by pointers but 
 seems like it's not possible or I still don't understand this subject 
 enough. Finally managed to get it going using the eval function. The code 
 below converts a seperated string into a multi dimensional array with n 
 depth:
 
 e.g. $array['1_20-2_16-7_14'] = 12 will become 
 $eval_array[1][20][2][16][7][14] = 12
 
   foreach(array_keys($this-quantity_array) AS $key){
 if($this-quantity_array[$key]  0){
   $combinations = explode('-', $key);
   $eval_string = '$eval_array';
   foreach(array_keys($combinations) AS $key2){
 $option_key_value = explode('_', $combinations[$key2]);
 $eval_string .= 
 '['.$option_key_value[0].']['.$option_key_value[1].']';
   }
   $eval_string .= ' = '.$this-quantity_array[$key].';';
   eval($eval_string);

the following 5 lines were contributed by my 2 yo.

   1112`11q\|  `1@
]1


qA|]
]A||z\'\'sas
}
   }

something like (I use a simalar technique to
manage 'namespaced' data stored in $_SESSION):

// input
$array = array(
1_20-2_16-7_14 = 12,
1_20-1_17-5_12 = 13,
1_20-0_18-3_11 = 12,
);
// output
$ML= array();
//process
foreach ($array as $keys = $val) {
// grab a ref to the root of the output array
$tmp  = $ML;
// get keys we want to build from - hackish but will do for this example
$keys = explode(_, str_replace(-,_,trim($keys)));
// build from the list of keys
foreach ($keys as $k) {
if (!isset($tmp[$k]))
$tmp[$k] = array();
$tmp = $tmp[$k];
}
// stick the value into the deepest array.
$tmp = $val;
}
// display output
var_dump($ML);

 
 Using eval() for it seems a bit expensive to me. So I've been wondering if 

indeed - if your using eval() then there is pretty much always a better way;
unless there isn't and then you probably don't need any help from this list :-)

 there is an easier way?

dunno, but there is usually a highway. ;-

 TIA
 
 Gunter 
 

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



[PHP] Job Posting

2006-08-09 Thread Brent Meshier
Is it appropriate to post jobs on this list?  I have many PHP Developer
positions available.

Brent Meshier
Director IT Operations
Global Transport Logistics
Garcia  Co Fulfillment
http://www.garcia-co.com/
(877) 257-SHIP ext 23

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



[PHP] LAMP Developer Needed - Indianapolis

2006-08-09 Thread Brent Meshier
MST Group, a rapidly growing marketing services firm located on the
northwest side of Indianapolis, is seeking an innovative and hard-working
person to become a key player on our talented and successful team. MST Group
is a leader in providing our world class Business-To-Business clients with
lead management services, customer database development, direct marketing
programs, web design processes and market research.

In this role, you would be involved in maintaining and continually enhancing
the functionality of our web based sales force lead management application.

Requirements

- Bachelor's degree in computer science or equivalent.
- At least 3 years in MySQL, PHP and PERL
- Basic knowledge of Linux server environment
- Object oriented design and development
- Team lead or project supervisory experience preferred
- Good verbal and written communication skills required
- Ability to meet aggressive deadlines and juggling multiple priorities
- Familiar with code revision tools such as CVS or SVN

Description

- Monitors and enforces coding standards and acts effectively as a team
leader
- Produces, refactors, tests, and documents program code
- Counsels management on the implications of new or revised systems
- Database administration, including design/data-mining/analysis
- Develop and maintain existing web based applications on the LAMP platform

MST Group is prepared to offer the selected candidate a competitive
compensation package including health and dental.

This is a permanent, in-house position at our Indianapolis, Indiana
location. No freelance, telecommuting or contract inquiries please. Please
be prepared to provide live URL's or screenshots of complex web applications
and sample code for review. Relocation assistance available.

Qualified candidates should e-mail their resume (Word, PDF, or Plain text
preferred) to [EMAIL PROTECTED]  

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



RE: [PHP] Best way to get PHP5

2006-08-09 Thread Chris W. Parker
Jochem Maas mailto:[EMAIL PROTECTED]
on Wednesday, August 09, 2006 11:05 AM said:

[snip useful stuff]

 1. you can skip 'make test'
 2. if in doubt do 'make clean' before 'make'
 3. rinse and repeat 'configure', 'make', 'make install' as required
 4. do './configure --help' to see all the options you can pass to
 configure 
 5. get stuck with a configure option (for instance enabling GD) come
 back here :-)

Thanks Jochem. That's exactly what I'll do! :)



Chris.

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



RE: [PHP] Job Posting

2006-08-09 Thread Jay Blanchard
[snip] Is it appropriate to post jobs on this list?  I have many PHP
Developer positions available.
[/snip]

Sure, or a link

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



Re: [PHP] create multidimensional array with n depth

2006-08-09 Thread tg-php
My brain is really fried right now and I'm sure someone has a more indepth 
answer/opinion on this subject, but it occurs to me that you can get away from 
using eval() if you do some kind of recursive function using:

$temp[] = array($arrval1, $arrval2,...);


and $arrval1 could == array($arr2val1, $arr2val2,...);


using the [] syntax and/or assigning arrays to other array value positions 
could do what you want it to do if you can work out the resursive 
functionality.  No need to use strings and eval() all over the place.

Sorry my head's not up to resursion right now..  plus I never did have as 
intuitive of a feel for it as I'd ever have liked (understand the concept and 
can grok other people's stuff, but never bothered writing any of my own);

Maybe that's a nudge in the right direction while the others finish lunch or 
coffee or whatever.

-TG

= = = Original message = = =

Hi all:
I've been trying to create a multidimensional array with n depth in php. 
Tried to use a recursive function passing array references by pointers but 
seems like it's not possible or I still don't understand this subject 
enough. Finally managed to get it going using the eval function. The code 
below converts a seperated string into a multi dimensional array with n 
depth:

e.g. $array['1_20-2_16-7_14'] = 12 will become 
$eval_array[1][20][2][16][7][14] = 12

  foreach(array_keys($this-quantity_array) AS $key)
if($this-quantity_array[$key]  0)
  $combinations = explode('-', $key);
  $eval_string = '$eval_array';
  foreach(array_keys($combinations) AS $key2)
$option_key_value = explode('_', $combinations[$key2]);
$eval_string .= 
'['.$option_key_value[0].']['.$option_key_value[1].']';
  
  $eval_string .= ' = '.$this-quantity_array[$key].';';
  eval($eval_string);

  

Using eval() for it seems a bit expensive to me. So I've been wondering if 
there is an easier way?
TIA

Gunter 


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

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



[PHP] script stopped working 2..

2006-08-09 Thread Ross

My previous post said the script stopped working but it actually only fails 
on the remote host, it works fine on localhost

Does unserialize()  only work after a certain version of php?

The phpinfo() is here...

http://legalservicestraining.co.uk/test/info.php 

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



Re: [PHP] Job Posting

2006-08-09 Thread Jochem Maas
Jay Blanchard wrote:
 [snip] Is it appropriate to post jobs on this list?  I have many PHP
 Developer positions available.
 [/snip]
 
 Sure, or a link

not that Jay's up for doing any work anymore - he's a director these days ;-)

 

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



Re: [PHP] Job Posting

2006-08-09 Thread John Nichel

Jochem Maas wrote:

Jay Blanchard wrote:

[snip] Is it appropriate to post jobs on this list?  I have many PHP
Developer positions available.
[/snip]

Sure, or a link


not that Jay's up for doing any work anymore - he's a director these days ;-)



Ah, so that's where Microsoft cronies go to die. :-p

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] script stopped working 2..

2006-08-09 Thread Jochem Maas
Ross wrote:
 My previous post said the script stopped working but it actually only fails 
 on the remote host, it works fine on localhost

stopped working heh? is it plugged in? did a homeless guy move in next to
power unit and accidently unseat the IDE cable? did you p*** of your sys admin?
if you SSH into the remote host it will be localhost - does that fix the 
problem?

'stopped working' can you be anymore vague?

 
 Does unserialize()  only work after a certain version of php?

jeapordy:

1. the thing with the answer in it.**
2. a function used to examine variable contents.***

 
 The phpinfo() is here...

hello phpinfo()

 
 http://legalservicestraining.co.uk/test/info.php 
 

** what is the *** manual?
*** what is the var_dump()?

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



Re: [PHP] LAMP Developer Needed - Indianapolis

2006-08-09 Thread John Nichel

Brent Meshier wrote:
snip

Qualified candidates should e-mail their resume (Word, PDF, or Plain text
preferred) to [EMAIL PROTECTED]  



Where should non-qualified candidates e-mail their resume?

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

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



RE: [PHP] Best way to get PHP5

2006-08-09 Thread Chris W. Parker
Jack Gates mailto:[EMAIL PROTECTED]
on Wednesday, August 09, 2006 10:16 AM said:

 On Wednesday 09 August 2006 12:02, Chris W. Parker wrote:
 I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some
 negative things about it in general (FC5).
 
 What sort of negative things have you heard in general about (FC5)?

Honestly I don't remember. But I've now got a generally negative view of
FC5 versus previous versions (last one I used was 4 I think).

If you're aware of any FUD that's been spread about it, feel free to
speak the truth.



Chris.

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



RE: [PHP] LAMP Developer Needed - Indianapolis

2006-08-09 Thread Jay Blanchard
[snip]
Brent Meshier wrote:
snip
 Qualified candidates should e-mail their resume (Word, PDF, or Plain
text
 preferred) to [EMAIL PROTECTED]  
 

Where should non-qualified candidates e-mail their resume?
[/snip]

To me.

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



Re: [PHP] LAMP Developer Needed - Indianapolis

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 14:45 -0400, John Nichel wrote:
 Brent Meshier wrote:
 snip
  Qualified candidates should e-mail their resume (Word, PDF, or Plain text
  preferred) to [EMAIL PROTECTED]  
  
 
 Where should non-qualified candidates e-mail their resume?

Isn't it obvious??

[EMAIL PROTECTED]

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

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



RE: [PHP] LAMP Developer Needed - Indianapolis

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 14:27 -0500, Jay Blanchard wrote:
 [snip]
 Brent Meshier wrote:
 snip
  Qualified candidates should e-mail their resume (Word, PDF, or Plain
 text
  preferred) to [EMAIL PROTECTED]  
  
 
 Where should non-qualified candidates e-mail their resume?
 [/snip]
 
 To me.

Hahah, your post arrived before mine.

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

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



Re: [PHP] LAMP Developer Needed - Indianapolis

2006-08-09 Thread John Nichel

Jay Blanchard wrote:

[snip]
Brent Meshier wrote:
snip

Qualified candidates should e-mail their resume (Word, PDF, or Plain

text
preferred) to [EMAIL PROTECTED]  



Where should non-qualified candidates e-mail their resume?
[/snip]

To me.



Silly me.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] create multidimensional array with n depth

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 14:14 -0400, [EMAIL PROTECTED] wrote:
 My brain is really fried right now and I'm sure someone has a more indepth 
 answer/opinion on this subject, but it occurs to me that you can get away 
 from using eval() if you do some kind of recursive function using:
 
 $temp[] = array($arrval1, $arrval2,...);
 
 
 and $arrval1 could == array($arr2val1, $arr2val2,...);
 
 
 using the [] syntax and/or assigning arrays to other array value positions 
 could do what you want it to do if you can work out the resursive 
 functionality.  No need to use strings and eval() all over the place.
 
 Sorry my head's not up to resursion right now..  plus I never did have as 
 intuitive of a feel for it as I'd ever have liked (understand the concept and 
 can grok other people's stuff, but never bothered writing any of my own);
 
 Maybe that's a nudge in the right direction while the others finish lunch or 
 coffee or whatever.
 
 -TG
 
 = = = Original message = = =
 
 Hi all:
 I've been trying to create a multidimensional array with n depth in php. 
 Tried to use a recursive function passing array references by pointers but 
 seems like it's not possible or I still don't understand this subject 
 enough. Finally managed to get it going using the eval function. The code 
 below converts a seperated string into a multi dimensional array with n 
 depth:
 
 e.g. $array['1_20-2_16-7_14'] = 12 will become 
 $eval_array[1][20][2][16][7][14] = 12
 
   foreach(array_keys($this-quantity_array) AS $key)
 if($this-quantity_array[$key]  0)
   $combinations = explode('-', $key);
   $eval_string = '$eval_array';
   foreach(array_keys($combinations) AS $key2)
 $option_key_value = explode('_', $combinations[$key2]);
 $eval_string .= 
 '['.$option_key_value[0].']['.$option_key_value[1].']';
   
   $eval_string .= ' = '.$this-quantity_array[$key].';';
   eval($eval_string);
 
   
 
 Using eval() for it seems a bit expensive to me. So I've been wondering if 
 there is an easier way?

Yep, that's pretty bad use of eval()  :) Instead use recursion or a
sliding reference:

?php
   
$key = '1_20-2_16-7_14';
$val = 12;

$bits = split( '_|-', $key );
$nested = array();
$ref = $nested;
$lastref = null;

foreach( $bits as $bit )
{
$lastRef = $ref;

$ref[$bit] = array();
$ref = $ref[$bit];
}
 
if( $lastRef === null )
{
$nested = $val;
}
else
{
$lastRef[$bit] = $val;
}
 
print_r( $nested );

?

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

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



RE: [PHP] LAMP Developer Needed - Indianapolis

2006-08-09 Thread Jay Blanchard
[snip]
  Qualified candidates should e-mail their resume (Word, PDF, or Plain
 text
  preferred) to [EMAIL PROTECTED]  
  
 
 Where should non-qualified candidates e-mail their resume?
 [/snip]
 
 To me.

Hahah, your post arrived before mine.
[/snip]

What is scary is that we are all on the same wavelength.

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



RE: [PHP] Job Posting

2006-08-09 Thread Jay Blanchard
[snip]
 Sure, or a link
 
 not that Jay's up for doing any work anymore - he's a director these
days ;-)
 

Ah, so that's where Microsoft cronies go to die. :-p
[/snip]

Yep...they make them management.

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



Re: [PHP] Job Posting

2006-08-09 Thread John Nichel

Jay Blanchard wrote:

[snip]

Sure, or a link

not that Jay's up for doing any work anymore - he's a director these

days ;-)

Ah, so that's where Microsoft cronies go to die. :-p
[/snip]

Yep...they make them management.




Sorry to hear about your demotion.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

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



[PHP] script stopped working- no output from unserialize()

2006-08-09 Thread Ross
So,

When I echo out the results from the db I get the serialized data but when I 
try and pass the serialized data to the function to unserialize the output 
it doesn't work - no output what-so-ever. Also when the serialized data is 
sent to the function and then echoed out before it is unserialized() I get 
the expected result .- eg 
a:4:{i:0;s:4:pass;i:1;s:4:pass;i:2;s:4:pass;

Which leads me to believe that the problem is with the php function 
unserialize().

The same function works fine locally. I am working with php version 5 
locally and version 4.4.2 on the remote host Could that be the problem?


R.

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



[PHP] Comment form spammer

2006-08-09 Thread Micky Hulse

Hi,

Recently, a client of mine was getting a ton of spam email from a site 
called hotbox.com. I updated her form to one with more spam security, 
but she is still receiving junk email.


Anyone feel like sharing code snippets that will help beef-up spam 
protection for a contact script?


Do you all enable a CAPTCHA system?

Here is what I am currently using in my contact form script to protect 
from spam:




# Error text:
$no_go = 'Forbidden - You are not authorized to view this page!';

# First, make sure the form was posted from a browser.
# For basic web-forms, we don't care about anything other than requests 
from a browser:

if(!isset($_SERVER['HTTP_USER_AGENT'])) { die($no_go); exit(); }
# Make sure the form was indeed POST'ed (requires your html form to use 
action=post):

if(!$_SERVER['REQUEST_METHOD'] == POST) { die($no_go); exit(); }
# Host names from where the form is authorized to be posted from:
$auth_hosts = array(site1.com, site2.com);
# Where have we been posted from?
$from_array = parse_url(strtolower($_SERVER['HTTP_REFERER']));
# Test to see if the $from_array used www to get here.
$www_used = strpos($from_array['host'], www.);
# Make sure the form was posted from an approved host name:
if(!in_array(($www_used === false ? $from_array['host'] : 
substr(stristr($from_array['host'], '.'), 1)), $auth_hosts)) {

//log_bad_request();
header(HTTP/1.0 403 Forbidden);
exit();
}
# Attempt to defend against header injections:
$bad_strings = array(Content-Type:, MIME-Version:, 
Content-Transfer-Encoding:, bcc:, cc:);
# Loop through each POST'ed value and test if it contains one of the 
$bad_strings:

foreach($_POST as $k = $v) {
foreach($bad_strings as $v2) {
if(strpos($v, $v2) !== false) {
log_bad_request();
header(HTTP/1.0 403 Forbidden);
exit();
}
}
}
# Made it past spammer test, free up some memory and continue rest of 
script:

unset($k, $v, $v2, $bad_strings, $auth_hosts, $from_array, $www_used);

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



Re: [PHP] script stopped working- no output from unserialize()

2006-08-09 Thread Jochem Maas
Ross wrote:
 So,
 
 When I echo out the results from the db I get the serialized data but when I 
 try and pass the serialized data to the function to unserialize the output 
 it doesn't work - no output what-so-ever. Also when the serialized data is 
 sent to the function and then echoed out before it is unserialized() I get 
 the expected result .- eg 
 a:4:{i:0;s:4:pass;i:1;s:4:pass;i:2;s:4:pass;

php -r 'echo serialize(array(pass,pass,pass));'
a:4:{i:0;s:4:pass;i:1;s:4:pass;i:2;s:4:pass;}

php -r 
'var_dump(unserialize(a:4:{i:0;s:4:\pass\;i:1;s:4:\pass\;i:2;s:4:\pass\;));'
false

what does your serialized value NOT have that mine does?

 
 Which leads me to believe that the problem is with the php function 
 unserialize().

looks to me like you are giving unserialize() a borked string and it's giving
you boolean false in return - that's a fair swap in my book.

 
 The same function works fine locally. I am working with php version 5 
 locally and version 4.4.2 on the remote host Could that be the problem?

you can rule it out until you can rule it out.

 
 
 R.
 

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



Re: [PHP] script stopped working- no output from unserialize()

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 21:06 +0100, Ross wrote:
 So,
 
 When I echo out the results from the db I get the serialized data but when I 
 try and pass the serialized data to the function to unserialize the output 
 it doesn't work - no output what-so-ever. Also when the serialized data is 
 sent to the function and then echoed out before it is unserialized() I get 
 the expected result .- eg 
 a:4:{i:0;s:4:pass;i:1;s:4:pass;i:2;s:4:pass;
 
 Which leads me to believe that the problem is with the php function 
 unserialize().
 
 The same function works fine locally. I am working with php version 5 
 locally and version 4.4.2 on the remote host Could that be the problem?

There are incompatibilities between 4 and 5 with respect to unserialize,
though I thought it was forward incompatibility and not backward. For
instance PHP didn't mind unserializing integer keys that were denoted as
strings, whereas PHP 5 would choke unless the key was serialized
specifically as an integer when all it contained was integer digits. I
don't know what your exact problem is, but it could be an
incompatibility issue. Also PHP5 may have added extra datatypes or
magic to the serialization process that PHP4 may not recognize. Maybe
turn your error logging to max to see if you get an error message
indicating corruption.

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

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



[PHP] Re: Best way to get PHP5

2006-08-09 Thread Colin Guthrie

Chris W. Parker wrote:

Hello,

Generally (well, actually 100%) I just use whatever version of PHP is
included with a certain distro (Redhat pre-Fedora, Fedora Core, CentOS).


For my work, I build PHP 5.1.2 for CentOS 4.3. I'd be happy to share the 
SRC or the built RPMs with you if that saves you some time? The same 
SRPM would probably build happily on FC4/5... maybe ;)


Just drop me a mail.

Col.

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



RE: [PHP] Best way to get PHP5

2006-08-09 Thread Jonathan Duncan


On Wed, 9 Aug 2006, Chris W. Parker wrote:


Jack Gates mailto:[EMAIL PROTECTED]
   on Wednesday, August 09, 2006 10:16 AM said:


On Wednesday 09 August 2006 12:02, Chris W. Parker wrote:

I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some
negative things about it in general (FC5).


What sort of negative things have you heard in general about (FC5)?


Honestly I don't remember. But I've now got a generally negative view of
FC5 versus previous versions (last one I used was 4 I think).

If you're aware of any FUD that's been spread about it, feel free to
speak the truth.



If you want to really learn Linux, try Gentoo.  If you just want a very 
good and easy to use Linux, go with SuSE.


Jonathan

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



Re: [PHP] Best way to get PHP5

2006-08-09 Thread Jochem Maas
Jonathan Duncan wrote:
 
 On Wed, 9 Aug 2006, Chris W. Parker wrote:
 
 Jack Gates mailto:[EMAIL PROTECTED]
on Wednesday, August 09, 2006 10:16 AM said:

 On Wednesday 09 August 2006 12:02, Chris W. Parker wrote:
 I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some
 negative things about it in general (FC5).

 What sort of negative things have you heard in general about (FC5)?

 Honestly I don't remember. But I've now got a generally negative view of
 FC5 versus previous versions (last one I used was 4 I think).

 If you're aware of any FUD that's been spread about it, feel free to
 speak the truth.

 
 If you want to really learn Linux, try Gentoo.  If you just want a very
 good and easy to use Linux, go with SuSE.

sane words. debian is a good alterative to Gentoo (and there's Ubuntu which is a
more userfriendly derivative of debian).

personally I prefer eating razor blade than using something from redhat - I have
never used FC but if it's anything like RedHat Enterprise Server then I'd only 
use
as a bookend (if at all) if I were you. ;-)

FUD-tastic!

 
 Jonathan
 

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



[PHP] List Meeting NNOT

2006-08-09 Thread Jay Blanchard
Here is a thought that a couple of us have shared off-list; why don't we
list denizens plan a get together? A face-to-face with the good, the bad
and the ugly. A mano y' mano curly brace holy war. Beers and meat. The
whole 9.2 Mb's.

So, what say you? Shall we start a more formal process? Set a date and a
place some time in the near (6 mos. or so) future? All are welcome, from
the newest of new to the crotchitiest of old.

Double-dog dare you.

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



Re: [PHP] List Meeting NNOT

2006-08-09 Thread Richard Lynch
On Wed, August 9, 2006 6:26 pm, Jay Blanchard wrote:
 Here is a thought that a couple of us have shared off-list; why don't
 we
 list denizens plan a get together? A face-to-face with the good, the
 bad
 and the ugly. A mano y' mano curly brace holy war. Beers and meat. The
 whole 9.2 Mb's.

 So, what say you? Shall we start a more formal process? Set a date and
 a
 place some time in the near (6 mos. or so) future? All are welcome,
 from
 the newest of new to the crotchitiest of old.

 Double-dog dare you.

Isn't that what the conferences are for???

I'm happy to host a small get-together in Chicago...

I'll throw in a couple kegs of beer and some munchies at Uncommon
Ground where I work. :-)
http://uncommonground.com/

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

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



Re: [PHP] Best way to get PHP5

2006-08-09 Thread Jack Gates
On Wednesday 09 August 2006 19:24, Jochem Maas wrote:
 Jonathan Duncan wrote:
  On Wed, 9 Aug 2006, Chris W. Parker wrote:
  Jack Gates mailto:[EMAIL PROTECTED]
 
 on Wednesday, August 09, 2006 10:16 AM said:
  On Wednesday 09 August 2006 12:02, Chris W. Parker wrote:
  I know that Fedora Core 5 offers PHP 5.1.2 but I've heard some
  negative things about it in general (FC5).
 
  What sort of negative things have you heard in general about
  (FC5)?
 
  Honestly I don't remember. But I've now got a generally negative
  view of FC5 versus previous versions (last one I used was 4 I
  think).
 
  If you're aware of any FUD that's been spread about it, feel
  free to speak the truth.
 
  If you want to really learn Linux, try Gentoo.  If you just want
  a very good and easy to use Linux, go with SuSE.

 sane words. debian is a good alterative to Gentoo (and there's
 Ubuntu which is a more userfriendly derivative of debian).

 personally I prefer eating razor blade than using something from
 redhat - I have never used FC but if it's anything like RedHat
 Enterprise Server then I'd only use as a bookend (if at all) if I
 were you. ;-)

 FUD-tastic!

  Jonathan

Chris,

Jochem just proved what I said earlier.

Every one has their own preference and some go so far as to claim that 
the ones they just don't like are evil.  That is why there are so 
many different flavors of Linux.  That is also what will continue to 
hold Linux back in the market place and allow the truly evil OS to 
hold there market share on the desktop.

 personally I prefer eating razor blades to using something from
 Redmond Washington

-- 
Jack Gates http://www.morningstarcom.net/

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



RE: [PHP] Best way to get PHP5

2006-08-09 Thread Chris W. Parker
Jonathan Duncan mailto:[EMAIL PROTECTED]
on Wednesday, August 09, 2006 3:55 PM said:

 If you want to really learn Linux, try Gentoo.  If you just want a
 very good and easy to use Linux, go with SuSE.

To keep this related to the question I asked...

Do either of the latest builds of these distros have PHP5?


Thanks,
Chris.

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



Re: [PHP] question about how php handles post'd and get'd data

2006-08-09 Thread Ligaya Turmelle

tedd wrote:

At 10:27 AM +1000 8/9/06, Ligaya Turmelle wrote:


jonathan wrote:

i was having a conversation and was wondering where in the source 
code for php is the process for writing get'd and post'd data to 
their corresponding arrays? Also, is there a way to view the source 
code online?


thanks,

jonathan

PHP's cvs is available online at 
http://cvs.php.net/viewvc.cgi/php-src/.  Drill down far enough and you 
will get the source code.


Ex:
http://cvs.php.net/viewvc.cgi/php-src/main/fopen_wrappers.c?revision=1.183view=markup 





Damn, that's a lot of GET.

Where's the reference(s) for how to add your own code? Sorry, I haven't 
a clue as to where to look.


tedd
there are instructions to get the cvs download at - 
http://www.php.net/anoncvs.php  For how to submit your code for the 
internals - join the internals mailing list and submit the patch.  They 
will look it over (maybe suggest alterations) and decide whether to add 
it or not.  If you want a bit more information on how the internals work 
- check out Sara Golemon's book Extending and Embedding PHP as well as 
http://lxr.php.net/


Hope that helps.

--

life is a game... so have fun.

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

RE: [PHP] List Meeting NNOT

2006-08-09 Thread Jay Blanchard
[snip]
Isn't that what the conferences are for???

I'm happy to host a small get-together in Chicago...

I'll throw in a couple kegs of beer and some munchies at Uncommon
Ground where I work. :-)
http://uncommonground.com/
[/snip]

Yes, but not everyone can get to or goes to conferences. And this would
stand on its own don'tcha think? I think that Chicago is perfect,
because it is centrally located (kinda') and a neat place to boot.

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



RE: [PHP] List Meeting NNOT

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 18:54 -0500, Jay Blanchard wrote:
 [snip]
 Isn't that what the conferences are for???
 
 I'm happy to host a small get-together in Chicago...
 
 I'll throw in a couple kegs of beer and some munchies at Uncommon
 Ground where I work. :-)
 http://uncommonground.com/
 [/snip]
 
 Yes, but not everyone can get to or goes to conferences. And this would
 stand on its own don'tcha think? I think that Chicago is perfect,
 because it is centrally located (kinda') and a neat place to boot.

Sounds like fun, what kind of timeline are you imagining?

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

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



RE: [PHP] List Meeting NNOT

2006-08-09 Thread Jay Blanchard
[snip]
 [snip]
 Isn't that what the conferences are for???
 
 I'm happy to host a small get-together in Chicago...
 
 I'll throw in a couple kegs of beer and some munchies at Uncommon
 Ground where I work. :-)
 http://uncommonground.com/
 [/snip]
 
 Yes, but not everyone can get to or goes to conferences. And this
would
 stand on its own don'tcha think? I think that Chicago is perfect,
 because it is centrally located (kinda') and a neat place to boot.

Sounds like fun, what kind of timeline are you imagining?
[/snip]

Sometime in the next 6 months

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



Re: [PHP] Comment form spammer

2006-08-09 Thread Richard Lynch
On Wed, August 9, 2006 3:17 pm, Micky Hulse wrote:
 Recently, a client of mine was getting a ton of spam email from a site
 called hotbox.com. I updated her form to one with more spam security,
 but she is still receiving junk email.

If you are not already, PLEASE make sure that any headers you pass in
to mail(), including the to, subject, and headers args (1, 2,
and 4 args) do *NOT* have any newlines in the user-input data.

Cuz if you ain't doing that, you're not just letting them spam your
client, but also letting them inject spam to ALL OF US!

Don't do that. :-)

 Anyone feel like sharing code snippets that will help beef-up spam
 protection for a contact script?

I also just trash anybody trying to send HTML enhanced (cough,
cough) email through the website form -- You KNOW only a spammer is
going to sit there and type HTML into an email form on a website.

if (strip_tags($body) != $body) { die(spammer); }

 Do you all enable a CAPTCHA system?

I did on one site that was just getting pounded -- Actually it was a
guestbook with site-owner approval, so the junk never went public, but
that didn't stop the automated spammers from trying anyway, and the
client sure didn't want to scroll through hundreds of posts to find
the one real one.  Sigh.

I *hate* CAPTCHA for various reasons, but I was stuck for any other
solution that would stop the junk...

YMMV

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

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



Re: [PHP] problem with quotes (single and double) in forms

2006-08-09 Thread Chris

[EMAIL PROTECTED] wrote:

Hi to all.

Have a web site on server where magic quote is turned On. Because of
problems with quotes within forms, I was thinking to turn it Off. I wonder
how much work I'll have to change code to accept new setting? Are we
talking about major changes or something that could be done in day or two
(the site has few couple-pages long forms and about 10 regular contact
us/register/edit membership/edit account/... forms)?


Copy it to a server where magic quotes is off and see what breaks. That 
will give you an idea of what needs fixing.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Comment form spammer

2006-08-09 Thread Micky Hulse

Quick note to Kevin Waterson:

Hehe, I think all this talk about spam sent my response to your reply 
into your spam filter... I got a bounce back. Thanks for help though... 
let me know if there is any way I can re-send the email without a 
bounce-back.


Richard Lynch wrote:

If you are not already, PLEASE make sure that any headers you pass in
to mail(), including the to, subject, and headers args (1, 2,
and 4 args) do *NOT* have any newlines in the user-input data.


Sounds good to me. Thanks for pointing that out.

I just found this link:

*Form Post Hijacking*
http://www.anders.com/projects/sysadmin/formPostHijacking/

Looks like the above article mentions the same thing and proposes this 
as a fix:


$_POST['email'] = preg_replace(/\r/, , $_POST['email']); 
$_POST['email'] = preg_replace(/\n/, , $_POST['email']);


This is another good one:

*Email Injection*
http://www.securephpwiki.com/index.php/Email_Injection


Cuz if you ain't doing that, you're not just letting them spam your
client, but also letting them inject spam to ALL OF US!
Don't do that. :-)


Man, spammers suck! I just had someone take over my own domain a 
couple weeks ago... thank god for Spam Assassin and Cpanel!  :D



I also just trash anybody trying to send HTML enhanced (cough,
cough) email through the website form -- You KNOW only a spammer is
going to sit there and type HTML into an email form on a website.
if (strip_tags($body) != $body) { die(spammer); }


Ahh, good point. So, with the above line, you are saying:

If the message body stripped of all html tags is not equal to the 
message body, then kill the script? Ah, makes perfect sense... a great 
way to test for html spam. Thanks for sharing!   :D



Do you all enable a CAPTCHA system?


I did on one site that was just getting pounded -- Actually it was a
guestbook with site-owner approval, so the junk never went public, but
that didn't stop the automated spammers from trying anyway, and the
client sure didn't want to scroll through hundreds of posts to find
the one real one.  Sigh.


Man, that sucks. SMFing spammers. They really are annoying.


I *hate* CAPTCHA for various reasons, but I was stuck for any other
solution that would stop the junk...


Yeah, I would prefer to not setup a CAPTCHA too (although, I would like 
to learn how to script one)... hopefully implementing your (and everyone 
else's) great suggestions will really make my script hard to spam.


Thanks Richard, I really appreciate... you are always very helpful and 
your advice is top-notch.  :)


Cheers,
Micky

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



Re: [PHP] script stopped working- no output from unserialize()

2006-08-09 Thread Richard Lynch
On Wed, August 9, 2006 3:06 pm, Ross wrote:
 When I echo out the results from the db I get the serialized data but
 when I
 try and pass the serialized data to the function to unserialize the
 output
 it doesn't work - no output what-so-ever. Also when the serialized
 data is
 sent to the function and then echoed out before it is unserialized() I
 get
 the expected result .- eg
 a:4:{i:0;s:4:pass;i:1;s:4:pass;i:2;s:4:pass;

This seems to be missing a closing } on the end, from this naive
reader's crude guess at what should be there...

Are you sure the DB text field length is big enough...?

 Which leads me to believe that the problem is with the php function
 unserialize().

 The same function works fine locally. I am working with php version 5
 locally and version 4.4.2 on the remote host Could that be the
 problem?

It's entirely possible that the serialize/unserialize functions
changed the internal data format from 4 to 5, I presume...

Compare the output from 4.4.2 of ?php echo serialize($foo);? and the
same $foo on PHP 5.0 and then see if they are the same.

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

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



Re: [PHP] Comment form spammer

2006-08-09 Thread Micky Hulse

Micky Hulse wrote:
Recently, a client of mine was getting a ton of spam email from a site 
called hotbox.com. I updated her form to one with more spam security, 
but she is still receiving junk email.


Hi all, thanks for the great responses (on/off list). I just realized 
that the spammer is not actually using the form to submit the spam, they 
are using the script directly... duH!


When I updated the form, I did not change the name or remove the old 
script... so she kept receiving tons of spam.


I just commented-out all of the PHP in the old script and added one 
line: die(#%$#@ off!);


Now that that is fixed, time to impliment all of your suggestions for 
making my script better. Thanks all for pointing-out the security holes 
and coding mistakes.


:: pats all who helped on back ::

You guys/gals rock!

Cheers,
Micky

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



Re: [PHP] problem with quotes (single and double) in forms

2006-08-09 Thread J R

try to use this few lines of code.

function stripMagicQuotes($var)
{
   if (get_magic_quotes_gpc()) {
   $var= stripslashes($var);
   }
   return $var;
}

this way you don't really have to worry if magic quotes is on or off.
**

On 8/10/06, Chris [EMAIL PROTECTED] wrote:


[EMAIL PROTECTED] wrote:
 Hi to all.

 Have a web site on server where magic quote is turned On. Because of
 problems with quotes within forms, I was thinking to turn it Off. I
wonder
 how much work I'll have to change code to accept new setting? Are we
 talking about major changes or something that could be done in day or
two
 (the site has few couple-pages long forms and about 10 regular contact
 us/register/edit membership/edit account/... forms)?

Copy it to a server where magic quotes is off and see what breaks. That
will give you an idea of what needs fixing.

--
Postgresql  php tutorials
http://www.designmagick.com/

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





--
GMail Rocks!!!


Re: [PHP] Create an EUC-JP encoded file just for download, not to be kept on server

2006-08-09 Thread Richard Lynch
On Wed, August 9, 2006 11:20 am, Dave M G wrote:
 How do I create a file that the user saves, and is not stored on the
 server?

http://richadlynch.blogger.com

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

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



Re: [PHP] Create an EUC-JP encoded file just for download, not to be kept on server

2006-08-09 Thread Dave M G

Robert, Ray, Richard,

Thank you all for responding with helpful advice.

Robert said:
It's all about the headers... 
header( Content-type: text/csv );
header( Content-disposition: inline; filename=$filename ); 


Ah... that's something I think I never would have figured out with the 
manual alone. Now that I know, it seems super easy.


Thanks to everyone - those who responded directly as well as the PHP 
list in general.


With the right regular expressions and file handling mechanisms in 
place, I now have a script that does everything I set out for it to do.


Everyone's time and expertise is very much appreciated.

--
Dave M G

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



Re: [PHP] Comment form spammer

2006-08-09 Thread Micky Hulse

Micky Hulse wrote:
I just commented-out all of the PHP in the old script and added one 
line: die(#%$#@ off!);


Actually... is there anything more I can do at this point to fight back? 
 Can I use something better than die()? Or, is it best just to let them 
figure it out and go away?


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



Re: [PHP] problem with quotes (single and double) in forms

2006-08-09 Thread Chris

J R wrote:

try to use this few lines of code.

function stripMagicQuotes($var)
{
   if (get_magic_quotes_gpc()) {
   $var= stripslashes($var);
   }
   return $var;
}

this way you don't really have to worry if magic quotes is on or off.


Then he has to modify all the code to call that function ;)

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] problem with quotes (single and double) in forms

2006-08-09 Thread Chris

Chris wrote:

J R wrote:

try to use this few lines of code.

function stripMagicQuotes($var)
{
   if (get_magic_quotes_gpc()) {
   $var= stripslashes($var);
   }
   return $var;
}

this way you don't really have to worry if magic quotes is on or off.


Then he has to modify all the code to call that function ;)



Hmm actually:

$_POST = stripMagicQuotes($_POST);

should do it I guess.. not exactly ideal but would work quickly.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Dave M G

Robert,

Thank you for responding.


The extra slashes are to properly escape the backslash character since
you are using double quotes
As I said you may want the following pattern in cases where no space
exists:
'#^([^\s]*)\s?(.*)$#'
Thank you for your detailed explanation. Especially with regards to the 
impact of double quotes versus single quotes in an expression. I see now 
that I most likely will find it simpler to use single quotes and avoid 
having to escape characters excessively.


As you might have seen in a response of mine to another of your 
postings, all this advice has come together, and my script now 
accomplishes what I had hoped it would.


Thank you and the PHP list in general for the continued great support.

--
Dave M G

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



Re: [PHP] problem with quotes (single and double) in forms

2006-08-09 Thread J R

here's an improvement jwith recursion:

function stripMagicQuotes($var)
{
   if (get_magic_quotes_gpc()) {
   if(!is_array($var)) {
   $var= stripslashes($var);
   } else {
   array_walk($var, stripMagicQuotes);
   }
   }
   return $var;
}

hth,

john
On 8/10/06, Chris [EMAIL PROTECTED] wrote:


Chris wrote:
 Chris wrote:
 J R wrote:
 try to use this few lines of code.

 function stripMagicQuotes($var)
 {
if (get_magic_quotes_gpc()) {
$var= stripslashes($var);
}
return $var;
 }

 this way you don't really have to worry if magic quotes is on or off.

 Then he has to modify all the code to call that function ;)


 Hmm actually:

 $_POST = stripMagicQuotes($_POST);

 should do it I guess.. not exactly ideal but would work quickly.


Argh, self-replying (*think before hitting send*) :(

Of course that function would need a bit more modification but should be
able to get it recursive without too many problems.

--
Postgresql  php tutorials
http://www.designmagick.com/





--
GMail Rocks!!!


Re: [PHP] problem with quotes (single and double) in forms

2006-08-09 Thread Chris

Chris wrote:

Chris wrote:

J R wrote:

try to use this few lines of code.

function stripMagicQuotes($var)
{
   if (get_magic_quotes_gpc()) {
   $var= stripslashes($var);
   }
   return $var;
}

this way you don't really have to worry if magic quotes is on or off.


Then he has to modify all the code to call that function ;)



Hmm actually:

$_POST = stripMagicQuotes($_POST);

should do it I guess.. not exactly ideal but would work quickly.



Argh, self-replying (*think before hitting send*) :(

Of course that function would need a bit more modification but should be 
able to get it recursive without too many problems.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



RE: [PHP] List Meeting NNOT

2006-08-09 Thread Paul Scott

On Wed, 2006-08-09 at 18:54 -0500, Jay Blanchard wrote:

 Yes, but not everyone can get to or goes to conferences. And this would
 stand on its own don'tcha think? I think that Chicago is perfect,
 because it is centrally located (kinda') and a neat place to boot.
 

Kinda...Chicago is a bit of a drive for us in Cape Town, South
Africa... ;)

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 

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