php-general Digest 12 Apr 2011 01:37:56 -0000 Issue 7269

2011-04-11 Thread php-general-digest-help

php-general Digest 12 Apr 2011 01:37:56 - Issue 7269

Topics (messages 312335 through 312337):

Re: File Upload Problem
312335 by: tedd

Error in variable assignment
312336 by: Ethan Rosenberg

Re: File Upload Problem [SOLVED]
312337 by: tedd

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---

At 7:37 AM +0100 4/11/11, Ashley Sheridan wrote:

tedd tedd.sperl...@gmail.com wrote:

 So, knowing this  -- does anyone have any idea as to what is wrong?

What happens if you diff the various config files involved directly, 
php.ini, https.conf, any other site-specific *.conf files used by 
apache. Sometimes its a security feature in a .conf file that 
means I can override a setting myself in code or in an .htaccess 
file. Takes ages to find and annoying to debug around!


Ash


Ash:

I think that's the problem. I just wanted to bounce this experience 
off the group before making a fool of myself by asking for help at 
the local college where I'm trying to get the script to run. I think 
they have some security protocol in place to prevent this.


Thanks,

tedd

--
---
http://sperling.com/
---End Message---
---BeginMessage---

Dear list -

I an writing a script that will simulate a chess board.  On a move 
from e2 to e6 [see below] the variable in e2 is never assigned to 
e6.  Here are some code snippets:


