Re: [PHP] Reading files in PHP 5.3.0

2009-09-11 Thread Steve Brown
 function parseResponseHeaders($header_file) {
     $http_found = $error_found = false;
     $http_reponse = $error_message = NULL;

     $response = array();
     $response['ResponseCode'] = NULL;
     $response['ErrorMessage'] = NULL;

     if (!is_file($header_file) ||
 !is_readable($header_file)) {
         return $response;
     }

     $fin = fopen($header_file, 'r');
     while ($line = fgets($fin)) {
         var_dump($line);

 What does var_dump($line); tell you?

Nothing, not even an empty variable.  Which is why I think something
is completely screwed up here.

BTW, squares at the end of lines are your platform not interpreting
EOL characters correctly from another platform.  Generally, its the
sending client thats not being friendly, not the receiving client.

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



[PHP] Reading files in PHP 5.3.0

2009-09-10 Thread Steve Brown
I've been beating my head against a wall all day and can't figure this
one out.  The code below worked perfectly in PHP5.2.4.  However, I
recently upgraded to PHP5.3.0 and this code no longer works.

The function below accepts the path to a text file containing headers
from a cUrl session (example attached).  Basically this function opens
to log file, looks for certain headers and captures some information
from that line.  When called on the attached file (or any log file for
that matter), the following is output:

array(2) {
  [ResponseCode]=
  NULL
  [ErrorMessage]=
  NULL
}

Which means that nothing is getting read from the file.

Now, I'm going to qualify all of this by saying I'm running OSX Snow
Leopard, so I'm fully prepared to believe that Apple fucked something
up in it, as they have done to third party packages on other occasions
in the past.  Well... to be fair, they don't usually fuck up third
party packages, rather they introduce enhancements to the OS that
prevents certain packages from working correctly and could care less
that they broke it.

So did anything change in PHP5.3.0 that would preclude the code below
from working?  Am I going crazy?  Or did Apple f...@# something up in
this release?

Thanks,
Steve

BEGIN CODE
==
function parseResponseHeaders($header_file) {
$http_found = $error_found = false;
$http_reponse = $error_message = NULL;

$response = array();
$response['ResponseCode'] = NULL;
$response['ErrorMessage'] = NULL;

if (!is_file($header_file) || !is_readable($header_file)) {
return $response;
}

$fin = fopen($header_file, 'r');
while ($line = fgets($fin)) {
var_dump($line);

if (substr($line, 0, 4) == 'HTTP') {
$line_explode = explode(' ', $line);
$response['ResponseCode'] = preg_replace('/\D/', '', 
$line_explode[1]);
if ($response['ResponseCode'] != 100) {
$http_found = true;
}
}

if (substr($line, 0, 16) == 'X-Error-Message:') {
$line_explode = explode(' ', $line);
array_shift($line_explode);
$response['ErrorMessage'] = join(' ', $line_explode);
$error_found = true;
}
}
fclose($fin);

var_dump($response);
return $response;
}
HTTP/1.1 100 Continue

HTTP/1.1 200 OK
Date: Thu, 10 Sep 2009 20:57:43 GMT
Server: Apache/2.2.6 (Unix) mod_ssl/2.2.6  PHP/5.2.8
X-Powered-By: PHP/5.2.8
Vary: Accept-Encoding
Content-Length: 1630
Content-Type: text/html

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

Re: [PHP] isset not functioning

2009-08-03 Thread Steve Brown
 if(isset($_REQUEST['firstname'])  !empty($RESULT['firstname'])) {
  $name = $_REQUEST['firstname'];
  } else {
  $name = 'Sir or Madam';
 }


 Can anyone see any problems with the code?

Your conditional will never evaluate to true.  What is $RESULT?  Where
did it come from? $RESULT is not a built-in PHP variable or function,
so empty($RESULT) will always be true, making !empty(...) always
false.

Also, it should be noted that if a form field exists, it will exist in
the form data POSTed to PHP, even if the field is empty.

I'm guessing that what you want to do is something like this:

if(!empty($_POST['firstname']) {
$name = $_POST['firstname'];
} else {
$name = 'Sir or Madam';
}

empty() will evaluate to false if the field is empty OR if the field
does not exist.  Also not the use of $_POST instead of $_REQUEST.
This will ensure that your data is actually coming from the form
instead of an attacker trying to inject data with $_GET variables or
some other source.

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



[PHP] http://go-pear.org?

2007-10-04 Thread Steve Brown
I'm trying to install Pear on OSX, but http://go-pear.org/ doesn't
seem to be resolving.  Pear manual states I should:

curl http://go-pear.org/ | php

but this fails and

dig go-pear.org

reveals that the name does not resolve.  Is there a package somewehre
I can download and install?

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



[PHP] Questions about overloading and visibility in PHP5

2007-09-18 Thread Steve Brown
I've been doing a bunch of reading about objects and overloading in
PHP5, but I've got a couple of questions that I can't seem to find the
answer to online.  Suppose the following code in PHP5.2.4:

?php
class foo {
public $x;
private $z = 'z';

public function __set ($name, $val) {
echo Setting \$this-$name to $val...\n;
$this-{$name} = $val;
}

public function __get ($name) {
return The value of $name is {$this-{$name}}.\n;
}
}
?

My questions are as follows:

1) It seems that the getter and setter are not called on every single
call.  For example, if I do the following:

$bar = new foo;
$bar-x = 'x';

There is no output.  I would expect to see Setting $this-x to x.
Another example:

$bar = new foo;
$bar-y = 'y';
echo $bar-y;

I would expect this to see The value of y is y. but instead I just
get  'y' as output.  So when do the various setters/getters get used?

2) It seems that getters ignore the visibility of properties.  Why is
this?  For example:

$bar = new foo;
echo $bar-z;

I would expect this to throw an error about accessing a private
member, but it outputs The value of z is z. just fine.  If I remove
the __get() overloader, an error is thrown.

I'm guessing that the answer to all of my questions is some how
wrapped up in visibility and overloading.  Unfortunately I cannot find
any resource that documents the interactions.  TIA.

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



[PHP] PHP4 vs PHP5 Performance?

2007-08-24 Thread Steve Brown
Recently, I've been doing a lot of benchmarking with Apache to compare
different OSes and platforms. I did a stock install of Ubuntu 7.04
Server w/ Apache2 and PHP5. To do the test, I used ab to fetch the
following document:

html
head
  titlePHP Web Server Test/title
/head
body
?php phpinfo(); ?
/body
/html

I ran ab in a loop 12 times with 10,000 connections and a concurrency
of 10. Then I threw out the highest result and the lowest result and
averaged the remaining values.   Both PHP4 (v 4.4.7) and PHP5 (v
5.2.3) were built as Apache modules, and I simply changed Apache's
config file to swap modules.

The results were somewhat surprising to me: on average, PHP4
significantly outperformed PHP5. Over our LAN PHP5 handled roughly
1,200 requests / sec while PHP4 handled over 1,800 requests / sec.
Since everything I have heard/read is that PHP5 is much faster than
PHP4, I expected the opposite to be true, but the numbers are what
they are.  Also PHP on Apache1 was much faster than on Apache2.

The only difference I can figure is that PHP5 was the packaged version
that comes with Ubuntu and I had to compile PHP4 from source since
there is no package for it in Feisty. But I wouldn't expect a 50%
increase as a result of that.  Any thoughts on this?

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



Re: [PHP] Printing library in PHP ?

2006-03-14 Thread Steve Brown
 I am currently migrating an application originally written with Delphi to
 PHP.  Everything is going fine except the printing of the reports that does
 not produce the same visual result (i.e does not look the same or has some
 aligmment issues).

We generate all of our printed reports using FPDF
(http://www.fpdf.org) to generate PDF files.  Its very flexible, can
do must of what you are aksing for, and unlike some alternatives, its
free.PDFs are going to be the easiest way to get total control of
the output.

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



Re: [PHP] [HS] IDE PHP on Linux...

2006-02-13 Thread Steve Brown
 Finally, I discovered that I need to have PHP and Apache on my computer
 in order than Eclipse may give me auto-complete...

No you don't.  Eclipse does code completion out-of-the-box w/out
installing additional software.  Check your Preferences.

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



Re: [PHP] building php, using mysql for apache2

2005-06-01 Thread Steve Brown
 trying to build php4 with mysql4.1-12, for use in apache2. i have the
 following ./compile that works for php5. however, when i try to use it for
 php4, i get a msg, stating that it can't find the MySQL Headers...

From http://us3.php.net/manual/en/ref.mysql.php:

===
 For compiling, simply use the --with-mysql[=DIR]  configuration
option where the optional [DIR] points to the MySQL installation
directory.

This MySQL extension doesn't support full functionality of MySQL
versions greater than 4.1.0. For that, use MySQLi.

If you would like to install the mysql extension along with the mysqli
extension you have to use the same client library to avoid any
conflicts.
===

PHP4 doesn't support the mysqli extension, so you must compile PHP w/
--with-mysql=/your/mysql/prefix/dir

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



Re: [PHP] Recursion: Ugh!

2005-05-27 Thread Steve Brown
 Food:Fruit:Red
 Food:Fruit:Green
 Food:Fruit:Yellow
 Food:Vegetables:Long
 Food:Vegetables:Round
 Food:Vegetables:Round:Spikey
 Food:Vegetables:Round:Smooth

How is your structure being built?  Is it hard-coded or dynamic (e.g.
pulled from a DB)?  We employ a similar tree structure for manging
items in our store front.  Believe me when I say, its a hell of a lot
easier to only be concerned about the current item rathen then every
item in the sturcture.  Consider that a 1-to-many relationship is much
easier to deal with than a many-to-many relationship.  What I mean is,
if you are looking at the element Round, don't concern yourself with
Fruit or Long.  Figure out your upstream path for the current
element, e.g. Food:Vegetables (which should be easy if you assume
that each element only has 1 parent).  Then figure out the children
for the current element, e.g. Spikey and Round. KISS. :)

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



Re: [PHP] Recursion: Ugh!

2005-05-27 Thread Steve Brown
On 5/27/05, Chris W. Parker [EMAIL PROTECTED] wrote:
 Let's say you're entering a new product, you'd want to see a list of all
 the available categories, not just the last node of a branch.

Not neccesarily; it depends on how big your tree structure is.  If you
only have 10 categories where an item could be placed, a list of all
available categories might be an OK solution.  However, if you have
100 categories, listing all of them is impractical.  Even if you
only have 10 categories, you should plan for the day when you will
have 10 categories.

In our store (500 categories), you add a new item by adding a child
to the current item.  Usually we know which category we want to place
the item in before we begin to lay it up (if we don't, we can move an
item at any time simply by changing the parent of the item).  So in
your case, if you wanted to create a new item in the category Round,
you would first have to navigate to Food  Vegetables  Round, then
create the new item.  This may seem more complicated, but think about
how much time your users are going to spend scrolling through a list
of lots of categories compared to this approach.

 But I wouldn't be building the entire tree if I were only looking at a
 specific node.

That's the beauty of it! :)  You don't need the entire tree if you are
working on a specific node.  Look at it this way: you can only work on
one item at a time, right?  If you are working on the item Fruit,
why do you care that the parent of Long is Vegetables or that
Round has two children, Spikey and Smooth?

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



Re: [PHP] Recursion: Ugh!

2005-05-27 Thread Steve Brown
** email gagging, sorry if this is a DP **

On 5/27/05, Chris W. Parker [EMAIL PROTECTED] wrote:
 Let's say you're entering a new product, you'd want to see a list of all
 the available categories, not just the last node of a branch.

Not neccesarily; it depends on how big your tree structure is.  If you
only have 10 categories where an item could be placed, a list of all
available categories might be an OK solution.  However, if you have
100 categories, listing all of them is impractical.  Even if you
only have 10 categories, you should plan for the day when you will
have 10 categories.

In our store (500 categories), you add a new item by adding a child
to the current item.  Usually we know which category we want to place
the item in before we begin to lay it up (if we don't, we can move an
item at any time simply by changing the parent of the item).  So in
your case, if you wanted to create a new item in the category Round,
you would first have to navigate to Food  Vegetables  Round, then
create the new item.  This may seem more complicated, but think about
how much time your users are going to spend scrolling through a list
of lots of categories compared to this approach.

 But I wouldn't be building the entire tree if I were only looking at a
 specific node.

That's the beauty of it! :)  You don't need the entire tree if you are
working on a specific node.  Look at it this way: you can only work on
one item at a time, right?  If you are working on the item Fruit,
why do you care that the parent of Long is Vegetables or that
Round has two children, Spikey and Smooth?

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



Re: [PHP] Dynamic Generating reports to print

2005-04-23 Thread Steve Brown
 My plan is move away from the current solution but I am still confused
 of how am I going to get control of the layout of the report.
 Generate a PDF ? Use CSS ?
 
 Some of the trick parts are, for instance, to have the same header
 in all pages of the same report, if I have tabular data greater than
 the height of the page continue in the next page etc.

I used to encounter the same problems with reporting in our business
software.  You can generate reports and spit out HTML in a new window
and have the user print the report from the browser, but that has many
drawbacks.  It only works with simple data sets, its difficult (or
impossible) to control page breaks, lack of precision placing, etc.

Now I use FPDF to generate PDF reports (http://www.fpdf.org/).  Its
free, easy to use, and pretty flexible.  It allows you to do precision
placement on a page, add headers, footers, etc, etc, etc.  Be sure to
check out the Scripts section, its got a bunch of useful tips for
expanding functionality of the classes.  There is another commerical
product out there (can't thin of the name right now) that is supposed
to be faster, but FPDF is pretty fast in our applications.

I also use the JPGraph package for generating graphs
(http://www.aditus.nu/jpgraph/).  This is *really* slick.  Its free
for personal use, about $125 for commercial use.  You need to install
some additional PHP libraries (JPEG, PNG, GD at least), but its fast
and easy.  I love playing around with this product because the
possibilities for what you can do are almost endless.

HTH,
Steve

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



[PHP] String parsing issue in PHP 4.3.10?

2004-12-21 Thread Steve Brown
I'm working on a script that will parse through a long string using
regexs to pattern match a certain format.  I'm having an issue with a
'?' in a string being picked up as an end-of-code character, but only
if the line before it is commented out.  If the line before is NOT
commented out, PHP processes the file as normal (errors out, but I can
fix that).  I'd appreciate it if someone else could run this script
and see what happens.

PHP Version:
$ php --version
PHP 4.3.10 (cli) (built: Dec 20 2004 10:45:58)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

PHP Config line:
./configure --with-mysql --with-apxs2=/pub/apache/bin/apxs
--with-mcrypt=/usr/local/lib --with-curl=/usr/local --enable-ftp
--with-imap=/usr/local/imap --with-jpeg --with-jpeg-dir=/usr/local/lib
--with-png --with-png-dir=/usr/local/lib
--with-zlib-dir=/usr/local/lib --with-gd --with-freetype
--with-freetype-dir=/usr/local/lib --with-ttf

Unexpected results:
If line 16 (indicated below) is commented out, the '?' in the string
on line 17 makes PHP stop parsing and the rest of the script is simply
dumped to stdout.  If line 16 is NOT commented out, the '?' is NOT
picked up as being a PHP tag and it parses the script as PHP.

Environment:
Running in CLI on Redhat 9, current versions of all applicable
software.  The exact same behavior occurs when running as a webpage
with Apache 2.0.52.

==
?
$notes = '14 Mar 2004 18:46  Jay Brown added item to shop14 Mar 2004
19:15 Jay Brown changed production status to Ready for Publishing14
Mar 2004 19:32  Published by Jay Brown15 Mar 2004 09:22  Published
by bill Smith15 Mar 2004 09:57 Published by Bill Smith16 Jun 2004
14:28 Julie Johnson repriced all options.
16 Jun 2004 14:29 Julie Johnson repriced all options.6/16/2004 14:29
Julie Johnson committed pricing changes.
 
29 Jun 2004 09:21 Published by Bill Smith07 Jul 2004 11:42 Bill
Smith changed production status to Ready for Publishing
 
07 Jul 2004 13:44 Published by Bill Smith20 Jul 2004 13:07 Bonie
Jackson changed production status to Ready for Publishing
 
21 Jul 2004 08:36 Published by Bill Smith';
 
 
# Attempt to split the notes
#   echo $notes.\n;
$time_exp = '/\d{1,2} \w{3} \d{4} \d{2}:\d{2}/';
   $note_exp = '/\d{1,2} \w{3} \d{4} \d{2}:\d{2}\s? [!-~ ]+/'; 
// COMMENT OUT THIS LINE
$note_exp = '/\d{1,2}\/\d{1,2}\/\d{2,4} \d{2}:\d{2}\s?
[!-~]+/';  // PHP STOPS PARSING HERE
 
// Attempt to split the notes...
if (preg_match($note_exp, $notes) == 0)
{
echo No match found for .$record['ID'].!:\n;
echo $notes.\n\n\n;
continue;
}
$count = preg_match_all ($note_exp, $notes, $splits);
$notes = $splits[0];
 
// Check for notes within notes... This can happen when
there are a missing line break in a note...
$temp = array();
foreach ($notes as $note)
{
while (preg_match($note_exp, $note)  0)
{
preg_match_all($note_exp, $note, $splits,
PREG_OFFSET_CAPTURE, 5);  // Find the next substring match... 
  if (isset ($splits[0][0]))
{
$temp[] = substr($note, 0, $splits[0][0][1]);
$note = $splits[0][0][0];
}
else break;
}
$temp[] = $note;
}
$notes = $temp;
 
// Remove any duplicate notes
$unique_notes = array();
foreach ($notes as $note)
{
if (!in_array($note, $unique_notes))
$unique_notes[] = $note;
}
 
# Split the note into different fields for storing in the DB...
$item_notes = array();  $count = 1;
foreach ($unique_notes as $note)
{
 
// Find the timestamp...
preg_match_all ($time_exp, $note, $splits);
$timestamp = $splits[0][0];
 
// Convert it to a legitimate timestamp...
$ansi_timestamp = date('Y-m-d H:i:s', strtotime($timestamp));
 
// Find the note itself...
$note_divider = strpos($note, '');
$note_only = trim(substr($note, $note_divider+1));
 
$a = array();
$a['RecordID'] = $record['Target'];
$a['Timestamp'] = $ansi_timestamp;
$a['Log'] = addslashes($note_only);
$all_notes[] = $a;
 
$count++;
}
 
foreach ($all_notes as $data)
{
echo '{ Timestamp='.$data['Timestamp'].', RecordID =
'.$data['RecordID'].', Log='.$data['Log'].' }';
}
 
?
==

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



Re: [PHP] String parsing issue in PHP 4.3.10?

2004-12-21 Thread Steve Brown
 Quote:  The one-line comment styles actually only comment to the end of the 
 line or the current block of PHP code, whichever comes first. This means that 
 HTML code after // ? WILL be printed: ? skips out of the PHP mode and 
 returns to HTML mode, and // cannot influence that. If asp_tags configuration 
 directive is enabled, it behaves the same with // %.

I read that too, but my problem is with the fact that if the previous
line is NOT commented out, the script works fine.  You will notice
that the previous line also contains a '?' sequence, so I'm confused
as to why this would die on one line but not the other?   Or is this
some freak combination of comments and PHP tags? :-o

At any rate, I managed to work around this issue by encapsulating the
'\s?' partion of the expression in parentheses.

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



Re: [PHP] php editor or php IDE for linux with autocompletion

2004-11-30 Thread Steve Brown
  Does anyboy know about a linux based php editor with autocompletion? Must
  be open source free software (free as in speech, not beer).

I use the PHPEclipse add on for the Eclipse IDE.  Eclipse provides a
fantastic suite of tools for coding in almost any language.  The
PHPEclipse add-ons provide some things that are specific to PHP. 
Eclipse is java based, so it works on any platform.

Eclipse: http://www.eclipse.org/
PHPEclipse: http://www.phpeclipse.de/

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



Re: [PHP] SOAP w/PHP 4

2004-10-29 Thread Steve Brown
 Does PHP 4 support SOAP, or does something have to be added to it??

We use the NuSOAP package in our SOAP apps: 
http://dietrich.ganx4.com/nusoap/index.php

We had to use the latest CVS version of NuSOAP to get all of our apps
working correctly, NOT the current Stable version however.

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



Re: [PHP] Virtual Host problem

2004-09-23 Thread Steve Brown
 Someone correct me if I am wrong, but haven't you just confused the
 hell out of Apache?  You have just declared three virtual hosts, all
 listening on port 80, but apache has no way to identify them based on
 the incoming packets.  You need to add a ServerName directive to
 each virtual host configuration in order to get the hosts working
 correctly.

Ack!  Scratch that... didn't read enough. :-o

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



Re: [PHP] mysql_connect does not connect

2004-09-20 Thread Steve Brown
 I definitely mind. I don't believe in rewarding bad behavior. It is
 reasonable to contribute to the productive development of solutions, but the
 attitude in this group is not productive. I have the impression that the
 real reason you want answers is so that you can continue in unproductive
 directions.

Boy, for someone who has over 12k posts on some VC++ forum, you don't
seem to have a positive and productive attitude here.  Personally, I
just think your an arogant ass.

BTW, for those of you who can't read between the lines, this means it
was a firewall issue.  Egads!

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



Re: [PHP] mysql_connect does not connect

2004-09-17 Thread Steve Brown
snip lots of garbage

OK, I'm going to jump in and try and take a stab at this.  

Sam, if you wouldn't mind answering a question: are you still unable
to connect to your mysql server?

I'll also add that your understanding of firwalls is lacking. 
Regardless of where your server is (local or remote), there is still a
client-server relationship happening.  If you are trying to connect to
localhost/127.0.0.1 (use the latter as previously recommended), your
system is acting as the server.  ANY consumer firewall (free or
otherwise) is going to block incoming packets not related to an
already established connection, regardless of where they originate.

Lots of consumer firewalls are going filter traffic on localhost
because lots of vicious spyware out there are starting to install
daemons on systems then rewiriting the HOSTS files to pull ads from
the localhost rather then hitting the marketers servers.  If you don't
believe me, google for spyware HOSTS file.  To assume that your
firewall (ZoneAlarm, XP, or otherwise) is not in play here is false.

At this point, you need to disable the firewall completely (just for
testing) and/or find a way to open the MySQL port (port 3306) on
localhost to incoming traffic in your firewall.  I know that you don't
think this is the problem, but the only way you are going to know is
if you try.

I'm sorry that you feel its a time-consuming process.  I'm sorry that
you are confused about the involvement of the firewall.  I'm sorry
that you feel you know better than everyone on this list.  Just try
this and prove us wrong.

Steve

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



Re: [PHP] sorting multidimensional array by a second level value

2004-09-17 Thread Steve Brown
 I'd like to sort the array based on one of the values in the field
 href, description, or time. Is there a canonical way of doing this?

Probably easiest to write your own sort function the use usort(), 
http://www.php.net/usort has pretty good documentation on how to
accomplish this.

Steve

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



Re: [PHP] reading from files

2004-09-17 Thread Steve Brown
 I am wondering how to read lines from a file to a php array? I would like to
 integrate a logfile into a html site. Is it possible to read line by line and to
 check how many lines there are in total?

I'm new here, so someone please tell me if RTFM is frowned upon as a
response. :)

http://www.php.net/fgets

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



Re: [PHP] Intermittent Seg Fault with PHP4.3.8 + FTP

2004-09-08 Thread Steve Brown
 OK. Sounds like a genuine segfault to me. The CLI version will simply print
 Segmentation fault to the screen or Segmentation fault (core dumped)
 when configured with debugging enabled.

Thanks for the help Jim.  I had to install gdb and recompile php, but
I was able to get consistant backtraces from both systems.  When the
fault occured, the backtrace was identical every time.  It appears to
be an issue with memchr() in ftp_get():

=
Program received signal SIGSEGV, Segmentation fault.
0x4207bae0 in memchr () from /lib/tls/libc.so.6
(gdb) bt
#0  0x4207bae0 in memchr () from /lib/tls/libc.so.6
#1  0x0807ebb0 in ftp_get (ftp=0x8366c4c, outstream=0x83a2204,
path=0x839868c /x-stuff/mir_libraries/lib-nusoap-066.php,
type=FTPTYPE_ASCII, resumepos=0)
   at /usr/local/src/php-4.3.8/ext/ftp/ftp.c:730
#2  0x0807bf69 in zif_ftp_get (ht=4, return_value=0x83a0f9c,
this_ptr=0x0, return_value_used=1) at
/usr/local/src/php-4.3.8/ext/ftp/php_ftp.c:637
#3  0x081ecfb0 in execute (op_array=0x836c920) at
/usr/local/src/php-4.3.8/Zend/zend_execute.c:1635
#4  0x081ed22b in execute (op_array=0x836d648) at
/usr/local/src/php-4.3.8/Zend/zend_execute.c:1679
#5  0x081ed22b in execute (op_array=0x8366b74) at
/usr/local/src/php-4.3.8/Zend/zend_execute.c:1679
#6  0x081d9783 in zend_execute_scripts (type=8, retval=0x0,
file_count=3) at /usr/local/src/php-4.3.8/Zend/zend.c:891
#7  0x0819e9b7 in php_execute_script (primary_file=0xbad0) at
/usr/local/src/php-4.3.8/main/main.c:1734
#8  0x081f3e3d in main (argc=2, argv=0xbb64) at
/usr/local/src/php-4.3.8/sapi/cli/php_cli.c:822
===

