php-general Digest 23 Jul 2008 09:21:54 -0000 Issue 5584

2008-07-23 Thread php-general-digest-help

php-general Digest 23 Jul 2008 09:21:54 - Issue 5584

Topics (messages 277179 through 277186):

Re: [PHP-INSTALL] Executing a python script from within perl
277179 by: Daniel Brown
277180 by: Daniel Brown
277181 by: Anuj Bhatt

Reference or copy?
277182 by: Yeti
277183 by: Robert Cummings
277184 by: Ted Wood
277185 by: Ted Wood

Getting info from SVN commit with php
277186 by: Raido

Administrivia:

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

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

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


--
---BeginMessage---
Forwarded to the appropriate list (PHP General).  Anuj: If you're
not already subscribed, please visit http://php.net/mailinglists and
subscribe to the PHP General list, or send a blank email to
[EMAIL PROTECTED]

On Tue, Jul 22, 2008 at 11:09 PM, Anuj Bhatt [EMAIL PROTECTED] wrote:
 Hi,


 I'm new to PHP and just installed apache2 with php support. I'm trying
 to execute a Python script (from within php), which does take a good
 amount of time and am waiting for it to terminate so that I can process
 the output and print that out in HTML.

 The problem I'm having is that I can't get the PHP script to wait for
 the Python file to terminate. If I try it with a simple Python script
 say print Hello, World! it gets that. But anything that takes
 substantially long time, it just returns. I've tried system(myfile.py,
 $result) and $result results in a 1 and prints any subsequent prints in
 the PHP file. I also tried exec, with no luck. I've read through
 http://www.php.net/function.exec and the documentation presented in the
 See Also section with other commands. I haven't got anywhere yet,
 after much work. Any pointers, suggestions and fixes?

Try this to see if your script is outputting any errors:

?php
exec('/path/to/python your-script.py 21',$ret);
print_r($ret);
?

If that works, you may just need to adjust your timeout and set
ignore_user_abort(1) to allow the Python script to keep running.  If
all else fails, and you're aware of the side-effects, go fork()
yourself.  ;-P

-- 
/Daniel P. Brown
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.
---End Message---
---BeginMessage---
On Tue, Jul 22, 2008 at 11:27 PM, Daniel Brown [EMAIL PROTECTED] wrote:

 If all else fails, and you're aware of the side-effects, go fork() yourself.  
 ;-P

For posterity:

http://php.net/pcntl

[See: pcntl_fork(), et al.]

-- 
/Daniel P. Brown
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.
---End Message---
---BeginMessage---
On Tue, 2008-07-22 at 23:27 -0400, Daniel Brown wrote:
 Try this to see if your script is outputting any errors:
 
 ?php
 exec('/path/to/python your-script.py 21',$ret);
 print_r($ret);
 ?

This worked, was opening a file for which permission was denied. Python
didn't show me anything, when run on the prompt, however when I used the
above method, I did get the error. Thanks!


-anuj


---End Message---
---BeginMessage---
Hello everyone,

Many of you may be familiar with references in PHP. Now i read
somewhere in the PHP manual that creating references can take longer
than copies. PHP5+ also seems to reference a bit different thant PHP4
did.
Here is some working example code:

?php
class useless {
var $huge_array;
function __construct() {
$this-huge_array = array();
for ($i = 0; $i  1024; $i++) $this-huge_array[] = $GLOBALS; //
fill ze array with copies of $GLOBALS array
return true;
}
function useless() {
return $this-__construct();
}
}
$time_start = microtime(true);
$test_obj = new useless();
$time_end = microtime(true);
$time = $time_end - $time_start;
echo It took {$time} seconds without using the reference operator.\r\n;
unset($test_obj);
$time_start = microtime(true);
$test_obj = new useless();
$time_end = microtime(true);
$time = $time_end - $time_start;
echo It took {$time} seconds using the reference
operator.\r\n## with obj2 \r\n;
$time_start = microtime(true);
$test_obj = new useless();
$obj2 = $test_obj;
$time_end = microtime(true);
$time = $time_end - $time_start;
echo It took {$time} seconds without using the reference operator.\r\n;
unset($test_obj);
$time_start = microtime(true);
$test_obj = new useless();
$obj2 = $test_obj;
$time_end = microtime(true);
$time = $time_end - $time_start;
echo It took {$time} seconds using the reference operator.\r\n;
?

I tested the code in PHP 4.4.7 and in PHP 5.2.5 and the results were
pretty much the same. Using references 

php-general Digest 23 Jul 2008 21:45:33 -0000 Issue 5585

2008-07-23 Thread php-general-digest-help

php-general Digest 23 Jul 2008 21:45:33 - Issue 5585

Topics (messages 277187 through 277213):

Re: Getting info from SVN commit with php
277187 by: mike
277189 by: Raido
277192 by: Daniel Brown
277193 by: Daniel Brown

Questions about finding ranges
277188 by: Aslan
277190 by: Jim Lucas
277209 by: VamVan
277210 by: Micah Gersten

Apache blocking certain requests instead of php
277191 by: Arno Kuhl
277195 by: Per Jessen
277211 by: Jim Lucas

Re: a question...
277194 by: Daniel Brown
277196 by: Micah Gersten

Re: Reference or copy?
277197 by: Robert Cummings
277207 by: Yeti
277208 by: Ted Wood

Multi-array - What am I missing?
277198 by: Chris Ditty
277201 by: Micah Gersten
277202 by: Chris Ditty
277203 by: Jason Norwood-Young
277204 by: Micah Gersten
277205 by: Micah Gersten
277206 by: Chris Ditty

big files download with php - configuration problem
277199 by: Giulio Mastrosanti
277213 by: mike

$_ENV or getenv to get bash environmental variables.. change php.ini?? env vars
277200 by: mindspin311

Re: After INSERT form submit - Data doesn't refresh!
277212 by: VamVan

Administrivia:

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

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

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