?php
session_start();
session_name(Chess);
error_reporting(1);
 if ($_SESSION['flag'] != 1)
{
$flag = 1;
echo br /startingbr /;
 $results = array(array(Br, Bn, Bb, Bq, Bk, Bb, Bn, 
Br),array(Bp, Bp, Bp, Bp, Bp, Bp, Bp, Bp),
array(, , , , , , , 
),array(, , , , , , , ),array(, , , , , 
, , ),
array(, , , , , , , 
),array(Wp, Wp, Wp, Wp, Wp, Wp, Wp, Wp),
array(Wr, Wn, Wb, Wq, Wk, Wb, 
Wn, Wr));


$_SESSION['results'] = $results;
for($i = 0; $i 8; $i++)
{
for ($j = 0; $j  8; $j++)
printf(%s , $results[$i][$j]);
printf(br /);
}

$_SESSION[flag] = $flag;

snip

$board = array  //Correlation of input array [chessboard] with 
internal array [results]

(
a8 = $results[0][0],
b8 = $results[0][1],
c8 = $results[0][2],
d8 = $results[0][3],
e8 = $results[0][4],
f8 = $results[0][5],
g8 = $results[0][6],
h8 = $results[0][7],
a7 = $results[1][0],
b7 = $results[1][1],
c7 = $results[1][2],
d7 = $results[1][3],
e7 = $results[1][4],
f7 = $results[1][5],
g7 = $results[1][6],
h7 = $results[1][7],
a6 = $results[2][0],
b6 = $results[2][1],
c6 = $results[2][2],
d6 = $results[2][3],
e6 = $results[2][4],
f6 = $results[2][5],
g6 = $results[2][6],
h6 = $results[2][7],
a5 = $results[3][0],
b5 = $results[3][1],
c5 = $results[3][2],
d5 = $results[3][3],
e5 = $results[3][4],
f5 = $results[3][5],
g5 = $results[3][6],
h5 = $results[3][7],
a4 = $results[4][0],
b4 = $results[4][1],
c4 = $results[4][2],
d4 = $results[4][3],
e4 = $results[4][4],
f4 = $results[4][5],
g4 = $results[4][6],
h4 = $results[4][7],
a3 = $results[5][0],
b3 = $results[5][1],
c3 = $results[5][2],
d3 = $results[5][3],
e3 = $results[5][4],
f3 = $results[5][5],
g3 = $results[5][6],
h3 = $results[5][7],
a2 = $results[6][0],
b2 = $results[6][1],
c2 = $results[6][2],
d2 = $results[6][3],
e2 = $results[6][4],
f2 = $results[6][5],
g2 = $results[6][6],
h2 = $results[6][7],
a1 = $results[7][0],
b1 = $results[7][1],
c1 = $results[7][2],
d1 = $results[7][3],
e1 = $results[7][4],
f1 = $results[7][5],
g1 = $results[7][6],
h1 = $results[7][7],
);


$board2 = array  //Correlation of input array [chessboard] with 
internal array [results]

(
a8 = [0][0],
b8 = [0][1],

Re: [PHP] Re: File Upload Problem

2011-04-11 Thread Louis Huppenbauer
Is there already a file with the same name?
Apparently copy won't overwrite a file on windows if it already exists.

Maybe you have the same problem ffproberen2 at dodgeit dot com had on
the php.net/move_uploaded_file manpage?

2011/4/10 tedd tedd.sperl...@gmail.com:
 At 7:15 AM +0200 4/7/11, Wojciech Kupiec wrote:

 On 06/04/11 19:10, tedd wrote:

 -snip-
 What could be wrong? What should I be looking for?

 If you really want to get help, publish your code.

 I don't think that's true. I should be able to ask a technical question with
 observations and inquire as to What's wrong? After all, what's the point
 of showing code that works on two servers, but fails on a third? Really,
 what is that going to tell you?

 As for the uploaded file exceeding max file size and file_uploads
 enabled, those are obvious and I did that investigation before I posted the
 question. They are NOT the problem.

 I also checked all the servers involved for safe_mode and open_basedir
 settings and they are set the same. Additionally, the upload_max_filesize
 and upload_tmp_dir are also set exactly the same. As such, I don't know
 what else to look for -- hence my question.

 As I said, the script works on two servers, but fails on a third.

 This is what I've learned in addition to the above:

 The script does successfully upload the file to the server in question. For
 example, I receive truth from:

 if(is_uploaded_file($_FILES['userfile']['tmp_name']))
   {
   echo('true');
   }

 I can even get the contents of the uploaded file by:

 $contents = file_get_contents($_FILES['userfile']['tmp_name']);
 echo($contents);

 -- and the contents are displayed.

 So, the file is indeed uploaded!

 What I cannot do is move the file to another location using:

 $result = move_uploaded_file($_FILES['userfile']['tmp_name'], $path . '/' .
 $_FILES['userfile']['name']);

 (Yes, all possible file paths have been investigated)

 Nor, can I copy the file by:

 $result = copy($_FILES['userfile']['tmp_name'], $path . '/' .
 $_FILES['userfile']['name']);

 The only difference I see is the server causing problems is Windows NT
 whereas the others are Linux.

 So, knowing this  -- does anyone have any idea as to what is wrong?

 Cheers,

 tedd

 --
 ---
 http://sperling.com/

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



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



Re: [PHP] Silly question

2011-04-11 Thread Stuart Dallas
On Monday, 11 April 2011 at 02:12, Curtis Maurand wrote:
nevermind. There is a function: fgetcsv();

Ewww!

http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


 Curtis Maurand wrote:
  
  
  Hello,
  I'm trying to run through an apache log
 file in an attempt to
  get all of the user agents.
  
  The question is how do I split the
  string? I can't
 seem to find a workable delimiter. Each
  section of the
 file is enclosed in quotes and that should be helpful, but
  it
 doesn't seem to be. I can't seem to set the delimiter to '
 ' I can't
  seem to find any good
  examples,
 either.
  
  I can't split on spaces, because the user
  agents generally have spaces in them.
  
  I was
 trying to use
  explode. 
 print_r(explode(' ', $line);
  
  Any help
  would be appreciated.
  thanks,
  Curtis
 


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



Re: [PHP] Silly question

2011-04-11 Thread Curtis Maurand


Stuart Dallas wrote:
 On Monday, 11 April 2011 at 02:12, Curtis
Maurand wrote:
 nevermind. There is a function: fgetcsv();
 
 Ewww!

Say what you want, it works.  Your
solution is way more elegant.  regex's are not my strong suit. 
I have to have the regex pocket reference to understand that regex 
that's in there.  However, the fgetcsv breaks it up into a few chunks
and I have to break up the first chunk, but that's space delimited, so its
not so bad.  I'll probably use yours.  Thanks for the class.

 

http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/
 
 -Stuart
 
 --
 Stuart
Dallas
 3ft9 Ltd
 http://3ft9.com/
 


 Curtis Maurand wrote:
 


  Hello,
  I'm trying to run
through an apache log
 file in an attempt to

 get all of the user agents.
 
  The
question is how do I split the
  string? I can't
 seem to find a workable delimiter. Each
 
section of the
 file is enclosed in quotes and that should be
helpful, but
  it
 doesn't seem to be. I
can't seem to set the delimiter to '
 ' I
can't
  seem to find any good
 
examples,
 either.
 
  I
can't split on spaces, because the user
  agents
generally have spaces in them.
 
  I
was
 trying to use
  explode.

print_r(explode(' ', $line);
 

 Any help
  would be appreciated.
 
thanks,
  Curtis

 



Re: [PHP] Silly question

2011-04-11 Thread Stuart Dallas
On Monday, 11 April 2011 at 13:17, Curtis Maurand wrote:
Stuart Dallas wrote:
  On Monday, 11 April 2011 at 02:12, Curtis Maurand wrote:
  nevermind. There is a function: fgetcsv();
  
  Ewww!
 
 Say what you want, it works. Your solution is way more elegant. regex's are 
 not my strong suit. I have to have the regex pocket reference to understand 
 that regex that's in there. However, the fgetcsv breaks it up into a few 
 chunks and I have to break up the first chunk, but that's space delimited, so 
 its not so bad. I'll probably use yours. Thanks for the class.

I'm not a great regex guru either, I googled that - it's not my class.

You can use a hammer to knock in a screw, but when screwdrivers are 
ubiquitously lying around all over the internet, why would you?!

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


  
  http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/
  
  -Stuart
  
  --
  Stuart Dallas
  3ft9 Ltd
  http://3ft9.com/
  
  
   Curtis Maurand wrote:


Hello,
I'm trying to run through an apache log
   file in an attempt to
get all of the user agents.

The question is how do I split the
string? I can't
   seem to find a workable delimiter. Each
section of the
   file is enclosed in quotes and that should be helpful, but
it
   doesn't seem to be. I can't seem to set the delimiter to '
   ' I can't
seem to find any good
examples,
   either.

I can't split on spaces, because the user
agents generally have spaces in them.

I was
   trying to use
explode.
   print_r(explode(' ', $line);

Any help
would be appreciated.
thanks,
Curtis
 


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



Re: [PHP] Silly question

2011-04-11 Thread Richard Quadling
On 11 April 2011 13:23, Stuart Dallas stu...@3ft9.com wrote:
 On Monday, 11 April 2011 at 13:17, Curtis Maurand wrote:
 Stuart Dallas wrote:
  On Monday, 11 April 2011 at 02:12, Curtis Maurand wrote:
  nevermind. There is a function: fgetcsv();
 
  Ewww!

 Say what you want, it works. Your solution is way more elegant. regex's are 
 not my strong suit. I have to have the regex pocket reference to understand 
 that regex that's in there. However, the fgetcsv breaks it up into a few 
 chunks and I have to break up the first chunk, but that's space delimited, 
 so its not so bad. I'll probably use yours. Thanks for the class.

 I'm not a great regex guru either, I googled that - it's not my class.

 You can use a hammer to knock in a screw, but when screwdrivers are 
 ubiquitously lying around all over the internet, why would you?!

 -Stuart

 --
 Stuart Dallas
 3ft9 Ltd
 http://3ft9.com/


 
  http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/
 
  -Stuart
 
  --
  Stuart Dallas
  3ft9 Ltd
  http://3ft9.com/
 
 
   Curtis Maurand wrote:
   
   
Hello,
I'm trying to run through an apache log
   file in an attempt to
get all of the user agents.
   
The question is how do I split the
string? I can't
   seem to find a workable delimiter. Each
section of the
   file is enclosed in quotes and that should be helpful, but
it
   doesn't seem to be. I can't seem to set the delimiter to '
   ' I can't
seem to find any good
examples,
   either.
   
I can't split on spaces, because the user
agents generally have spaces in them.
   
I was
   trying to use
explode.
   print_r(explode(' ', $line);
   
Any help
would be appreciated.
thanks,
Curtis



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



Certain data sequences (especially like the Apache log file), are well
documented and as such, due to their regular format, are sometimes
easier to read using a regex than by manually pulling apart using
string functions.

I use an app called RegexBuddy (it's a windows app) which is really
useful for describing a regex string in human readable format.

I can recommend http://www.regular-expressions.info,
http://www.regexbuddy.com and
http://www.regular-expressions.info/cookbook.html

I am not affiliated with any of these sites/books, just a happy customer.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



[PHP] stupid array question

2011-04-11 Thread Curtis Maurand


I have the following code which should increment the value of the array
$iplist if there is a value there.  When I walk the array at the end,
all the values = 1.  What am i doing wrong?

--Curtis

while (!feof($INPUTFILE))
 {
   $chunks = fgetcsv($INPUTFILE,  , '');
   $firstpart = explode( , $chunks[0]);
   $ipaddress = $firstpart[0];
   $agent =
$chunks[4];
//   print (stripos($agent, compatible;
MSIE 6.0; Windows NT 5.1; SV1).\n);
   if
(stripos($agent, compatible; MSIE 6.0; Windows NT 5.1; SV1)
 0)
   {
  
$iplist[$ipaddress]++;
  
//print($ipaddress\t$agent\n);
   }
   while (list($key, $value) = each($iplist))
   {

print($key\t$value\n);
   }
  }



Re: [PHP] Re: File Upload Problem

2011-04-11 Thread Hans Åhlin
I had some similar problem with Windows 7,
it had to do with UAC and folder rights. Apache/PHP could read but not
write to any dir except the ones that all users could write to.
I solved it by allowing every one to read, write and change content in
the directory where I needed PHP to handle/control the content.


2011/4/10 tedd tedd.sperl...@gmail.com:
 At 7:15 AM +0200 4/7/11, Wojciech Kupiec wrote:

 On 06/04/11 19:10, tedd wrote:

 -snip-
 What could be wrong? What should I be looking for?

 If you really want to get help, publish your code.

 I don't think that's true. I should be able to ask a technical question with
 observations and inquire as to What's wrong? After all, what's the point
 of showing code that works on two servers, but fails on a third? Really,
 what is that going to tell you?

 As for the uploaded file exceeding max file size and file_uploads
 enabled, those are obvious and I did that investigation before I posted the
 question. They are NOT the problem.

 I also checked all the servers involved for safe_mode and open_basedir
 settings and they are set the same. Additionally, the upload_max_filesize
 and upload_tmp_dir are also set exactly the same. As such, I don't know
 what else to look for -- hence my question.

 As I said, the script works on two servers, but fails on a third.

 This is what I've learned in addition to the above:

 The script does successfully upload the file to the server in question. For
 example, I receive truth from:

 if(is_uploaded_file($_FILES['userfile']['tmp_name']))
   {
   echo('true');
   }

 I can even get the contents of the uploaded file by:

 $contents = file_get_contents($_FILES['userfile']['tmp_name']);
 echo($contents);

 -- and the contents are displayed.

 So, the file is indeed uploaded!

 What I cannot do is move the file to another location using:

 $result = move_uploaded_file($_FILES['userfile']['tmp_name'], $path . '/' .
 $_FILES['userfile']['name']);

 (Yes, all possible file paths have been investigated)

 Nor, can I copy the file by:

 $result = copy($_FILES['userfile']['tmp_name'], $path . '/' .
 $_FILES['userfile']['name']);

 The only difference I see is the server causing problems is Windows NT
 whereas the others are Linux.

 So, knowing this  -- does anyone have any idea as to what is wrong?

 Cheers,

 tedd

 --
 ---
 http://sperling.com/

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





-- 


**
 Hans Åhlin
   Tel: +46761488019
   icq: 275232967
   http://www.kronan-net.com/
   irc://irc.freenode.net:6667 - TheCoin
**

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



Re: [PHP] Re: File Upload Problem

2011-04-11 Thread tedd

At 7:37 AM +0100 4/11/11, Ashley Sheridan wrote:

tedd tedd.sperl...@gmail.com wrote:

 So, knowing this  -- does anyone have any idea as to what is wrong?

What happens if you diff the various config files involved directly, 
php.ini, https.conf, any other site-specific *.conf files used by 
apache. Sometimes its a security feature in a .conf file that 
means I can override a setting myself in code or in an .htaccess 
file. Takes ages to find and annoying to debug around!


Ash


Ash:

I think that's the problem. I just wanted to bounce this experience 
off the group before making a fool of myself by asking for help at 
the local college where I'm trying to get the script to run. I think 
they have some security protocol in place to prevent this.


Thanks,

tedd

--
---
http://sperling.com/

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



[PHP] Error in variable assignment

2011-04-11 Thread Ethan Rosenberg

Dear list -

I an writing a script that will simulate a chess board.  On a move 
from e2 to e6 [see below] the variable in e2 is never assigned to 
e6.  Here are some code snippets:


?php
session_start();
session_name(Chess);
error_reporting(1);
 if ($_SESSION['flag'] != 1)
{
$flag = 1;
echo br /startingbr /;
 $results = array(array(Br, Bn, Bb, Bq, Bk, Bb, Bn, 
Br),array(Bp, Bp, Bp, Bp, Bp, Bp, Bp, Bp),
array(, , , , , , , 
),array(, , , , , , , ),array(, , , , , 
, , ),
array(, , , , , , , 
),array(Wp, Wp, Wp, Wp, Wp, Wp, Wp, Wp),
array(Wr, Wn, Wb, Wq, Wk, Wb, 
Wn, Wr));


$_SESSION['results'] = $results;
for($i = 0; $i 8; $i++)
{
for ($j = 0; $j  8; $j++)
printf(%s , $results[$i][$j]);
printf(br /);
}

$_SESSION[flag] = $flag;

snip

$board = array  //Correlation of input array [chessboard] with 
internal array [results]

(
a8 = $results[0][0],
b8 = $results[0][1],
c8 = $results[0][2],
d8 = $results[0][3],
e8 = $results[0][4],
f8 = $results[0][5],
g8 = $results[0][6],
h8 = $results[0][7],
a7 = $results[1][0],
b7 = $results[1][1],
c7 = $results[1][2],
d7 = $results[1][3],
e7 = $results[1][4],
f7 = $results[1][5],
g7 = $results[1][6],
h7 = $results[1][7],
a6 = $results[2][0],
b6 = $results[2][1],
c6 = $results[2][2],
d6 = $results[2][3],
e6 = $results[2][4],
f6 = $results[2][5],
g6 = $results[2][6],
h6 = $results[2][7],
a5 = $results[3][0],
b5 = $results[3][1],
c5 = $results[3][2],
d5 = $results[3][3],
e5 = $results[3][4],
f5 = $results[3][5],
g5 = $results[3][6],
h5 = $results[3][7],
a4 = $results[4][0],
b4 = $results[4][1],
c4 = $results[4][2],
d4 = $results[4][3],
e4 = $results[4][4],
f4 = $results[4][5],
g4 = $results[4][6],
h4 = $results[4][7],
a3 = $results[5][0],
b3 = $results[5][1],
c3 = $results[5][2],
d3 = $results[5][3],
e3 = $results[5][4],
f3 = $results[5][5],
g3 = $results[5][6],
h3 = $results[5][7],
a2 = $results[6][0],
b2 = $results[6][1],
c2 = $results[6][2],
d2 = $results[6][3],
e2 = $results[6][4],
f2 = $results[6][5],
g2 = $results[6][6],
h2 = $results[6][7],
a1 = $results[7][0],
b1 = $results[7][1],
c1 = $results[7][2],
d1 = $results[7][3],
e1 = $results[7][4],
f1 = $results[7][5],
g1 = $results[7][6],
h1 = $results[7][7],
);


$board2 = array  //Correlation of input array [chessboard] with 
internal array [results]

(
a8 = [0][0],
b8 = [0][1],
c8 = [0][2],
d8 = [0][3],
e8 = [0][4],
f8 = [0][5],
g8 = [0][6],
h8 = [0][7],
a7 = [1][0],
b7 = [1][1],
c7 = [1][2],
d7 = [1][3],
e7 = [1][4],
f7 = [1][5],
g7 = [1][6],
h7 = [1][7],
a6 = [2][0],
b6 = [2][1],
c6 = [2][2],
d6 = [2][3],
e6 = [2][4],
f6 = [2][5],
g6 = [2][6],
h6 = [2][7],
a5 = [3][0],
b5 = [3][1],
c5 = [3][2],
d5 = [3][3],
e5 = [3][4],
f5 = [3][5],
g5 = [3][6],
h5 = [3][7],
a4 = [4][0],
b4 = [4][1],
c4 = [4][2],
d4 = [4][3],
e4 = [4][4],
f4 = [4][5],
g4 = [4][6],
h4 = [4][7],
a3 = [5][0],
b3 = [5][1],
c3 = [5][2],
d3 = [5][3],
e3 = [5][4],
f3 = [5][5],
g3 = [5][6],
h3 = [5][7],
a2 = [6][0],
b2 = [6][1],
c2 = [6][2],
d2 = [6][3],
e2 = 

Re: [PHP] Re: File Upload Problem [SOLVED]

2011-04-11 Thread tedd

At 10:07 AM -0400 4/11/11, tedd wrote:

At 7:37 AM +0100 4/11/11, Ashley Sheridan wrote:

tedd tedd.sperl...@gmail.com wrote:

 So, knowing this  -- does anyone have any idea as to what is wrong?

What happens if you diff the various config files involved 
directly, php.ini, https.conf, any other site-specific *.conf files 
used by apache. Sometimes its a security feature in a .conf file 
that means I can override a setting myself in code or in an 
.htaccess file. Takes ages to find and annoying to debug around!


Ash


Ash:

I think that's the problem. I just wanted to bounce this experience 
off the group before making a fool of myself by asking for help at 
the local college where I'm trying to get the script to run. I think 
they have some security protocol in place to prevent this.


Thanks,

tedd


To all:

That was the problem.

The school had banned the practice of uploading any files to their 
server. I got permission for my class, but it is under a strict need 
to know basis.


Thanks for listening.

Cheers,

tedd

--
---
http://sperling.com/

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