I did some searching through the bug list and didn't find anything
that appeared to be related to this issue.  I've created bug #30027,
so hopefully this will be addressed soon.  Thanks for your help!

Steve

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



Re: [PHP] Intermittent Seg Fault with PHP4.3.8 + FTP

2004-09-08 Thread Steve Brown
 ...and just for clarification... after re-reading my response to you it came
 to my attention that one might assume I'm somehow involved with PHP
 development.

You mean you won't be the person fixing this bug??  Man, I'm screwed
now!  j/k ;-)

No worries!

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



[PHP] Intermittent Seg Fault with PHP4.3.8 + FTP

2004-09-07 Thread Steve Brown
I'm using PHP to write some backup scripts.  One of the scripts uses
PHP to connect via FTP to a server, download some scripts and tar them
up.  I'm getting intermittent segmentation faults with this script,
and I'm not sure what to report to troubleshoot this.  Can someone
tell me what would be useful information to help determine the case of
this seg fault?  Thanks.

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



Re: [PHP] Intermittent Seg Fault with PHP4.3.8 + FTP

2004-09-07 Thread Steve Brown
 1) Environment
 a) OS
 b) PHP Version
 c) CLI or web-based
 d) Are you running php as an apache module?

I'm runnning PHP 4.3.8 in CLI on Redhat 9 in this particular case. 
PHP compiled with --enable-ftp (among other things).  PHP is installed
as an Apache2 module, but (obviously since this is CLI), Apache isn't
involved here.  All other scripts work fine (CLI and web-based). 
Server is a dual MP 1600+.  I've got the same setup running on a
non-SMP server  and it also seg faults at about the same place.

 2) Logs/errors
 a) example from log file (just the error line(s))
 b) what is segfaulting? (Apache, PHP, Kernel, other)
 c) Any error messages?

I assume this is PHP seg faulting as I'm running CLI here.  No error
messages or anything (not hiding them or anything like that).  Nothing
in the sys logs.  The script runs for a while (I've got it echoing
what file it is d/l'ing), but then displays Segmentation Fault after
it downloads several files.

 3) Any other pertinent information

It does not die after a specific file, e.g. it dies randomly.  Also,
if I reduce the number of files to be d/l'ed, it won't seg fault. 
Usually it faults after d/ling about 210 files (it varies), but I've
seen it go as high as 290.  Its actually made it all the way through
the script once today, but seg faults most of them time.

The random nature leads me to believe that this is some sort of
harmful interaction between this server and the FTP server.  The FTP
server is a Windows-based host.  An almost identical script runs just
fine while connecting to other servers.

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