--
---BeginMessage---
On 7/23/08, Raido [EMAIL PROTECTED] wrote:

 I have an SVN server but I need to add some extra to commit message which
 PHP will get  and use(for example use the parameters from commit message to
 change data on mysql database... (if commit messages first line has
 character *, then run sql query... update tasks set some_row='OK'
 where

There's an SVN PECL module: http://pecl.php.net/package/svn

Also, you can easily run these kind of commands via system() - I've
done that in the past, but now that there's this SVN PECL module I've
been wanting to get aligned that way. Always better in my opinion to
use APIs and not system() calls.

If the svn module doesn't meet your needs you can ask for
enhancements, or just use system() for now.

here's a couple functions I wrote.
$config['svn'] was the path to the svn command (like /usr/bin/svn)

i used the xml output option so i could parse it using simplexml.
also, i pass it a username, password and repository since i support
multiple repositories and each one has a unique username/password set.
it worked like a charm. i am sure you can tailor this code to suit
your needs.

# get the latest revision #
function svn_latest($username, $password, $repository) {
$xml = simplexml_load_string(shell_exec($GLOBALS['config']['svn'].
info --xml --non-interactive --no-auth-cache --username {$username}
--password{$password} svn://localhost/{$repository}));
return intval($xml-entry-commit['revision']);
}

function svn_history($username, $password, $repository, $count = 20,
$start = 0, $latest = 0) {
# svn's revisions are incremental, so we need to calculate
backwards to find the right offsets
if($latest == 0) {
$latest = svn_latest($username, $password, $repository);
}
$start = $latest - $start;
$end = intval($start - $count) + 1;
if($end  0) { $end = 0; }
$xml = simplexml_load_string(shell_exec($GLOBALS['config']['svn'].
log --xml --non-interactive --no-auth-cache --username {$username}
--password {$password} -r {$start}:{$end}
svn://localhost/{$repository}));
return $xml;
}
---End Message---
---BeginMessage---

Thank You for that fast reply.

PECL was something that I din't know about. But I'll dig in with Your 
examples and also PECL and try to find most simple but well-working 
solution.

Also sorry for Return Receipt, turned that off.


mike wrote:

On 7/23/08, Raido [EMAIL PROTECTED] wrote:

  

I have an SVN server but I need to add some extra to commit message which
PHP will get  and use(for example use the parameters from commit message to
change data on mysql database... (if commit messages first line has
character *, then run sql query... update tasks set some_row='OK'
where



There's an SVN PECL module: http://pecl.php.net/package/svn

Also, you can easily run these kind of commands via system() - I've
done that in the past, but now that there's this SVN PECL module I've
been wanting to get aligned that way. Always better in my opinion to
use APIs and not system() calls.

If the svn module doesn't meet your needs you can ask for
enhancements, or just use system() for now.

here's a couple functions I wrote.
$config['svn'] was the path to the svn command (like /usr/bin/svn)

i used the xml output option so i could parse it using simplexml.
also, i pass it a username, password and repository 

[PHP] Reference or copy?

2008-07-23 Thread Yeti
Hello everyone,

Many of you may be familiar with references in PHP. Now i read
somewhere in the PHP manual that creating references can take longer
than copies. PHP5+ also seems to reference a bit different thant PHP4
did.
Here is some working example code:

?php
class useless {
var $huge_array;
function __construct() {
$this-huge_array = array();
for ($i = 0; $i  1024; $i++) $this-huge_array[] = $GLOBALS; //
fill ze array with copies of $GLOBALS array
return true;
}
function useless() {
return $this-__construct();
}
}
$time_start = microtime(true);
$test_obj = new useless();
$time_end = microtime(true);
$time = $time_end - $time_start;
echo It took {$time} seconds without using the reference operator.\r\n;
unset($test_obj);
$time_start = microtime(true);
$test_obj = new useless();
$time_end = microtime(true);
$time = $time_end - $time_start;
echo It took {$time} seconds using the reference
operator.\r\n## with obj2 \r\n;
$time_start = microtime(true);
$test_obj = new useless();
$obj2 = $test_obj;
$time_end = microtime(true);
$time = $time_end - $time_start;
echo It took {$time} seconds without using the reference operator.\r\n;
unset($test_obj);
$time_start = microtime(true);
$test_obj = new useless();
$obj2 = $test_obj;
$time_end = microtime(true);
$time = $time_end - $time_start;
echo It took {$time} seconds using the reference operator.\r\n;
?

I tested the code in PHP 4.4.7 and in PHP 5.2.5 and the results were
pretty much the same. Using references speeds up the script!
Occasionally obj2-with-references took longer than all the others. But
i don't know if that's to be taken serious.

Now if i do not need a copy, isn't it smarter to use references instead?

I'm grateful for any ideas, thoughts or experiences
Yeti

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



Re: [PHP] Reference or copy?

2008-07-23 Thread Robert Cummings
On Wed, 2008-07-23 at 10:07 +0200, Yeti wrote:
 Hello everyone,
 
 Many of you may be familiar with references in PHP. Now i read
 somewhere in the PHP manual that creating references can take longer
 than copies. PHP5+ also seems to reference a bit different thant PHP4
 did.
 Here is some working example code:
 
 ?php
 class useless {
   var $huge_array;
   function __construct() {
   $this-huge_array = array();
   for ($i = 0; $i  1024; $i++) $this-huge_array[] = $GLOBALS; //
 fill ze array with copies of $GLOBALS array
   return true;
   }
   function useless() {
   return $this-__construct();
   }
 }
 $time_start = microtime(true);
 $test_obj = new useless();
 $time_end = microtime(true);
 $time = $time_end - $time_start;
 echo It took {$time} seconds without using the reference operator.\r\n;
 unset($test_obj);
 $time_start = microtime(true);
 $test_obj = new useless();
 $time_end = microtime(true);
 $time = $time_end - $time_start;
 echo It took {$time} seconds using the reference
 operator.\r\n## with obj2 \r\n;
 $time_start = microtime(true);
 $test_obj = new useless();
 $obj2 = $test_obj;
 $time_end = microtime(true);
 $time = $time_end - $time_start;
 echo It took {$time} seconds without using the reference operator.\r\n;
 unset($test_obj);
 $time_start = microtime(true);
 $test_obj = new useless();
 $obj2 = $test_obj;
 $time_end = microtime(true);
 $time = $time_end - $time_start;
 echo It took {$time} seconds using the reference operator.\r\n;
 ?
 
 I tested the code in PHP 4.4.7 and in PHP 5.2.5 and the results were
 pretty much the same. Using references speeds up the script!
 Occasionally obj2-with-references took longer than all the others. But
 i don't know if that's to be taken serious.
 
 Now if i do not need a copy, isn't it smarter to use references instead?
 
 I'm grateful for any ideas, thoughts or experiences

In PHP4 if you don't need a copy then use a reference... it will be
faster. In PHP5 you don't get a copy unless you explicitly clone the
object. And so, in PHP5 assignment by value is faster than assignment by
reference. However, there may be the odd time you really want a
reference. PHP4 is dead though... so they say.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Reference or copy?

2008-07-23 Thread Ted Wood


The general rules of thumb are -- don't use references unless you  
actually *want* a reference. And don't use references for performance  
reasons.


Under PHP 4, it's generally been recommended to use a reference  
operator when creating objects.


 $obj = new Object();

PHP uses references internally until it's necessary to create a copy:

$a = array();

$a = $b;// internally, $b is a reference to $a

$b[] = chocolate;// at this point, a copy is made, and $b is  
modified


So PHP waits until a copy is actually needed before it makes one.  
Explicitly making copies incurs overhead because of the concept of  
reference counting. So again, don't use references for performance  
reasons.


~Ted




On 23-Jul-08, at 1:07 AM, Yeti wrote:


Hello everyone,

Many of you may be familiar with references in PHP. Now i read
somewhere in the PHP manual that creating references can take longer
than copies. PHP5+ also seems to reference a bit different thant PHP4
did.
Here is some working example code:

?php
class useless {
var $huge_array;
function __construct() {
$this-huge_array = array();
for ($i = 0; $i  1024; $i++) $this-huge_array[] = $GLOBALS; //
fill ze array with copies of $GLOBALS array
return true;
}
function useless() {
return $this-__construct();
}
}
$time_start = microtime(true);
$test_obj = new useless();
$time_end = microtime(true);
$time = $time_end - $time_start;
echo It took {$time} seconds without using the reference operator.\r 
\n;

unset($test_obj);
$time_start = microtime(true);
$test_obj = new useless();
$time_end = microtime(true);
$time = $time_end - $time_start;
echo It took {$time} seconds using the reference
operator.\r\n## with obj2 \r\n;
$time_start = microtime(true);
$test_obj = new useless();
$obj2 = $test_obj;
$time_end = microtime(true);
$time = $time_end - $time_start;
echo It took {$time} seconds without using the reference operator.\r 
\n;

unset($test_obj);
$time_start = microtime(true);
$test_obj = new useless();
$obj2 = $test_obj;
$time_end = microtime(true);
$time = $time_end - $time_start;
echo It took {$time} seconds using the reference operator.\r\n;
?

I tested the code in PHP 4.4.7 and in PHP 5.2.5 and the results were
pretty much the same. Using references speeds up the script!
Occasionally obj2-with-references took longer than all the others. But
i don't know if that's to be taken serious.

Now if i do not need a copy, isn't it smarter to use references  
instead?


I'm grateful for any ideas, thoughts or experiences
Yeti

--
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] Reference or copy?

2008-07-23 Thread Ted Wood


On 23-Jul-08, at 1:19 AM, Ted Wood wrote:


So PHP waits until a copy is actually needed before it makes one.  
Explicitly making copies incurs overhead because of the concept of  
reference counting. So again, don't use references for performance  
reasons.



That should've been:  Explicitly making references, not copies...

~Ted

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



[PHP] Getting info from SVN commit with php

2008-07-23 Thread Raido

Hi,

I would be very grateful if someone could point out some ways how to do 
the following:


I have an SVN server but I need to add some extra to commit message 
which PHP will get  and use(for example use the parameters from commit 
message to change data on mysql database... (if commit messages first 
line has character *, then run sql query... update tasks set 
some_row='OK' where

Currently important is:
1) Is it even possible to get commit messages text with php ? Since I 
can't find the file where commit messages are.

I only digged subversion docs for 'how to edit message'

Should, be possible(bot nut sure) to use commands: 
$ svn propedit -r N --revprop svn:log URL

$ svn propset -r N --revprop svn:log new log message URL

What I'd like to achieve is:
I'l' make page where I store all my tasks (for example Need to add login function 
to test.php). In MySQL, this task has got ID 1 and STATUS 0 which means it isn't 
done yet.

Then when I have that task done I start writing commit message where first line 
may look like this: 1|1
and rest of the lines will be regular commit message. Then there will be PHP 
script which checks that commit message and reads that line where I put 1|1 and 
understands that first number is task ID and second is STATUS and then run sql 
query like:
update tasks set STATUS=1 where ID=1;

So, seems impossible? For me, currently yes, since I haven't found any examples 
how to do it...but I know that nothing is impossible.

Raido



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



Re: [PHP] Getting info from SVN commit with php

2008-07-23 Thread mike
On 7/23/08, Raido [EMAIL PROTECTED] wrote:

 I have an SVN server but I need to add some extra to commit message which
 PHP will get  and use(for example use the parameters from commit message to
 change data on mysql database... (if commit messages first line has
 character *, then run sql query... update tasks set some_row='OK'
 where

There's an SVN PECL module: http://pecl.php.net/package/svn

Also, you can easily run these kind of commands via system() - I've
done that in the past, but now that there's this SVN PECL module I've
been wanting to get aligned that way. Always better in my opinion to
use APIs and not system() calls.

If the svn module doesn't meet your needs you can ask for
enhancements, or just use system() for now.

here's a couple functions I wrote.
$config['svn'] was the path to the svn command (like /usr/bin/svn)

i used the xml output option so i could parse it using simplexml.
also, i pass it a username, password and repository since i support
multiple repositories and each one has a unique username/password set.
it worked like a charm. i am sure you can tailor this code to suit
your needs.

# get the latest revision #
function svn_latest($username, $password, $repository) {
$xml = simplexml_load_string(shell_exec($GLOBALS['config']['svn'].
info --xml --non-interactive --no-auth-cache --username {$username}
--password{$password} svn://localhost/{$repository}));
return intval($xml-entry-commit['revision']);
}

function svn_history($username, $password, $repository, $count = 20,
$start = 0, $latest = 0) {
# svn's revisions are incremental, so we need to calculate
backwards to find the right offsets
if($latest == 0) {
$latest = svn_latest($username, $password, $repository);
}
$start = $latest - $start;
$end = intval($start - $count) + 1;
if($end  0) { $end = 0; }
$xml = simplexml_load_string(shell_exec($GLOBALS['config']['svn'].
log --xml --non-interactive --no-auth-cache --username {$username}
--password {$password} -r {$start}:{$end}
svn://localhost/{$repository}));
return $xml;
}

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



[PHP] Questions about finding ranges

2008-07-23 Thread Aslan

Hey there,

I have a range of records that represent different faults and different 
symptoms that I want to pull out of the database, and to find the 
records that are the closest within each range.


I am currently doing it with a barrage of if statements, but I am sure 
that this could be done faster and far more elegantly by using SQL


I have a range of conditions eg
Attainable rates:
0-500 KB/sec is very poor
500 - 1000 is marginal
1000- 3000 KB/sec is good

So the database may look like:
Type|Min|Max|Value
Attainable|0|500| This rate is very poor

and then SQL could go something like

SELECT * FROM table WHERE Type= Attainable AND Min LIKE $var


But that wouldn't work quite right I don't think.

But where it can get a bit more hairy is that I want to have a whole 
range of variables that are input from an entry table, and then it just 
finds the the vars that are the closest to what is searching for all the 
vars. The closest code I have seen doing something similar is where 
there it is finding if an IP is in a certain range.


Does that make sense? feel free to email me if you need more explanation.

It is kind of like a multi variable search engine, that is finding the 
root cause of the symptoms that are the very best fit given the 
multi-variables...


Thanks heaps for any assistance,
Aslan.


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



Re: [PHP] Getting info from SVN commit with php

2008-07-23 Thread Raido

Thank You for that fast reply.

PECL was something that I din't know about. But I'll dig in with Your 
examples and also PECL and try to find most simple but well-working 
solution.

Also sorry for Return Receipt, turned that off.


mike wrote:

On 7/23/08, Raido [EMAIL PROTECTED] wrote:

  

I have an SVN server but I need to add some extra to commit message which
PHP will get  and use(for example use the parameters from commit message to
change data on mysql database... (if commit messages first line has
character *, then run sql query... update tasks set some_row='OK'
where



There's an SVN PECL module: http://pecl.php.net/package/svn

Also, you can easily run these kind of commands via system() - I've
done that in the past, but now that there's this SVN PECL module I've
been wanting to get aligned that way. Always better in my opinion to
use APIs and not system() calls.

If the svn module doesn't meet your needs you can ask for
enhancements, or just use system() for now.

here's a couple functions I wrote.
$config['svn'] was the path to the svn command (like /usr/bin/svn)

i used the xml output option so i could parse it using simplexml.
also, i pass it a username, password and repository since i support
multiple repositories and each one has a unique username/password set.
it worked like a charm. i am sure you can tailor this code to suit
your needs.

# get the latest revision #
function svn_latest($username, $password, $repository) {
$xml = simplexml_load_string(shell_exec($GLOBALS['config']['svn'].
info --xml --non-interactive --no-auth-cache --username {$username}
--password{$password} svn://localhost/{$repository}));
return intval($xml-entry-commit['revision']);
}

function svn_history($username, $password, $repository, $count = 20,
$start = 0, $latest = 0) {
# svn's revisions are incremental, so we need to calculate
backwards to find the right offsets
if($latest == 0) {
$latest = svn_latest($username, $password, $repository);
}
$start = $latest - $start;
$end = intval($start - $count) + 1;
if($end  0) { $end = 0; }
$xml = simplexml_load_string(shell_exec($GLOBALS['config']['svn'].
log --xml --non-interactive --no-auth-cache --username {$username}
--password {$password} -r {$start}:{$end}
svn://localhost/{$repository}));
return $xml;
}

  



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



Re: [PHP] Questions about finding ranges

2008-07-23 Thread Jim Lucas

Aslan wrote:

Hey there,

I have a range of records that represent different faults and different 
symptoms that I want to pull out of the database, and to find the 
records that are the closest within each range.


I am currently doing it with a barrage of if statements, but I am sure 
that this could be done faster and far more elegantly by using SQL


I have a range of conditions eg
Attainable rates:
0-500 KB/sec is very poor
500 - 1000 is marginal
1000- 3000 KB/sec is good

So the database may look like:
Type|Min|Max|Value
Attainable|0|500| This rate is very poor

and then SQL could go something like

SELECT * FROM table WHERE Type= Attainable AND Min LIKE $var



You're close, try this

SELECT   *
FROM table
WHEREType = Attainable
  ANDMin = $var
  ANDMax = $var


as long as your min and max do not overlap from row to row, you should only 
get one result.  Make sure in your data that you have no overlap.


Row 1 =0 -  499
Row 2 =  500 -  999
Row 3 = 1000 - 1499



But that wouldn't work quite right I don't think.

But where it can get a bit more hairy is that I want to have a whole 
range of variables that are input from an entry table, and then it just 
finds the the vars that are the closest to what is searching for all the 
vars. The closest code I have seen doing something similar is where 
there it is finding if an IP is in a certain range.


Does that make sense? feel free to email me if you need more explanation.

It is kind of like a multi variable search engine, that is finding the 
root cause of the symptoms that are the very best fit given the 
multi-variables...


Thanks heaps for any assistance,
Aslan.





--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



[PHP] Apache blocking certain requests instead of php

2008-07-23 Thread Arno Kuhl
I'm getting a lot of bogus requsts in the form of
index.php?id=http://64.15.67.17/~babysona/logo.jpg?;, sometimes more than a
hundred a day per domain. The php script catches it, logs the request, sends
an email report and replies with access denied, but it takes processing
which I'd rather not have php busy with. (The php script rejects anything
where id=something_not_numeric.) Is there a way for apache to catch these
requests before passing it to php? Is it more efficient for apache to handle
this than php?

Arno


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



Re: [PHP] Getting info from SVN commit with php

2008-07-23 Thread Daniel Brown
On Wed, Jul 23, 2008 at 8:22 AM, Raido [EMAIL PROTECTED] wrote:

 1) Is it even possible to get commit messages text with php ? Since I can't
 find the file where commit messages are.

Just a quick answer to this: in your directory of your project
repo, go into the hooks/ subdirectory.  In there, you'll find a
post-commit.tmpl file.  Remove the .tmpl extension and chmod 755
post-commit (if on *NIX).  When a commit is made, post-commit will be
executed by SVN.

Conversely, if you want the script to execute on a different
trigger, just use a different name for the script, including
pre-commit, pre-lock, post-lock, post-revprop-change, et cetera.

One of my post-commit scripts looks like this (with names changed
to protect the innocent):

#!/bin/bash
REPOS=$1
REV=$2
AUTHOR=`/usr/bin/svnlook author -r $REV $REPOS`
CHANGED=`/usr/bin/svnlook changed -r $REV $REPOS`
DIFF=`/usr/bin/svnlook diff -r $REV $REPOS`
/usr/bin/php -q /home/repos/sites/example-com/hooks/post-commit.php
$REPOS $REV $AUTHOR $CHANGED $DIFF


And then, the PHP script it calls (post-commit.php) from the
shellscript above:

#!/usr/bin/php -q
?php

$repo = $argv[1];
$rev = $argv[2];
$username = $argv[3];
$changes = $argv[4];
$diff = $argv[5];
$datetime = date(D, j F, Y). at .date(H:i:s T);

$to = [EMAIL PROTECTED];

$subject = [SVN] Commit by .$username;

$body  = \n;
$body .= \tChanges have been made to the SVN repository.  The
revision number is now .$rev..  Details follow.\n;
$body .= \n;
$body .= Committed at .$datetime.\n;
$body .= Committed By: .$username.\n;
$body .= Repository: .$repo.\n;
$body .= Revision # .$rev.\n;
$body .= \n\n;
$body .= List of changes: \n;
$body .= $changes.\n;
$body .= \n\n;
$body .= Differences:\n;
$body .= $diff.\n;
$body .= \n;

$headers  = From: \SVN: .$username.\ [EMAIL PROTECTED]\r\n;
$headers .= X-Mailer: PHP/.phpversion().\r\n;

mail($to,$subject,$body,$headers);
?

-- 
/Daniel P. Brown
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



[PHP] Re: a question...

2008-07-23 Thread Daniel Brown
On Wed, Jul 23, 2008 at 12:10 PM,  [EMAIL PROTECTED] wrote:
 Yes, sorry. I have a database that records ip of attacks on a customer
 server, what I like to do get a count so that I can see what subnet is
 doing the major of the attacks.

 select ip from ipslimit 10;
 +-+---+
 | ip  | count(ip) |
 +-+---+
 | 83.117.196.206  | 1 |
 | 85.17.109.28| 1 |
 | 125.138.96.19   | 1 |
 | 89.110.148.253  | 1 |
 | 192.168.105.10  | 1 |
 | 200.170.124.72  | 1 |
 | 201.116.98.214  | 1 |
 | 202.168.255.226 | 1 |
 | 203.89.243.158  | 1 |
 | 210.245.207.217 | 1 |
 +-+---+
 10 rows in set (0.00 sec)

Okay, this would have to be done in code, and isn't a MySQL issue.
 Presuming you're using PHP, I'm going to also copy this message to
the PHP General mailing list, Payne, so that others can benefit from
it in the archives as well.  If you're not already subscribed and
would like to follow along with the thread, please send a blank
message to [EMAIL PROTECTED]

To get the Class C on that, here's a simple function you can use:

?php
function get_subnet($ip) {
return substr($ip,0,strrpos($ip,'.'));
}
?

As a quick illustration of how it works, here's an example script
(to use MySQL, just replace the $ips array with your ?php $row =
mysql_fetch_array($result); ? or similar line):

?php
$ips = 
array('192.168.0.0','10.0.0.1','127.0.0.1','216.37.159.240','99.99.99.99','127.0.0.2','192.168.1.1','10.0.0.0','192.168.0.1','192.168.0.150');

function get_subnet($ip) {
return substr($ip,0,strrpos($ip,'.'));
}

foreach($ips as $ip) {
echo $ip.'s Class C is .get_subnet($ip).\n;
}
?


-- 
/Daniel P. Brown
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Apache blocking certain requests instead of php

2008-07-23 Thread Per Jessen
Arno Kuhl wrote:

 Is there a
 way for apache to catch these requests before passing it to php? Is it
 more efficient for apache to handle this than php?

2 x yes. I think you could probably use LocationMatch and ban all
access with Deny from all. 


/Per Jessen, Zürich


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



Re: [PHP] Re: a question...

2008-07-23 Thread Micah Gersten
I just want to point out that public IPs are no longer given out as
Class A, B, and C networks, but based on CIDR.  You can use rwhois to
figure out who has use of a certain subnet and what the range of it is.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Daniel Brown wrote:
 On Wed, Jul 23, 2008 at 12:10 PM,  [EMAIL PROTECTED] wrote:
   
 Yes, sorry. I have a database that records ip of attacks on a customer
 server, what I like to do get a count so that I can see what subnet is
 doing the major of the attacks.

 select ip from ipslimit 10;
 +-+---+
 | ip  | count(ip) |
 +-+---+
 | 83.117.196.206  | 1 |
 | 85.17.109.28| 1 |
 | 125.138.96.19   | 1 |
 | 89.110.148.253  | 1 |
 | 192.168.105.10  | 1 |
 | 200.170.124.72  | 1 |
 | 201.116.98.214  | 1 |
 | 202.168.255.226 | 1 |
 | 203.89.243.158  | 1 |
 | 210.245.207.217 | 1 |
 +-+---+
 10 rows in set (0.00 sec)
 

 Okay, this would have to be done in code, and isn't a MySQL issue.
  Presuming you're using PHP, I'm going to also copy this message to
 the PHP General mailing list, Payne, so that others can benefit from
 it in the archives as well.  If you're not already subscribed and
 would like to follow along with the thread, please send a blank
 message to [EMAIL PROTECTED]

 To get the Class C on that, here's a simple function you can use:

 ?php
 function get_subnet($ip) {
 return substr($ip,0,strrpos($ip,'.'));
 }
 ?

 As a quick illustration of how it works, here's an example script
 (to use MySQL, just replace the $ips array with your ?php $row =
 mysql_fetch_array($result); ? or similar line):

 ?php
 $ips = 
 array('192.168.0.0','10.0.0.1','127.0.0.1','216.37.159.240','99.99.99.99','127.0.0.2','192.168.1.1','10.0.0.0','192.168.0.1','192.168.0.150');

 function get_subnet($ip) {
 return substr($ip,0,strrpos($ip,'.'));
 }

 foreach($ips as $ip) {
 echo $ip.'s Class C is .get_subnet($ip).\n;
 }
 ?


   

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



Re: [PHP] Reference or copy?

2008-07-23 Thread Robert Cummings
On Wed, 2008-07-23 at 01:21 -0700, Ted Wood wrote:
 On 23-Jul-08, at 1:19 AM, Ted Wood wrote:
 
  So PHP waits until a copy is actually needed before it makes one.  
  Explicitly making copies incurs overhead because of the concept of  
  reference counting. So again, don't use references for performance  
  reasons.
 
 
 That should've been:  Explicitly making references, not copies...

This only applies to PHP5. PHP4's Copy-On-Write (COW) for objects was
crap and would clone the object on assignment. It was especially bad
when looping over an array of objects since each would be cloned so you
usually had to loop over the keys of the array and pull out a reference
yourself.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



[PHP] Multi-array - What am I missing?

2008-07-23 Thread Chris Ditty
Can anyone point me in the right direction?  I know I am missing something
simple, but I can't place my hands on it.

$myCalTime = act_getCalendarDays($config, $myMonth, $myYear);

foreach($myCalTime as $calTime = $calArrayTime){
$calArray[] = $calArrayTime['day'].=array('NULL','linked-day
.strtolower($calArrayTime['reason']).','.$calArrayTime['day'].'),;
}

act_getCalendarDays returns this
Array
(
[day] = Array
(
[0] = 05
[1] = 06
[2] = 26
[3] = 27
)

[reason] = Array
(
[0] = Vacation
[1] = Vacation
[2] = Vacation
[3] = Vacation
)

)


What am I missing to get this
=array('NULL=','linked-day ',''),

to look like this
05=array(NULL,'linked-day vacation','05'),


[PHP] big files download with php - configuration problem

2008-07-23 Thread Giulio Mastrosanti

Hi all,

I have a set of php scripts that handle the browsing and download of  
file from the server.


it has worked fine for a long time on a server linux, now I have got  
to migrate those scripts also on a windows server, and something very  
strange is happening:


the download process hangs when  downloading big ( 50 MB and up )  
files from the server, and the files are only partially downloaded.

the log on the server shows a Timer_connectionidle error message.

I'm quite sure it is a configuration ( php or IIS ) issue, but I have  
no idea about what could be the problem.


it is not an execution time problem since I have set the  
max_execution_time on the php.in to a very large value.
it seems that the php script simply stops communicating with the  
server, and after a while the server kills it.


the original script used a  readfile($filename) function, I have also  
tryed to replace it with fopen($filename, 'rb') and a while cicle with  
fread($filename, $chunksize), but with no success.


the server is Windows Server 2003 with IIS.

php Version is 5.2.5

any of you experienced a similar problem, or has any idea on what  
could be the problem?


Thanks,

 Giulio


Giulio Mastrosanti
[EMAIL PROTECTED]






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



[PHP] $_ENV or getenv to get bash environmental variables.. change php.ini?? env vars

2008-07-23 Thread mindspin311

I want to be able to do a getenv('SYMFONY_HOME'); or any env var that I've
setup in my /etc/bashrc for everyone. But apache obviously doesn't have a
shell, so it doesn't know about these. only the stuff in $_ENV. 

What I want to know is how can I read env vars like ANT_HOME, JAVA_HOME,
etc.. in php? I just need to be able to read symfony's root path so I can
stop hard coding it into a config file in the project everytime I deploy to
a new machine.
-- 
View this message in context: 
http://www.nabble.com/%24_ENV-or-getenv-to-get-bash-environmental-variables..-change-php.ini---env-vars-tp18617784p18617784.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Multi-array - What am I missing?

2008-07-23 Thread Micah Gersten
Don't put the array definitions in quotes:
Should be either:

foreach($myCalTime as $calTime = $calArrayTime){
$calArray[$calArrayTime['day']] = array('NULL','linked-day 
'.strtolower($calArrayTime['reason']),$calArrayTime['day']);

}

or

foreach($myCalTime as $calTime = $calArrayTime){
$calArray[] = array($calArrayTime['day'] = array('NULL','linked-day 
'.strtolower($calArrayTime['reason']),$calArrayTime['day']));


Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Chris Ditty wrote:
 Can anyone point me in the right direction?  I know I am missing something
 simple, but I can't place my hands on it.

 $myCalTime = act_getCalendarDays($config, $myMonth, $myYear);

 foreach($myCalTime as $calTime = $calArrayTime){
 $calArray[] = $calArrayTime['day'].=array('NULL','linked-day
 .strtolower($calArrayTime['reason']).','.$calArrayTime['day'].'),;
 }

 act_getCalendarDays returns this
 Array
 (
 [day] = Array
 (
 [0] = 05
 [1] = 06
 [2] = 26
 [3] = 27
 )

 [reason] = Array
 (
 [0] = Vacation
 [1] = Vacation
 [2] = Vacation
 [3] = Vacation
 )

 )


 What am I missing to get this
 =array('NULL=','linked-day ',''),

 to look like this
 05=array(NULL,'linked-day vacation','05'),

   

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



Re: [PHP] Multi-array - What am I missing?

2008-07-23 Thread Chris Ditty
The array($calArrayTime. is actually another string.  I am mainly trying to 
get the values for ['day']['0'], ['reason']['0'] etc all on the same line.

Sorry for not being clearer.

 Micah Gersten [EMAIL PROTECTED] 7/23/2008 2:50 PM 
Don't put the array definitions in quotes:
Should be either:

foreach($myCalTime as $calTime = $calArrayTime){
$calArray[$calArrayTime['day']] = array('NULL','linked-day 
'.strtolower($calArrayTime['reason']),$calArrayTime['day']);

}

or

foreach($myCalTime as $calTime = $calArrayTime){
$calArray[] = array($calArrayTime['day'] = array('NULL','linked-day 
'.strtolower($calArrayTime['reason']),$calArrayTime['day']));


Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com 



Chris Ditty wrote:
 Can anyone point me in the right direction?  I know I am missing something
 simple, but I can't place my hands on it.

 $myCalTime = act_getCalendarDays($config, $myMonth, $myYear);

 foreach($myCalTime as $calTime = $calArrayTime){
 $calArray[] = $calArrayTime['day'].=array('NULL','linked-day
 .strtolower($calArrayTime['reason']).','.$calArrayTime['day'].'),;
 }

 act_getCalendarDays returns this
 Array
 (
 [day] = Array
 (
 [0] = 05
 [1] = 06
 [2] = 26
 [3] = 27
 )

 [reason] = Array
 (
 [0] = Vacation
 [1] = Vacation
 [2] = Vacation
 [3] = Vacation
 )

 )


 What am I missing to get this
 =array('NULL=','linked-day ',''),

 to look like this
 05=array(NULL,'linked-day vacation','05'),

   

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




MLGW now offers ONLINE BILLING!
To view your bills, receive paperless bills, 
check payment status and pay online,
go to www.mlgw.com and click on the My Account link.
Enroll today!


This e-mail and any attachments represent the views and opinions
of only the sender and are not necessarily those of 
Memphis Light, Gas  Water Division, and no such inference should be made.


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



Re: [PHP] Multi-array - What am I missing?

2008-07-23 Thread Jason Norwood-Young

On Wed, 2008-07-23 at 13:52 -0500, Chris Ditty wrote:
 Can anyone point me in the right direction?  I know I am missing something
 simple, but I can't place my hands on it.
 
 $myCalTime = act_getCalendarDays($config, $myMonth, $myYear);
 
 foreach($myCalTime as $calTime = $calArrayTime){
 $calArray[] = $calArrayTime['day'].=array('NULL','linked-day
 .strtolower($calArrayTime['reason']).','.$calArrayTime['day'].'),;
 }
 
 act_getCalendarDays returns this
 Array
 (
 [day] = Array
 (
 [0] = 05
 [1] = 06
 [2] = 26
 [3] = 27
 )
 
 [reason] = Array
 (
 [0] = Vacation
 [1] = Vacation
 [2] = Vacation
 [3] = Vacation
 )
 
 )
 
 
 What am I missing to get this
 =array('NULL=','linked-day ',''),
 
 to look like this
 05=array(NULL,'linked-day vacation','05'),

Your myCalTime isn't an array of arrays of arrays, like you're
suggesting in the foreach.

$calArray=array();
for($x=0;$xsizeof($myCalTime[day]);$x++) {
   $calArray[]=$myCalTime[day][$x].=array('NULL','linked-day
.strtolower($myCalTime['reason'][$x]).','.$myCalTime['day'][$x].'),;
}


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



Re: [PHP] Multi-array - What am I missing?

2008-07-23 Thread Micah Gersten
I'm still confused.  What do you mean by same line?

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Chris Ditty wrote:
 The array($calArrayTime. is actually another string.  I am mainly trying 
 to get the values for ['day']['0'], ['reason']['0'] etc all on the same line.

 Sorry for not being clearer.

   
 Micah Gersten [EMAIL PROTECTED] 7/23/2008 2:50 PM 
 
 Don't put the array definitions in quotes:
 Should be either:

 foreach($myCalTime as $calTime = $calArrayTime){
 $calArray[$calArrayTime['day']] = array('NULL','linked-day 
 '.strtolower($calArrayTime['reason']),$calArrayTime['day']);

 }

 or

 foreach($myCalTime as $calTime = $calArrayTime){
 $calArray[] = array($calArrayTime['day'] = array('NULL','linked-day 
 '.strtolower($calArrayTime['reason']),$calArrayTime['day']));


 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com 



 Chris Ditty wrote:
   
 Can anyone point me in the right direction?  I know I am missing something
 simple, but I can't place my hands on it.

 $myCalTime = act_getCalendarDays($config, $myMonth, $myYear);

 foreach($myCalTime as $calTime = $calArrayTime){
 $calArray[] = $calArrayTime['day'].=array('NULL','linked-day
 .strtolower($calArrayTime['reason']).','.$calArrayTime['day'].'),;
 }

 act_getCalendarDays returns this
 Array
 (
 [day] = Array
 (
 [0] = 05
 [1] = 06
 [2] = 26
 [3] = 27
 )

 [reason] = Array
 (
 [0] = Vacation
 [1] = Vacation
 [2] = Vacation
 [3] = Vacation
 )

 )


 What am I missing to get this
 =array('NULL=','linked-day ',''),

 to look like this
 05=array(NULL,'linked-day vacation','05'),

   
 

   

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



Re: [PHP] Multi-array - What am I missing?

2008-07-23 Thread Micah Gersten
Nice catch, I missed that.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Jason Norwood-Young wrote:
 On Wed, 2008-07-23 at 13:52 -0500, Chris Ditty wrote:
   
 Can anyone point me in the right direction?  I know I am missing something
 simple, but I can't place my hands on it.

 $myCalTime = act_getCalendarDays($config, $myMonth, $myYear);

 foreach($myCalTime as $calTime = $calArrayTime){
 $calArray[] = $calArrayTime['day'].=array('NULL','linked-day
 .strtolower($calArrayTime['reason']).','.$calArrayTime['day'].'),;
 }

 act_getCalendarDays returns this
 Array
 (
 [day] = Array
 (
 [0] = 05
 [1] = 06
 [2] = 26
 [3] = 27
 )

 [reason] = Array
 (
 [0] = Vacation
 [1] = Vacation
 [2] = Vacation
 [3] = Vacation
 )

 )


 What am I missing to get this
 =array('NULL=','linked-day ',''),

 to look like this
 05=array(NULL,'linked-day vacation','05'),
 

 Your myCalTime isn't an array of arrays of arrays, like you're
 suggesting in the foreach.

 $calArray=array();
 for($x=0;$xsizeof($myCalTime[day]);$x++) {
$calArray[]=$myCalTime[day][$x].=array('NULL','linked-day
 .strtolower($myCalTime['reason'][$x]).','.$myCalTime['day'][$x].'),;
 }


   

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



Re: [PHP] Multi-array - What am I missing?

2008-07-23 Thread Chris Ditty
I actually got it.  Seeing Micah's code made me think.

Thanks for helping.  Much appreciated.

 Micah Gersten [EMAIL PROTECTED] 7/23/2008 3:06 PM 
Nice catch, I missed that.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com 



Jason Norwood-Young wrote:
 On Wed, 2008-07-23 at 13:52 -0500, Chris Ditty wrote:
   
 Can anyone point me in the right direction?  I know I am missing something
 simple, but I can't place my hands on it.

 $myCalTime = act_getCalendarDays($config, $myMonth, $myYear);

 foreach($myCalTime as $calTime = $calArrayTime){
 $calArray[] = $calArrayTime['day'].=array('NULL','linked-day
 .strtolower($calArrayTime['reason']).','.$calArrayTime['day'].'),;
 }

 act_getCalendarDays returns this
 Array
 (
 [day] = Array
 (
 [0] = 05
 [1] = 06
 [2] = 26
 [3] = 27
 )

 [reason] = Array
 (
 [0] = Vacation
 [1] = Vacation
 [2] = Vacation
 [3] = Vacation
 )

 )


 What am I missing to get this
 =array('NULL=','linked-day ',''),

 to look like this
 05=array(NULL,'linked-day vacation','05'),
 

 Your myCalTime isn't an array of arrays of arrays, like you're
 suggesting in the foreach.

 $calArray=array();
 for($x=0;$xsizeof($myCalTime[day]);$x++) {
$calArray[]=$myCalTime[day][$x].=array('NULL','linked-day
 .strtolower($myCalTime['reason'][$x]).','.$myCalTime['day'][$x].'),;
 }


   

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




MLGW now offers ONLINE BILLING!
To view your bills, receive paperless bills, 
check payment status and pay online,
go to www.mlgw.com and click on the My Account link.
Enroll today!


This e-mail and any attachments represent the views and opinions
of only the sender and are not necessarily those of 
Memphis Light, Gas  Water Division, and no such inference should be made.


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



Re: [PHP] Reference or copy?

2008-07-23 Thread Yeti
?php
# So if i want a copy in PHP, like:

$a = $b;

# In PHP5 $a would still be a reference as long as $b is not being changed?(!)
# Such behaviour makes it extremely easy to write a speedy script
without worrying about copy/reference issues!

# Thanks to all of you,
# Ernie
?

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



Re: [PHP] Reference or copy?

2008-07-23 Thread Ted Wood


In both PHP 4 and PHP 5, this would be an internal reference:

$a = $b;

until $b is changed.

The only exception is with Object handling under PHP 4, which had  
flawed reference handling.


So, the rule remains -- don't use references for performance reasons  
-- use them if you need references. :-)



~Ted



On 23-Jul-08, at 1:20 PM, Yeti wrote:


?php
# So if i want a copy in PHP, like:

$a = $b;

# In PHP5 $a would still be a reference as long as $b is not being  
changed?(!)

# Such behaviour makes it extremely easy to write a speedy script
without worrying about copy/reference issues!

# Thanks to all of you,
# Ernie
?

--
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] Questions about finding ranges

2008-07-23 Thread VamVan
Hey,

For ranges you can also use Between in the mysql queries.

SELECT * FROM table WHERE Type= Attainable AND Min LIKE $var can be
written as

Select * from table where between min and max

Just remember that between acts a bit wierd with dates or else Jim's
solution would be perfect for you.

Thanks



On Wed, Jul 23, 2008 at 7:58 AM, Jim Lucas [EMAIL PROTECTED] wrote:

 Aslan wrote:

 Hey there,

 I have a range of records that represent different faults and different
 symptoms that I want to pull out of the database, and to find the records
 that are the closest within each range.

 I am currently doing it with a barrage of if statements, but I am sure
 that this could be done faster and far more elegantly by using SQL

 I have a range of conditions eg
 Attainable rates:
 0-500 KB/sec is very poor
 500 - 1000 is marginal
 1000- 3000 KB/sec is good

 So the database may look like:
 Type|Min|Max|Value
 Attainable|0|500| This rate is very poor

 and then SQL could go something like

 SELECT * FROM table WHERE Type= Attainable AND Min LIKE $var


 You're close, try this

 SELECT   *
 FROM table
 WHEREType = Attainable
  ANDMin = $var
  ANDMax = $var


 as long as your min and max do not overlap from row to row, you should only
 get one result.  Make sure in your data that you have no overlap.

 Row 1 =0 -  499
 Row 2 =  500 -  999
 Row 3 = 1000 - 1499


 But that wouldn't work quite right I don't think.

 But where it can get a bit more hairy is that I want to have a whole range
 of variables that are input from an entry table, and then it just finds the
 the vars that are the closest to what is searching for all the vars. The
 closest code I have seen doing something similar is where there it is
 finding if an IP is in a certain range.

 Does that make sense? feel free to email me if you need more explanation.

 It is kind of like a multi variable search engine, that is finding the
 root cause of the symptoms that are the very best fit given the
 multi-variables...

 Thanks heaps for any assistance,
 Aslan.




 --
 Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

 Twelfth Night, Act II, Scene V
by William Shakespeare



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




Re: [PHP] Questions about finding ranges

2008-07-23 Thread Micah Gersten
Here's the info on the weirdness of between:
http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



VamVan wrote:
 Hey,

 For ranges you can also use Between in the mysql queries.

 SELECT * FROM table WHERE Type= Attainable AND Min LIKE $var can be
 written as

 Select * from table where between min and max

 Just remember that between acts a bit wierd with dates or else Jim's
 solution would be perfect for you.

 Thanks



 On Wed, Jul 23, 2008 at 7:58 AM, Jim Lucas [EMAIL PROTECTED] wrote:

   
 Aslan wrote:

 
 Hey there,

 I have a range of records that represent different faults and different
 symptoms that I want to pull out of the database, and to find the records
 that are the closest within each range.

 I am currently doing it with a barrage of if statements, but I am sure
 that this could be done faster and far more elegantly by using SQL

 I have a range of conditions eg
 Attainable rates:
 0-500 KB/sec is very poor
 500 - 1000 is marginal
 1000- 3000 KB/sec is good

 So the database may look like:
 Type|Min|Max|Value
 Attainable|0|500| This rate is very poor

 and then SQL could go something like

 SELECT * FROM table WHERE Type= Attainable AND Min LIKE $var


   
 You're close, try this

 SELECT   *
 FROM table
 WHEREType = Attainable
  ANDMin = $var
  ANDMax = $var


 as long as your min and max do not overlap from row to row, you should only
 get one result.  Make sure in your data that you have no overlap.

 Row 1 =0 -  499
 Row 2 =  500 -  999
 Row 3 = 1000 - 1499


 
 But that wouldn't work quite right I don't think.

 But where it can get a bit more hairy is that I want to have a whole range
 of variables that are input from an entry table, and then it just finds the
 the vars that are the closest to what is searching for all the vars. The
 closest code I have seen doing something similar is where there it is
 finding if an IP is in a certain range.

 Does that make sense? feel free to email me if you need more explanation.

 It is kind of like a multi variable search engine, that is finding the
 root cause of the symptoms that are the very best fit given the
 multi-variables...

 Thanks heaps for any assistance,
 Aslan.



   
 --
 Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

 Twelfth Night, Act II, Scene V
by William Shakespeare



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


 

   


Re: [PHP] Apache blocking certain requests instead of php

2008-07-23 Thread Jim Lucas

Arno Kuhl wrote:

I'm getting a lot of bogus requsts in the form of
index.php?id=http://64.15.67.17/~babysona/logo.jpg?;, sometimes more than a
hundred a day per domain. The php script catches it, logs the request, sends
an email report and replies with access denied, but it takes processing
which I'd rather not have php busy with. (The php script rejects anything
where id=something_not_numeric.) Is there a way for apache to catch these
requests before passing it to php? Is it more efficient for apache to handle
this than php?

Arno




Yes, in Apache turn off userdir access

In your httpd.conf file do this.

UserDir disabled

That way it will not process url that starts with a tildy ~...

That should take care of it.  Apache should then only report a 404 error to 
the error log for the given virtual host.


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] After INSERT form submit - Data doesn't refresh!

2008-07-23 Thread VamVan
Hello,

I understand what you are trying to do. But as a web developer it is never a
good practice to have a insert query and page to display the record in the
same page. This way you will never add the redundant data whenever the page
is refreshed.

So from my experience I would suggest you do this:

form.php

if(isset($_GET['displayrecords'])  $_GET['displayrecords'] == true) {
show records
}else{
form action='qry_form.php'
HTML FORM
submit
}

qry_form.php

{INSERT QUERY}

//redirect
header('location:form.php?displayrecords=true')

this intermediate step qry_form.php will insert the record and redirect to
the same page with a get variable.

This is a good practice to avoid inserting everytime you refresh the page.

Thanks




On Tue, Jul 22, 2008 at 8:12 AM, Daniel Brown [EMAIL PROTECTED] wrote:

 On Tue, Jul 22, 2008 at 10:51 AM, Rahul S. Johari
 [EMAIL PROTECTED] wrote:
 
  I just checked a couple of other browsers (IE, Safari, Opera) and it
 seems
  to be working fine in all the browsers except Firefox 3. I think this
 issue
  is now out of bounds for PHP - I don't think there is anything wrong in
 the
  script or the way I'm doing this - I think the problem is lying somewhere
 in
  either Firefox 3 or my settings of Firefox 3. Let me look into this.

 If you believe that to be the case, Rahul, please report your
 findings at [EMAIL PROTECTED]  We (I'm a Mozilla
 developer as well) may then ask you to post portions of your
 'about:config' to better troubleshoot the issues.

 --
 /Daniel P. Brown
 Better prices on dedicated servers:
 Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
 Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
 Dedicated servers, VPS, and hosting from $2.50/mo.

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




Re: [PHP] big files download with php - configuration problem

2008-07-23 Thread mike
On 7/23/08, Giulio Mastrosanti [EMAIL PROTECTED] wrote:
 Hi all,

 I have a set of php scripts that handle the browsing and download of file
 from the server.

 it has worked fine for a long time on a server linux, now I have got to
 migrate those scripts also on a windows server, and something very strange
 is happening:

 the download process hangs when  downloading big ( 50 MB and up ) files from
 the server, and the files are only partially downloaded.
 the log on the server shows a Timer_connectionidle error message.

 I'm quite sure it is a configuration ( php or IIS ) issue, but I have no
 idea about what could be the problem.

 it is not an execution time problem since I have set the max_execution_time
 on the php.in to a very large value.
 it seems that the php script simply stops communicating with the server, and
 after a while the server kills it.

 the original script used a  readfile($filename) function, I have also tryed
 to replace it with fopen($filename, 'rb') and a while cicle with
 fread($filename, $chunksize), but with no success.

I would recommend looking into a webserver that supports offloading
the file download to the webserver via fastcgi:

- nginx (preferred) using X-Accel-Redirect header
- lighttpd using X-Lighttpd-Sendfile header
- apache has a module mod_sendfile or something, but I don't recommend
apache for anything anymore

not sure if other webservers have it or not. But basically it allows
you to use PHP/application level logic to validate if the user has
access, and then tells the webserver okay, now send the file and
releases PHP/application level from having to spoonfeed the file using
things like readfile() and keeping the PHP thread/whatever open

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



Re: [PHP] $_ENV or getenv to get bash environmental variables.. change php.ini?? env vars

2008-07-23 Thread mike
On 7/23/08, mindspin311 [EMAIL PROTECTED] wrote:

 I want to be able to do a getenv('SYMFONY_HOME'); or any env var that I've
 setup in my /etc/bashrc for everyone. But apache obviously doesn't have a
 shell, so it doesn't know about these. only the stuff in $_ENV.

 What I want to know is how can I read env vars like ANT_HOME, JAVA_HOME,
 etc.. in php? I just need to be able to read symfony's root path so I can
 stop hard coding it into a config file in the project everytime I deploy to
 a new machine.

i believe you can add it to /etc/profile and restart apache (possibly
need to reboot, not sure) and those are global environment variables
everyone receives, including non-interactive shells and processes.

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



[PHP] *****[SPAM(1.8)]*****

2008-07-23 Thread payne
Spam detection software, running on the system magi.magidesign.com, has
identified this incoming email as possible spam.  The original message
has been attached to this so you can view it (if it isn't spam) or label
similar future email.  If you have any questions, see
postmaster for details.

Content preview:  Hi, Can someone please point me to a web site with examples
   of php being use with the cli sending mail. I need to create a couple scripts
   that do that. I have looked on the net and most scripts are for form feed
   back. [...] 

Content analysis details:   (1.8 points, 1.5 required)

 pts rule name  description
 -- --
-1.7 ALL_TRUSTEDPassed through trusted hosts only via SMTP
 1.0 Magi_deSpam from Germany
 0.0 BAYES_50   BODY: Bayesian spam probability is 40 to 60%
[score: 0.4208]
 2.5 MISSING_SUBJECTMissing Subject: header


---BeginMessage---
Hi,

Can someone please point me to a web site with examples of php being use
with the cli sending mail. I need to create a couple scripts that do that.
I have looked on the net and most scripts are for form feed back.

Thanks...

Payne


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

[PHP] *****[SPAM(1.8)]*****

2008-07-23 Thread payne
Spam detection software, running on the system magi.magidesign.com, has
identified this incoming email as possible spam.  The original message
has been attached to this so you can view it (if it isn't spam) or label
similar future email.  If you have any questions, see
postmaster for details.

Content preview:  Hi, Can someone please point me to a web site with examples
   of php being use with the cli sending mail. I need to create a couple scripts
   that do that. I have looked on the net and most scripts are for form feed
   back. [...] 

Content analysis details:   (1.8 points, 1.5 required)

 pts rule name  description
 -- --
-1.7 ALL_TRUSTEDPassed through trusted hosts only via SMTP
 1.0 Magi_deSpam from Germany
 0.0 BAYES_50   BODY: Bayesian spam probability is 40 to 60%
[score: 0.4208]
 2.5 MISSING_SUBJECTMissing Subject: header


---BeginMessage---
Hi,

Can someone please point me to a web site with examples of php being use
with the cli sending mail. I need to create a couple scripts that do that.
I have looked on the net and most scripts are for form feed back.

Thanks...

Payne


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

[PHP] Weird issue with PHP5

2008-07-23 Thread jeff . mills

I have a module originally written for PHP-Nuke that I have ported to
CPG-Nuke/DragonFlyCMS.

In PHP4, the page I'm displaying works fine.
In PHP5, it doesn't.

The following link is a screenshot of the page using PHP4:
http://nukeleaguedf.winsto.net/working-php4.jpg

And a screenshot from PHP5:
http://nukeleaguedf.winsto.net/broken-php5.jpg

You can see that the stat lines for the first group (Batters) displays
properly. However, the stat lines for the following groups do not.

I have copied the three offending files into text files:
http://nukeleaguedf.winsto.net/modules/League/index.txt
http://nukeleaguedf.winsto.net/modules/League/util.txt
http://nukeleaguedf.winsto.net/modules/League/classes.txt

Line 1119 of index.txt is where is all begins.
I have tested that the while loop is actually looping 3 times as it should
(once for each group).
Doing a var_dump of $players shows all of the required information.

Line 1126 is the actual line that displays the fields.

I have scoured the code with my limited PHP knowledge, but I can't for the
life of me see why its not working in PHP5.
Perhaps part of the code is incompatible with PHP5, or perhaps its a bug
in PHP5.
Is anyone able to help?








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



Re: [PHP] Weird issue with PHP5

2008-07-23 Thread Nathan Nobbe
On Wed, Jul 23, 2008 at 10:45 PM, [EMAIL PROTECTED] wrote:


 I have a module originally written for PHP-Nuke that I have ported to
 CPG-Nuke/DragonFlyCMS.

 In PHP4, the page I'm displaying works fine.
 In PHP5, it doesn't.

 The following link is a screenshot of the page using PHP4:
 http://nukeleaguedf.winsto.net/working-php4.jpg

 And a screenshot from PHP5:
 http://nukeleaguedf.winsto.net/broken-php5.jpg

 You can see that the stat lines for the first group (Batters) displays
 properly. However, the stat lines for the following groups do not.

 I have copied the three offending files into text files:
 http://nukeleaguedf.winsto.net/modules/League/index.txt
 http://nukeleaguedf.winsto.net/modules/League/util.txt
 http://nukeleaguedf.winsto.net/modules/League/classes.txt

 Line 1119 of index.txt is where is all begins.
 I have tested that the while loop is actually looping 3 times as it should
 (once for each group).
 Doing a var_dump of $players shows all of the required information.

 Line 1126 is the actual line that displays the fields.

 I have scoured the code with my limited PHP knowledge, but I can't for the
 life of me see why its not working in PHP5.
 Perhaps part of the code is incompatible with PHP5, or perhaps its a bug
 in PHP5.
 Is anyone able to help?


thats a decent bit of code to pick through, jeff.  glancing at index.txt,
the code looks pretty straight forward, and by that i mean that it doesnt
look like theres anything that shouldnt work in php5.

if i were to guess, i would suspect an environmental issue.  you should
ensure that all the extensions you had in php4 are there in php5.  you can
do this by writing a simple script, phpinfo.php

?php
die(phpinfo());

you should run this in both the php4, and php5 environments and make sure
things look essentially identical.  as well, there are a few things that
changed in php5, here is a helpful reference from the manual that will give
you things to look out for,

http://www.php.net/manual/en/faq.migration5.php

another thing i would recommend to weed out any environmental issues is to
configure error_reporting to show everything.  so (depending on your version
of php5) if youre using the latest version, your php.ini file should have
something like this

display_errors = On
error_reporting = E_ALL

on older versions of php5, you would have to tweak the error reporting to
also display E_STRICT errors, i doubt thats your problem, but i thought to
mention it.

something else that might be helpful would be setting up a debugger, such as
xdebug + protoeditor.  i can help you through the configuration if you
want.  this will allow you to set breakpoints and step through the code,
line-by-line if you wish, which could also help you isolate the problem more
quickly.

-nathan


Re: [PHP] Weird issue with PHP5

2008-07-23 Thread jeff . mills


 thats a decent bit of code to pick through, jeff.  glancing at index.txt,
 the code looks pretty straight forward, and by that i mean that it doesnt
 look like theres anything that shouldnt work in php5.

 if i were to guess, i would suspect an environmental issue.  you should
 ensure that all the extensions you had in php4 are there in php5.  you can
 do this by writing a simple script, phpinfo.php

 ?php
 die(phpinfo());

 you should run this in both the php4, and php5 environments and make sure
 things look essentially identical.  as well, there are a few things that
 changed in php5, here is a helpful reference from the manual that will
 give
 you things to look out for,

 http://www.php.net/manual/en/faq.migration5.php

 another thing i would recommend to weed out any environmental issues is to
 configure error_reporting to show everything.  so (depending on your
 version
 of php5) if youre using the latest version, your php.ini file should have
 something like this

 display_errors = On
 error_reporting = E_ALL

 on older versions of php5, you would have to tweak the error reporting to
 also display E_STRICT errors, i doubt thats your problem, but i thought to
 mention it.

 something else that might be helpful would be setting up a debugger, such
 as
 xdebug + protoeditor.  i can help you through the configuration if you
 want.  this will allow you to set breakpoints and step through the code,
 line-by-line if you wish, which could also help you isolate the problem
 more
 quickly.

 -nathan


Hi Nathan,
it sure is a lot of code to work through. Its been driving me insane for
the last couple of days.
phpinfo on the same server when switching from php4 to php5 shows only a
few differences.
There is one different module in each version:
PHP Version 4.4.8_pre20070816-pl0-gentoo
- sapi_apache2
PHP Version 5.2.6RC4-pl0-gentoo
- mod_php5

I've saved the phpinfo pages.
http://nukeleaguedf.winsto.net/phpinfo/phpinfov4.htm
http://nukeleaguedf.winsto.net/phpinfo/phpinfov5.htm

I'm currently installing xdebug, but I don't see protoeditor in my Linux
distro. Is it available for download?
Configuration help would be great, thank you.






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