Re: [PHP] How do I remove a string from another string in a fuzzy way?

2013-05-21 Thread Tedd Sperling
On May 20, 2013, at 10:17 PM, Daevid Vincent  wrote:
Initially I was thinking that somehow I could use a simple regex on the
> needle and haystacks to strip out all white space and str_ireplace() them
> that way, but then I don't have a way to put the whitespace back that I can
> see.

Daevid:

Go ahead and strip out the whitespace, but replace it with a delimiter string 
that is unique and then don't consider that delimiter when comparing strings to 
strings.

Afterwards, if you want to keep the string (instead of deleting it), then 
reverse the process adding back in the whitespace and removing the delimiter.

Also, you may want to look into using array_unique() for comparing groupings of 
several strings (i.e., paragraphs) to other groupings. It works pretty slick 
for me.

Cheers,

tedd

_
tedd.sperl...@gmail.com
http://sperling.com


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



RE: [PHP] How do I remove a string from another string in a fuzzy way?

2013-05-20 Thread Daevid Vincent


> -Original Message-
> From: muquad...@gmail.com [mailto:muquad...@gmail.com] On Behalf Of shiplu
> Sent: Monday, May 20, 2013 9:03 PM
> To: Daevid Vincent
> Cc: php-general General List
> Subject: Re: [PHP] How do I remove a string from another string in a fuzzy
> way?
> 
> Is your ticketing system written from scratch? Because such type of logic
> is already implemented in existing help desk softwares.

Yes written from scratch years ago.

> I think you can also use a specific string in your email to define which
> part goes in ticket and which part not. For example, you can include
> "PLEASE REPLY ABOVE THIS LINE\r\n" in each of the email. When reply comes
> you can split the whole email with this string and get the first part as
> original reply.

We have like 20,000 tickets in there already. Asking the users (who are not the 
brightest people on the planet to begin with given the vast majority of tickets 
I've encountered. Most don't read simple instructions as it is and many don't 
even speak Engrish) to follow some instructions is probably not going to work. 
And even if it did, that doesn't solve the problem for previous tickets.


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



Re: [PHP] How do I remove a string from another string in a fuzzy way?

2013-05-20 Thread shiplu
Is your ticketing system written from scratch? Because such type of logic
is already implemented in existing help desk softwares.

I think you can also use a specific string in your email to define which
part goes in ticket and which part not. For example, you can include
"PLEASE REPLY ABOVE THIS LINE\r\n" in each of the email. When reply comes
you can split the whole email with this string and get the first part as
original reply.


-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader


[PHP] How do I remove a string from another string in a fuzzy way?

2013-05-20 Thread Daevid Vincent
We have a support ticket system we built and customers can reply via email
which then posts their reply into our database. The problem is that when you
read a ticket, you see each ticket entry (row in DB) but they tend to
accumulate the previous entries text since the customer replied to an email.
A thread if you will.

I'm trying to strip out the "duplicate parts" (cosmetically on the front end
via a checkbox, in case the support person needs to see the actual unaltered
version such as in cases where the algorithm may be too aggressive and rip
out important pieces inadvertently).

One challenge I'm running into are situations like this, where the text is
embedded but has been slightly altered.

ENTRY 1:

For security and confidentiality reasons, we request that all subscribers
who are requesting cancellation do so via the website of the company billing
their account. You can easily cancel your membership on our billing agent
website

(just in case THIS PHP list software mangles the above, it is just one long
string with no CR breaks as the ones below have)

ENTRY 2: (which was mangled by the customer's email client most likely and
formatted for 72 chars)

For security and confidentiality reasons, we request that all
subscribers who are requesting cancellation do so via the website of
the company billing their account. You can easily cancel your 
membership on our billing agent website

This is a simple example, but the solution logic might extend to other
things such as perhaps a prefix like so:

ENTRY 3: (again mangled by email client to prefix with ">" marks)

> For security and confidentiality reasons, we request that all
> subscribers who are requesting cancellation do so via the website of
> the company billing their account. You can easily cancel your 
> membership on our billing agent website

Keep in mind those blobs of text are often embedded inside other text which
I *do* want to display.

Initially I was thinking that somehow I could use a simple regex on the
needle and haystacks to strip out all white space and str_ireplace() them
that way, but then I don't have a way to put the whitespace back that I can
see.

Currently I'm just sort of brute forcing it and comparing the current
message to previous ones and if the previous message is found in this
message, then blank it out. But this only works of course if they are
identical.

get_message(false); 

foreach($my_ticket->get_entries() as $eid => $entry) 
{ 
$i++;
$output_message = $entry_message[$i] = trim($entry['message']);
//var_dump('OUTPUT MESSAGE:', $output_message);

for ($j = ($i - 1); $j >= 0; --$j)
{
//echo "\nsearching for
entry_message[$j] in [i = $i]:\n$output_message\n";
$output_message = str_replace($entry_message[$j], '',
$output_message);
//var_dump('NEW OUTPUT MESSAGE:', $output_message);
}

( ^ you have to start from the bottom up like that or else you have altered
your $output_message so subsequent matches fail ^ )

Would these be helpful? 

http://us2.php.net/manual/en/function.similar-text.php
http://us2.php.net/manual/en/function.levenshtein.php
http://us2.php.net/manual/en/function.soundex.php
http://us2.php.net/manual/en/function.metaphone.php

It seems like similar_text() could be, and if it's a high percentage,
consider it a match, but then how do I extract that part from the source
string, since str_replace() requires an exact match, not fuzzy.

I am also thinking maybe something with preg_replace() where I break up the
source string and take the first word(s) and last word(s) and use .*? in
between, but that has its' own challenges for example...

  /For .*? website/

On this text doesn't do the match I really want (it stops on the second
line)...

  For security and confidentiality reasons, we request that all
  subscribers who are requesting cancellation do so via the website of
  the company billing their account. You can easily cancel your 
  membership on our billing agent website
  More stuff goes here website

By putting more words before and after the .*? I could get better accuracy,
but that is starting to feel hacky or fragile somehow.



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



RE: [PHP] How do I do count the occurrence of each word?

2012-08-20 Thread Ford, Mike
> -Original Message-
> From: Marco Behnke [mailto:ma...@behnke.biz]
> Sent: 19 August 2012 06:39
> To: php-general@lists.php.net
> Subject: Re: [PHP] How do I do count the occurrence of each word?
> 
> Am 19.08.12 06:59, schrieb tamouse mailing lists:
> > On Sat, Aug 18, 2012 at 6:44 PM, John Taylor-Johnston
> >  wrote:
> >> I want to parse this text and count the occurrence of each word:
> >>
> >> Sample Output:
> >>
> >> determined = 4
> >> fire = 7
> >> patrol = 3
> >> theft = 6
> >> witness = 1
> >> witnessed = 1
> >>

[...]

> > and then you just run through the words building an associative
> array
> > by incrementing the count of each word as the key to the array:
> >
> > foreach ($words as $word) {
> > $freq[$word]++;
> > }
> 
> Please an existence check to avoid incrementing not set array keys
> 
> foreach ($words as $word) {
>   if (array_key_exists($word, $freq)) {
> $freq[$word] = 1;
>   } else {
> $freq[$word]++;
>   }
> }

Erm...

   $freq = array_count_values($words)

(http://php.net/array_count_values)


Cheers!

Mike

-- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS,  LS1 3HE,  United Kingdom 
E: m.f...@leedsmet.ac.uk T: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm


Re: [PHP] How do I do count the occurrence of each word?

2012-08-18 Thread tamouse mailing lists
On Sun, Aug 19, 2012 at 12:38 AM, Marco Behnke  wrote:
> Am 19.08.12 06:59, schrieb tamouse mailing lists:
>> On Sat, Aug 18, 2012 at 6:44 PM, John Taylor-Johnston
>>  wrote:
>>> I want to parse this text and count the occurrence of each word:
>>>
>>> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html;
>>> #Can I do this?
>>> $stripping = strip_tags($text); #get rid of html
>>> $stripping = strtolower($stripping); #put in lowercase
>>>
>>> 
>>> First of all I want to start AFTER the expression "News Releases" and stop
>>> BEFORE the next occurrence of "-30-"
>>>
>>> #This may occur an undetermined number of times on
>>> http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>>>
>>>
>>> 
>>> Second, do I put $stripping into an array to separate each word by each
>>> space " "?
>>>
>>> $stripping = implode(" ", $stripping);
>>>
>>> 
>>> Third how do I count the number of occurrences of each word?
>>>
>>> Sample Output:
>>>
>>> determined = 4
>>> fire = 7
>>> patrol = 3
>>> theft = 6
>>> witness = 1
>>> witnessed = 1
>>>
>>> 
>>> >> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>>> #echo strip_tags($text);
>>> #echo "\n";
>>> $stripping = strip_tags($text);
>>>
>>> #Get text between "News Releases" and stop before the next occurrence of
>>> "-30-"
>>>
>>> #$stripping = str_replace("\r", " ", $stripping);# getting rid of \r
>>> #$stripping = str_replace("\n", " ", $stripping);# getting rid of \n
>>> #$stripping = str_replace("  ", " ", $stripping);# getting rid of the
>>> occurrences of double spaces
>>>
>>> #$stripping = strtolower($stripping);
>>>
>>> #Where do I go now?
>>> ?>
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>> This is usually a first-year CS programming problem (word frequency
>> counts) complicated a little bit by needing to extract the text.
>> You've started off fine, stripping tags, converting to lower case,
>> you'll want to either convert or strip HTML entities as well, deciding
>> what you want to do with plurals and words like "you're", "Charlie's",
>> "it's", etc, also whether something like RFC822 is a word or not
>> (mixed letters and numbers).
>>
>> When you've arranged all that, splitting on white space is trivial:
>>
>> $words = preg_split('/[[:space:]]+/',$text);
>>
>> and then you just run through the words building an associative array
>> by incrementing the count of each word as the key to the array:
>>
>> foreach ($words as $word) {
>> $freq[$word]++;
>> }
>
> Please an existence check to avoid incrementing not set array keys
>
> foreach ($words as $word) {
>   if (array_key_exists($word, $freq)) {
> $freq[$word] = 1;
>   } else {
> $freq[$word]++;
>   }
> }

Ah, yes, good point -- as written, my code will raise two notices. In
addition, "declare" the $freq array:

$freq=array();

as well before the foreach loop to ensure notice-free operation.

>
>
>>
>> For output, you may want to sort the array:
>>
>> ksort($freq);
>>
>
>
> --
> Marco Behnke
> Dipl. Informatiker (FH), SAE Audio Engineer Diploma
> Zend Certified Engineer PHP 5.3
>
> Tel.: 0174 / 9722336
> e-Mail: ma...@behnke.biz
>
> Softwaretechnik Behnke
> Heinrich-Heine-Str. 7D
> 21218 Seevetal
>
> http://www.behnke.biz
>
>

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



Re: [PHP] How do I do count the occurrence of each word?

2012-08-18 Thread Marco Behnke
Am 19.08.12 06:59, schrieb tamouse mailing lists:
> On Sat, Aug 18, 2012 at 6:44 PM, John Taylor-Johnston
>  wrote:
>> I want to parse this text and count the occurrence of each word:
>>
>> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html;
>> #Can I do this?
>> $stripping = strip_tags($text); #get rid of html
>> $stripping = strtolower($stripping); #put in lowercase
>>
>> 
>> First of all I want to start AFTER the expression "News Releases" and stop
>> BEFORE the next occurrence of "-30-"
>>
>> #This may occur an undetermined number of times on
>> http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>>
>>
>> 
>> Second, do I put $stripping into an array to separate each word by each
>> space " "?
>>
>> $stripping = implode(" ", $stripping);
>>
>> 
>> Third how do I count the number of occurrences of each word?
>>
>> Sample Output:
>>
>> determined = 4
>> fire = 7
>> patrol = 3
>> theft = 6
>> witness = 1
>> witnessed = 1
>>
>> 
>> > $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>> #echo strip_tags($text);
>> #echo "\n";
>> $stripping = strip_tags($text);
>>
>> #Get text between "News Releases" and stop before the next occurrence of
>> "-30-"
>>
>> #$stripping = str_replace("\r", " ", $stripping);# getting rid of \r
>> #$stripping = str_replace("\n", " ", $stripping);# getting rid of \n
>> #$stripping = str_replace("  ", " ", $stripping);# getting rid of the
>> occurrences of double spaces
>>
>> #$stripping = strtolower($stripping);
>>
>> #Where do I go now?
>> ?>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
> This is usually a first-year CS programming problem (word frequency
> counts) complicated a little bit by needing to extract the text.
> You've started off fine, stripping tags, converting to lower case,
> you'll want to either convert or strip HTML entities as well, deciding
> what you want to do with plurals and words like "you're", "Charlie's",
> "it's", etc, also whether something like RFC822 is a word or not
> (mixed letters and numbers).
>
> When you've arranged all that, splitting on white space is trivial:
>
> $words = preg_split('/[[:space:]]+/',$text);
>
> and then you just run through the words building an associative array
> by incrementing the count of each word as the key to the array:
>
> foreach ($words as $word) {
> $freq[$word]++;
> }

Please an existence check to avoid incrementing not set array keys

foreach ($words as $word) {
  if (array_key_exists($word, $freq)) {
$freq[$word] = 1;
  } else {
$freq[$word]++;
  }
}


>
> For output, you may want to sort the array:
>
> ksort($freq);
>


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] How do I do count the occurrence of each word?

2012-08-18 Thread tamouse mailing lists
On Sat, Aug 18, 2012 at 6:44 PM, John Taylor-Johnston
 wrote:
> I want to parse this text and count the occurrence of each word:
>
> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html;
> #Can I do this?
> $stripping = strip_tags($text); #get rid of html
> $stripping = strtolower($stripping); #put in lowercase
>
> 
> First of all I want to start AFTER the expression "News Releases" and stop
> BEFORE the next occurrence of "-30-"
>
> #This may occur an undetermined number of times on
> http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>
>
> 
> Second, do I put $stripping into an array to separate each word by each
> space " "?
>
> $stripping = implode(" ", $stripping);
>
> 
> Third how do I count the number of occurrences of each word?
>
> Sample Output:
>
> determined = 4
> fire = 7
> patrol = 3
> theft = 6
> witness = 1
> witnessed = 1
>
> 
>  $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
> #echo strip_tags($text);
> #echo "\n";
> $stripping = strip_tags($text);
>
> #Get text between "News Releases" and stop before the next occurrence of
> "-30-"
>
> #$stripping = str_replace("\r", " ", $stripping);# getting rid of \r
> #$stripping = str_replace("\n", " ", $stripping);# getting rid of \n
> #$stripping = str_replace("  ", " ", $stripping);# getting rid of the
> occurrences of double spaces
>
> #$stripping = strtolower($stripping);
>
> #Where do I go now?
> ?>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

This is usually a first-year CS programming problem (word frequency
counts) complicated a little bit by needing to extract the text.
You've started off fine, stripping tags, converting to lower case,
you'll want to either convert or strip HTML entities as well, deciding
what you want to do with plurals and words like "you're", "Charlie's",
"it's", etc, also whether something like RFC822 is a word or not
(mixed letters and numbers).

When you've arranged all that, splitting on white space is trivial:

$words = preg_split('/[[:space:]]+/',$text);

and then you just run through the words building an associative array
by incrementing the count of each word as the key to the array:

foreach ($words as $word) {
$freq[$word]++;
}

For output, you may want to sort the array:

ksort($freq);

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



[PHP] How do I do count the occurrence of each word?

2012-08-18 Thread John Taylor-Johnston

I want to parse this text and count the occurrence of each word:

$text = 
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html; #Can I 
do this?

$stripping = strip_tags($text); #get rid of html
$stripping = strtolower($stripping); #put in lowercase


First of all I want to start AFTER the expression "News Releases" and 
stop BEFORE the next occurrence of "-30-"


#This may occur an undetermined number of times on 
http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html




Second, do I put $stripping into an array to separate each word by each 
space " "?


$stripping = implode(" ", $stripping);


Third how do I count the number of occurrences of each word?

Sample Output:

determined = 4
fire = 7
patrol = 3
theft = 6
witness = 1
witnessed = 1


http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
#echo strip_tags($text);
#echo "\n";
$stripping = strip_tags($text);

#Get text between "News Releases" and stop before the next occurrence of 
"-30-"


#$stripping = str_replace("\r", " ", $stripping);# getting rid of \r
#$stripping = str_replace("\n", " ", $stripping);# getting rid of \n
#$stripping = str_replace("  ", " ", $stripping);# getting rid of the 
occurrences of double spaces


#$stripping = strtolower($stripping);

#Where do I go now?
?>


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



Re: [PHP] How do I enable more useful PHP error logging?

2012-02-29 Thread Stuart Dallas
On 29 Feb 2012, at 01:13, Daevid Vincent wrote:

>> -Original Message-
>> From: Stuart Dallas [mailto:stu...@3ft9.com]
>> 
>> Seriously? Errors like this should not be getting anywhere near your
>> production servers. This is especially true if you're really getting 30k
>> hits/s.
> 
> Don't get me started. I joined here almost a year ago. They didn't even have
> a RCS or Wiki at the time. Nothing was OOP. There were no PHPDoc or even
> comments in the code. They used to make each site by copying an existing one
> and modifying it (ie. no shared libraries or resources). I could go on and
> on. Suffice it to say we've made HUGE leaps and bounds (thanks to me!), but
> there is only 3 of us developers here and no official test person let alone
> a test team.
> 
> It is what it is. I'm doing the best I can with the limited resources
> available to me.

Good stuff, but the idea that you need an official test person or a test team 
to produce solid code that minimises runtime errors is, in my opinion, 
completely the wrong attitude. I've been in similar situations several times 
and have found that the key is not to try and solve the problem in one big 
push. The key to solving the problem of a large codebase with minimal testing 
is simply to start somewhere.

Put in the infrastructure for unit testing, then make writing tests a part of 
your standard development process. Over time you will find that you are unit 
testing the majority of the code. Yes, that will make things take longer, but 
you can also be confident that when you fix a bug it stays fixed, because you 
know there's a unit test that verifies that the bug has not returned.

In my experience and opinion, limited resources is a big reason to implement 
some level of unit testing as soon as humanly possible, not a reason why you 
can't. Once you have the unit testing infrastructure in place, make running the 
tests the first step in your deployment process. You mention you now use a 
version control system, consider adding a hook to require that the unit tests 
pass before allowing code to be committed. Alternatively implement a CI 
environment which publicly ridicules anyone who checks in code which breaks the 
unit tests - it's amazing how much of a motivator this can be, even in a small 
team of seasoned professionals.

> And let me tell you a little secret, when you get to that scale, you see all
> kinds of errors you don't see on your VM or even with a test team. DB
> connections go away. Funny things happen to memcache. Concurrency issues
> arise. Web bots and search engines rape, pillage and ravage your site in
> ways that make you feel dirty. So yeah, you do hit weird situations and
> cases you can't possibly test for, but show up in error logs.

Not a secret. Not even close to being a secret. I'm no stranger to sites with 
the sort of traffic you have, and then some, and I'm fully aware that it 
presents a unique set of challenges, but there are simple steps you can take to 
make life easier.

Most of the specific issues you mention (DB connections, memcache weirdness, 
concurrency problems, and crawler activity) are the result of poor architecture 
and/or flawed server configuration. Where the architecture is poor I'd 
recommend you design a new architecture and find a way that you can start 
moving towards it, piece by piece, without having too much impact on your 
day-to-day activities. This is not always easy but I've done it several times 
and know it can be done in most situations.

There will always be issues that crop up that you couldn't possibly have known 
would happen, but you can load test your app to see what happens at levels of 
traffic an order of magnitude above that which you expect. One of my current 
clients has a test tool that can generate traffic levels that hit the limit of 
EC2 network throughput specifically to see what would happen if they had a 
sudden and dramatic increase in usage. Knowing the application can cope at 10x 
the expected level of traffic is the only way you can be sure that it can cope 
with 1x the expected traffic without breaking a sweat.

There will always be situations that you don't foresee, and conditions that are 
difficult to test, but saying that you "can't possibly test" for them is simply 
wrong.

>> For a commercial, zero-hassle solution I can't recommend
>> http://newrelic.com/ highly enough. Simple installation followed by highly
>> detailed reports with zero issues (so far). They do a free trial of all
> the
>> pro features so you can see if it gets you what you need. And no, I don't
>> work for them, I just think they've built a freakin' awesome product
> that's
>> invaluable when diagnosing issues that only occur in production. I've
> never
>> used it on a site with that level of traffic, and I'm sure it won't be a
>> problem, but you may want to only deploy it to a fraction of your
>> infrastructure.
> 
> A quick look at that product seems interesting, but not what I rea

Re: [PHP] How do I enable more useful PHP error logging?

2012-02-29 Thread Simon Schick
Hi, Daevid

What you could do to have it quick is to install the plugin xdebug.

Here you can (as described in the documentation linked here) enable to get
some extra information for a E_* message from php.
http://xdebug.org/docs/stack_trace

I would not do that on a live-system where you have 30k v/s without
changing the default configuration as there are several options that would
dramatically slow down the system.
But if you're configuring this properly I think you'll get the best
information without changing the php-code itself.

Bye
Simon

2012/2/29 Tommy Pham 

> On Tue, Feb 28, 2012 at 3:14 PM, Daevid Vincent  wrote:
> > My question is, is there a way to enable some PHP configuration that
> would
> > output more verbose information, such as a backtrace or the URL
> attempted?
> >
>
> Have you looked at log4php? [1] It's a log4j (Java based) logging
> facility port to PHP.  IIRC for log4j, you can do various logging from
> FINEST, FINER, FINE, INFO, WARNING, ERROR (?), SEVERE levels within
> the application.  You can adjust levels as needed at run time.  You
> may want to have a wrapper that will do back trace and record the
> requested URL.  The log4* facility does rolling file logging, DB,
> e-mail, syslog, etc.  (I've used the log4j and log4net before.)  Very
> handy and flexible, IMO.
>
> HTH,
> Tommy
>
>
> [1] http://logging.apache.org/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] How do I enable more useful PHP error logging?

2012-02-28 Thread Tommy Pham
On Tue, Feb 28, 2012 at 3:14 PM, Daevid Vincent  wrote:
> My question is, is there a way to enable some PHP configuration that would
> output more verbose information, such as a backtrace or the URL attempted?
>

Have you looked at log4php? [1] It's a log4j (Java based) logging
facility port to PHP.  IIRC for log4j, you can do various logging from
FINEST, FINER, FINE, INFO, WARNING, ERROR (?), SEVERE levels within
the application.  You can adjust levels as needed at run time.  You
may want to have a wrapper that will do back trace and record the
requested URL.  The log4* facility does rolling file logging, DB,
e-mail, syslog, etc.  (I've used the log4j and log4net before.)  Very
handy and flexible, IMO.

HTH,
Tommy


[1] http://logging.apache.org/

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



RE: [PHP] How do I enable more useful PHP error logging?

2012-02-28 Thread Daevid Vincent
> -Original Message-
> From: Stuart Dallas [mailto:stu...@3ft9.com]
> 
> Seriously? Errors like this should not be getting anywhere near your
> production servers. This is especially true if you're really getting 30k
> hits/s.

Don't get me started. I joined here almost a year ago. They didn't even have
a RCS or Wiki at the time. Nothing was OOP. There were no PHPDoc or even
comments in the code. They used to make each site by copying an existing one
and modifying it (ie. no shared libraries or resources). I could go on and
on. Suffice it to say we've made HUGE leaps and bounds (thanks to me!), but
there is only 3 of us developers here and no official test person let alone
a test team.

It is what it is. I'm doing the best I can with the limited resources
available to me.

And let me tell you a little secret, when you get to that scale, you see all
kinds of errors you don't see on your VM or even with a test team. DB
connections go away. Funny things happen to memcache. Concurrency issues
arise. Web bots and search engines rape, pillage and ravage your site in
ways that make you feel dirty. So yeah, you do hit weird situations and
cases you can't possibly test for, but show up in error logs.
 
> For a commercial, zero-hassle solution I can't recommend
> http://newrelic.com/ highly enough. Simple installation followed by highly
> detailed reports with zero issues (so far). They do a free trial of all
the
> pro features so you can see if it gets you what you need. And no, I don't
> work for them, I just think they've built a freakin' awesome product
that's
> invaluable when diagnosing issues that only occur in production. I've
never
> used it on a site with that level of traffic, and I'm sure it won't be a
> problem, but you may want to only deploy it to a fraction of your
> infrastructure.

A quick look at that product seems interesting, but not what I really need.
We have a ton of monitoring solutions in place to get metrics and
performance data. I just need a good 'hook' to get details when errors
occur.

> If you want a homemade solution, the uncaught exceptions are easily dealt
> with... CATCH THEM, do something useful with them, and then die
gracefully.
> Rocket science this ain't!

Thanks captain obvious. :)

I can do that (and did do that), but again, at these scales, all the
text-book code you think you know starts to go out the window. Frameworks
break down. RDBMS topple over. You have to write things creatively, leanly
(and sometimes error on the side of 'assume something is there' rather than
'assume the worst' or your code spends too much time checking the edge
cases). Hit it and quit it! Get in. Get out. I can't put try/catch around
everything everywhere, it's just not efficient or practical. Even the SQL
queries we write are 'wide' and we pull in as much logical stuff as we can
in one DB call, get it into a memcache slab and then pull it out of there
over and over, rather than surgical queries to get small chunks of data
which would murder mySQL.

Part of the reason I took this job is exactly because of these challenges
and I've learned an incredible amount here (I've also had to wash the guilt
off of me some nights, as some code I've written goes against everything I
was taught and thought I knew for the past decade -- but it works and works
well -- it just FEELS wrong). We do a lot of things that would make my
college professors cringe. THAT is the difference between the REAL world and
the LAB. ;-)

> See the set_exception_handler function for an
> easy way to set up a global function to catch uncaught exceptions if you
> don't have a limited number of entry points.
> 
> You can similarly catch the warnings using the set_error_handler function,
> tho be aware that this won't be triggered for fatal errors.

And this is the meat of the solution. Thanks! I'll look into these handlers
and see if I can inject it into someplace useful. I have high hopes for this
now.

> But seriously... a minimal level of structured testing would prevent
issues
> like this being deployed to your production servers. Sure, instrument to
> help resolve these issues now, but if I were you I'd be putting a lot of
> effort into improving your development process. Contact me off-list if
you'd
> like to talk about this in more detail.

See above. I have begged for even a single dedicated tester. I have offered
to sacrifice the open req I had for a junior developer to get a tester. That
resulted in them taking away the req because "clearly I didn't need the
developer then" and "we can just test it ourselves". You're preaching to the
choir my friend. I've been doing this for 15+ years at various companies.
;-)

d.


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



Re: [PHP] How do I enable more useful PHP error logging?

2012-02-28 Thread Stuart Dallas
On 28 Feb 2012, at 23:14, Daevid Vincent wrote:

> My question is, is there a way to enable some PHP configuration that would
> output more verbose information, such as a backtrace or the URL attempted?
> 
> In our PHP error log, we have the usual semi-useful information. However
> this is only a partial story as it's hard to re-create the URL that caused
> the error. In the first Actor example, yeah actor_id 2206 doesn't exist and
> so now I have put a try/catch on all pages that have "new Actor($actor_id)"
> but it doesn't tell me WHY this is happening. How did someone get to this
> point? I doubt they just randomly picked '2206' which happens to be one of
> only a handful of actually missing actors out of 100k. Sure I guess it could
> be a bot that sequentially tried them all, but this is not likely since we
> have SEO style URLs and so we re-map an actor name back to the ID. So the
> bot would have to try NAMEs not IDs. This means we must have some link
> somewhere that points to this. Same with the common foreach() warnings
> below. Yeah, the array being passed is empty/null. Sure I can check the
> array before doing the foreach() or even @foreach() but that doesn't tell me
> the root cause. What video are they trying to access that has no scenes or
> invalid actors?
> 
> We do NOT have apache logging turned on as we get 30,000 hits per second and
> it would be too expensive. I only care about PHP errors like this. And the
> apache error log (which we do have enabled) doesn't have useful info related
> to these kinds of issues as they're really not apache's problem. That log
> only deals with missing files/images/pages/etc.
> 
> [28-Feb-2012 13:43:19 UTC] PHP Fatal error:  Uncaught exception 
> 'ObjectNotFound' with message 'There is no such object Actor [2206].' in 
> /home/SHARED/classes/base.class.php:103
> Stack trace:
> #0 /home/SHARED/classes/actor.class.php(61): Base->load_from_sql()
> #1 /home/m.videosz.com/browse_scenes.php(89): Actor->__construct(2206)
> #2 {main}
>   thrown in /home/SHARED/classes/base.class.php on line 103
> 
> [28-Feb-2012 10:54:01 UTC] PHP Warning:  Invalid argument supplied for 
> foreach() in /home/m.dev.com/scene.php on line 138
> 
> [28-Feb-2012 07:22:50 UTC] PHP Warning:  Invalid argument supplied for 
> foreach() in /home/SHARED/classes/scene.class.php on line 423

Seriously? Errors like this should not be getting anywhere near your production 
servers. This is especially true if you're really getting 30k hits/s.

For a commercial, zero-hassle solution I can't recommend http://newrelic.com/ 
highly enough. Simple installation followed by highly detailed reports with 
zero issues (so far). They do a free trial of all the pro features so you can 
see if it gets you what you need. And no, I don't work for them, I just think 
they've built a freakin' awesome product that's invaluable when diagnosing 
issues that only occur in production. I've never used it on a site with that 
level of traffic, and I'm sure it won't be a problem, but you may want to only 
deploy it to a fraction of your infrastructure.

If you want a homemade solution, the uncaught exceptions are easily dealt 
with... CATCH THEM, do something useful with them, and then die gracefully. 
Rocket science this ain't! See the set_exception_handler function for an easy 
way to set up a global function to catch uncaught exceptions if you don't have 
a limited number of entry points.

You can similarly catch the warnings using the set_error_handler function, tho 
be aware that this won't be triggered for fatal errors.

But seriously... a minimal level of structured testing would prevent issues 
like this being deployed to your production servers. Sure, instrument to help 
resolve these issues now, but if I were you I'd be putting a lot of effort into 
improving your development process. Contact me off-list if you'd like to talk 
about this in more detail.

-Stuart

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

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



Re: [PHP] How do I enable more useful PHP error logging?

2012-02-28 Thread Adam Richardson
On Tue, Feb 28, 2012 at 6:14 PM, Daevid Vincent  wrote:

> My question is, is there a way to enable some PHP configuration that would
> output more verbose information, such as a backtrace or the URL attempted?
>
> In our PHP error log, we have the usual semi-useful information. However
> this is only a partial story as it's hard to re-create the URL that caused
> the error. In the first Actor example, yeah actor_id 2206 doesn't exist and
> so now I have put a try/catch on all pages that have "new Actor($actor_id)"
> but it doesn't tell me WHY this is happening. How did someone get to this
> point? I doubt they just randomly picked '2206' which happens to be one of
> only a handful of actually missing actors out of 100k. Sure I guess it
> could
> be a bot that sequentially tried them all, but this is not likely since we
> have SEO style URLs and so we re-map an actor name back to the ID. So the
> bot would have to try NAMEs not IDs. This means we must have some link
> somewhere that points to this. Same with the common foreach() warnings
> below. Yeah, the array being passed is empty/null. Sure I can check the
> array before doing the foreach() or even @foreach() but that doesn't tell
> me
> the root cause. What video are they trying to access that has no scenes or
> invalid actors?
>
> We do NOT have apache logging turned on as we get 30,000 hits per second
> and
> it would be too expensive. I only care about PHP errors like this. And the
> apache error log (which we do have enabled) doesn't have useful info
> related
> to these kinds of issues as they're really not apache's problem. That log
> only deals with missing files/images/pages/etc.
>
> [28-Feb-2012 13:43:19 UTC] PHP Fatal error:  Uncaught exception
> 'ObjectNotFound' with message 'There is no such object Actor [2206].' in
> /home/SHARED/classes/base.class.php:103
> Stack trace:
> #0 /home/SHARED/classes/actor.class.php(61): Base->load_from_sql()
> #1 /home/m.videosz.com/browse_scenes.php(89): Actor->__construct(2206)
> #2 {main}
>   thrown in /home/SHARED/classes/base.class.php on line 103
>
> [28-Feb-2012 10:54:01 UTC] PHP Warning:  Invalid argument supplied for
> foreach() in /home/m.dev.com/scene.php on line 138
>
> [28-Feb-2012 07:22:50 UTC] PHP Warning:  Invalid argument supplied for
> foreach() in /home/SHARED/classes/scene.class.php on line 423
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I tend to set up a custom error handler that throws exceptions
(set_error_handler()), then set up an exception handler
(set_exception_handler()) that logs the backtrace (or saves it to a db)
available using debug_backtrace().

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com


[PHP] How do I enable more useful PHP error logging?

2012-02-28 Thread Daevid Vincent
My question is, is there a way to enable some PHP configuration that would
output more verbose information, such as a backtrace or the URL attempted?

In our PHP error log, we have the usual semi-useful information. However
this is only a partial story as it's hard to re-create the URL that caused
the error. In the first Actor example, yeah actor_id 2206 doesn't exist and
so now I have put a try/catch on all pages that have "new Actor($actor_id)"
but it doesn't tell me WHY this is happening. How did someone get to this
point? I doubt they just randomly picked '2206' which happens to be one of
only a handful of actually missing actors out of 100k. Sure I guess it could
be a bot that sequentially tried them all, but this is not likely since we
have SEO style URLs and so we re-map an actor name back to the ID. So the
bot would have to try NAMEs not IDs. This means we must have some link
somewhere that points to this. Same with the common foreach() warnings
below. Yeah, the array being passed is empty/null. Sure I can check the
array before doing the foreach() or even @foreach() but that doesn't tell me
the root cause. What video are they trying to access that has no scenes or
invalid actors?

We do NOT have apache logging turned on as we get 30,000 hits per second and
it would be too expensive. I only care about PHP errors like this. And the
apache error log (which we do have enabled) doesn't have useful info related
to these kinds of issues as they're really not apache's problem. That log
only deals with missing files/images/pages/etc.

[28-Feb-2012 13:43:19 UTC] PHP Fatal error:  Uncaught exception 
'ObjectNotFound' with message 'There is no such object Actor [2206].' in 
/home/SHARED/classes/base.class.php:103
Stack trace:
#0 /home/SHARED/classes/actor.class.php(61): Base->load_from_sql()
#1 /home/m.videosz.com/browse_scenes.php(89): Actor->__construct(2206)
#2 {main}
   thrown in /home/SHARED/classes/base.class.php on line 103

[28-Feb-2012 10:54:01 UTC] PHP Warning:  Invalid argument supplied for 
foreach() in /home/m.dev.com/scene.php on line 138

[28-Feb-2012 07:22:50 UTC] PHP Warning:  Invalid argument supplied for 
foreach() in /home/SHARED/classes/scene.class.php on line 423



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



Re: [PHP] How do I enable $_SERVER['HTTP_X_WAP_PROFILE'] or $_SERVER['HTTP_PROFILE']

2011-08-04 Thread Stuart Dallas
On 3 Aug 2011, at 21:07, Daevid Vincent wrote:

> I'm working on a mobile site and from the various searches and reading (and
> even code fragments I've inherited for the project), they make reference to:
> 
> $_SERVER['HTTP_X_WAP_PROFILE'] and a fallback $_SERVER['HTTP_PROFILE']
> 
> However, when I hit a phpinfo(); page using both an Android MyTouch 3G (2.2)
> and an Apple iPhone 3G, there are nothing even close to those. All of the
> 'HTTP_X_*' headers are absent and there is no HTTP_PROFILE either.
> 
> http://www.dpinyc.com/literature/resources/code-bank/php-lightweight-device-
> detection/
> http://mobiforge.com/developing/blog/useful-x-headers
> http://blog.svnlabs.com/tag/_serverhttp_x_wap_profile/
> 
> 
> Do I need to enable something in Apache or PHP??
> 
> PHP Version 5.3.6
> Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
>with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans
> 
> and 
> 
> $ httpd -v
> Server version: Apache/2.2.17 (FreeBSD)

I may be wrong, but as I understand it those headers are for older WAP 
browsers, not modern mobile-based browsers which are HTML-capable. The best way 
I've found to detect mobile devices is to examine the user agent header. While 
it's not 100% reliable it's the best method available.

This is the function I've used in the past to detect mobile devices: 
https://gist.github.com/1124666. I haven't used it for a little while so there 
are probably new devices out there that it can't detect but it should give you 
a good starting point.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How do I enable $_SERVER['HTTP_X_WAP_PROFILE'] or $_SERVER['HTTP_PROFILE']

2011-08-03 Thread Daevid Vincent
I'm working on a mobile site and from the various searches and reading (and
even code fragments I've inherited for the project), they make reference to:

$_SERVER['HTTP_X_WAP_PROFILE'] and a fallback $_SERVER['HTTP_PROFILE']

However, when I hit a phpinfo(); page using both an Android MyTouch 3G (2.2)
and an Apple iPhone 3G, there are nothing even close to those. All of the
'HTTP_X_*' headers are absent and there is no HTTP_PROFILE either.

http://www.dpinyc.com/literature/resources/code-bank/php-lightweight-device-
detection/
http://mobiforge.com/developing/blog/useful-x-headers
http://blog.svnlabs.com/tag/_serverhttp_x_wap_profile/


Do I need to enable something in Apache or PHP??

PHP Version 5.3.6
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans

and 

$ httpd -v
Server version: Apache/2.2.17 (FreeBSD)


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



RE: [PHP] How do I convert the string "E_ALL & ~E_NOTICE" to the decimal equivalent 6135?

2010-11-12 Thread Ford, Mike
> -Original Message-
> From: Daevid Vincent [mailto:dae...@daevid.com]
> Sent: 11 November 2010 22:23
> To: php-general@lists.php.net
> 
> > -Original Message-
> > From: Ford, Mike [mailto:m.f...@leedsmet.ac.uk]
> > Sent: Thursday, November 11, 2010 12:58 AM
> > To: php-general@lists.php.net
> > Subject: RE: [PHP] How do I convert the string "E_ALL &
> > ~E_NOTICE" to the decimal equivalent 6135?
> >
> > > -Original Message-
> > > From: Daevid Vincent [mailto:dae...@daevid.com]
> > > Sent: 11 November 2010 04:06
> > > To: php-general@lists.php.net
> > >
> > > We're trying to move all of our configuration files for our
> > > DEV/TEST/PROD
> > > and various python scripts and such that all need the same DB
> > > connection
> > > parameters and pathing information to a common and simple
> config.ini
> > > file
> > > they all can share across languages.
> > >
> > > One snag I ran into is this:
> > >
> > > [dart]
> > > relative_url  = /dart2
> > > absolute_path = /home/www/dart2
> > > log_level = E_ALL & ~E_NOTICE
> > >
> > > But when I read it in from the file, it's a string (of course)
> >
> > That's odd -- parse_ini_file() should definitely translate
> > those constants!
> > It certainly works on my v5.2.5 installation.
> >
> > Cheers!
> >
> > Mike
> 
> You assume I'm using that busted-ass "parse_ini_file()" function. ;-
> )
> 
> See previous emails as to why that's a useless option for me.
> 
> I wrote a much better parser which I'll post in another email.

Ah, I see. I don't believe you mentioned that in your original query.
In that case, your only option probably is eval - something like:

eval("\$log_level_int = {$log_level_string}");

or:

$log_level_int = eval("return {$log_level_string}");

Cheers!

Mike

 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507 City Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730






To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] How do I convert the string "E_ALL & ~E_NOTICE" to the decimal equivalent 6135?

2010-11-11 Thread Daevid Vincent
 

> -Original Message-
> From: Ford, Mike [mailto:m.f...@leedsmet.ac.uk] 
> Sent: Thursday, November 11, 2010 12:58 AM
> To: php-general@lists.php.net
> Subject: RE: [PHP] How do I convert the string "E_ALL & 
> ~E_NOTICE" to the decimal equivalent 6135?
> 
> > -Original Message-
> > From: Daevid Vincent [mailto:dae...@daevid.com]
> > Sent: 11 November 2010 04:06
> > To: php-general@lists.php.net
> > 
> > We're trying to move all of our configuration files for our
> > DEV/TEST/PROD
> > and various python scripts and such that all need the same DB
> > connection
> > parameters and pathing information to a common and simple config.ini
> > file
> > they all can share across languages.
> > 
> > One snag I ran into is this:
> > 
> > [dart]
> > relative_url= /dart2
> > absolute_path   = /home/www/dart2
> > log_level   = E_ALL & ~E_NOTICE
> > 
> > But when I read it in from the file, it's a string (of course)
> 
> That's odd -- parse_ini_file() should definitely translate 
> those constants!
> It certainly works on my v5.2.5 installation.
> 
> Cheers!
> 
> Mike

You assume I'm using that busted-ass "parse_ini_file()" function. ;-)

See previous emails as to why that's a useless option for me.

I wrote a much better parser which I'll post in another email.


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



RE: [PHP] How do I convert the string "E_ALL & ~E_NOTICE" to the decimal equivalent 6135?

2010-11-11 Thread Ford, Mike
> -Original Message-
> From: Daevid Vincent [mailto:dae...@daevid.com]
> Sent: 11 November 2010 04:06
> To: php-general@lists.php.net
> 
> We're trying to move all of our configuration files for our
> DEV/TEST/PROD
> and various python scripts and such that all need the same DB
> connection
> parameters and pathing information to a common and simple config.ini
> file
> they all can share across languages.
> 
> One snag I ran into is this:
> 
> [dart]
> relative_url  = /dart2
> absolute_path = /home/www/dart2
> log_level = E_ALL & ~E_NOTICE
> 
> But when I read it in from the file, it's a string (of course)

That's odd -- parse_ini_file() should definitely translate those constants!
It certainly works on my v5.2.5 installation.

Cheers!

Mike

 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507 City Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730




To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



[PHP] How do I convert the string "E_ALL & ~E_NOTICE" to the decimal equivalent 6135?

2010-11-10 Thread Daevid Vincent
We're trying to move all of our configuration files for our DEV/TEST/PROD
and various python scripts and such that all need the same DB connection
parameters and pathing information to a common and simple config.ini file
they all can share across languages.

One snag I ran into is this:

[dart]
relative_url= /dart2
absolute_path   = /home/www/dart2
log_level   = E_ALL & ~E_NOTICE

But when I read it in from the file, it's a string (of course)

$log_level_string = "E_ALL & ~E_NOTICE";
echo 'log level string = '.eval($log_level_string.';').'';

This gives me nothing!:

log level string =

Wheras this one gives the proper values:

echo 'log bit level = '.(E_ALL & ~E_NOTICE).'';

Output is:

log bit level = 6135

But that defeats the purpose of a config file.


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



[PHP] How do I use date_diff in my code (both codes are included, mine and the example function) I need process.php

2010-05-02 Thread justino garcia
HOw would I use this function below, from this url
http://php.net/manual/en/function.date-diff.php
I need to output the subject, date, and the final answer to the calcuation
of the time difference (say from e.g. 10:00 AM to 12:00 PM) . Getting total
time wrked on at a job site, doing helpdesk. I am doing this for me to send
a preformated email to acounting, it will help since I am busy at work and
suck at counting time worked due to my adhd and dyslxia.
Thanks






This function calculates the difference up to the second.

=0 && $time<=59) {
// Seconds
$timeshift = $time.' seconds ';

} elseif($time>=60 && $time<=3599) {
// Minutes + Seconds
$pmin = ($edate - $sdate) / 60;
$premin = explode('.', $pmin);

$presec = $pmin-$premin[0];
$sec = $presec*60;

$timeshift = $premin[0].' min '.round($sec,0).' sec ';

} elseif($time>=3600 && $time<=86399) {
// Hours + Minutes
$phour = ($edate - $sdate) / 3600;
$prehour = explode('.',$phour);

$premin = $phour-$prehour[0];
$min = explode('.',$premin*60);

$presec = '0.'.$min[1];
$sec = $presec*60;

$timeshift = $prehour[0].' hrs '.$min[0].' min '.round($sec,
0).' sec ';

} elseif($time>=86400) {
// Days + Hours + Minutes
$pday = ($edate - $sdate) / 86400;
$preday = explode('.',$pday);

$phour = $pday-$preday[0];
$prehour = explode('.',$phour*24);

$premin = ($phour*24)-$prehour[0];
$min = explode('.',$premin*60);

$presec = '0.'.$min[1];
$sec = $presec*60;

$timeshift = $preday[0].' days '.$prehour[0].' hrs '.$min[0
].' min '.round($sec,0).' sec ';

}
return $timeshift;
}

// EXAMPLE:

$start_date = 2010-03-15 13:00:00
$end_date = 2010-03-17 09:36:15

echo date_diff($start_date, $end_date);

?>


*MY
CODE---===
*

"

 Hello there TechSquad!


 

MLS
ITS
JCPA
Kocher
Bagel Buffet
Warranty Title
Metalico
 
Date: 
Subject:  



' . $time[$val] . '' .
"\n";
 }
}
?>


' . $time[$val] . '' .
"\n";
 }
}
?>

Enter the work done
here.



-- 
Justin
IT-TECH



-- 
Justin
IT-TECH


Re: [PHP] How do I upgrade GD?

2010-03-20 Thread Per Jessen
PmI wrote:

> Hi,
> 
> how do I upgrade GD? PHP still comes bundled with the three year old
> version 2.0.34, even though there have been lots of bugfixes in 2.0.35
> and 2.0.36 (most importantly, 2.0.36 now actually supports unicode
> text, rather than "any unicode text as long as it's only UCS-2", which
> means any unicode using blocks introduced after 3.1 don't work).
> 
> Related to that, how would one update both GD and FreeType2?

Install/upgrade libgd and freetype2 individually, then rebuild PHP using
those libaries. 


-- 
Per Jessen, Zürich (14.2°C)


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



[PHP] How do I upgrade GD?

2010-03-20 Thread PmI
Hi, 

how do I upgrade GD? PHP still comes bundled with the three year old version
2.0.34, even though there have been lots of bugfixes in 2.0.35 and 2.0.36
(most importantly, 2.0.36 now actually supports unicode text, rather than
"any unicode text as long as it's only UCS-2", which means any unicode using
blocks introduced after 3.1 don't work).

Related to that, how would one update both GD and FreeType2?

- Mike "Pomax" Kamermans
nihongoresources.com


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



Re: [PHP] how do I use php://memory?

2010-01-29 Thread Mari Masuda

On Jan 29, 2010, at 10:57 PM, Mari Masuda wrote:

> 
> On Jan 29, 2010, at 4:38 PM, Nathan Nobbe wrote:
> 
>> On Fri, Jan 29, 2010 at 5:35 PM, Mari Masuda  
>> wrote:
>> Hello,
>> 
>> I have a function that uses tidy to attempt to clean up a bunch of crappy 
>> HTML that I inherited.  In order to use tidy, I write the crappy HTML to a 
>> temporary file on disk, run tidy, and extract and return the clean(er) HTML. 
>>  The program itself works fine but with all of the disk access, it runs 
>> quite slowly.
>> 
>> why read from disk in the first place?
>> 
>> http://us3.php.net/manual/en/tidy.parsestring.php
>> 
>> -nathan 
> 
> Thank you, this looks like exactly what I need.  Unfortunately I cannot get 
> it to work on my machine.

[snip]

So I figured it out... I was using the wrong command to compile libtidy.  (I am 
not a *nix geek so I had no idea I was messing it up.)  To get it working, I 
followed the instructions I found here: 
http://www.php.net/manual/en/ref.tidy.php#64281

My setup is slightly different from the person who wrote the directions in that 
I am running OS X 10.6.2 and PHP 5.2.12.  However, the only difference between 
the instructions I followed and what I actually had to do is that the line to 
comment out for me was line 525 instead of 508.  (The actual line is: typedef 
unsigned long ulong;)

Thank you everyone for your help!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] how do I use php://memory?

2010-01-29 Thread Mari Masuda

On Jan 29, 2010, at 4:38 PM, Nathan Nobbe wrote:

> On Fri, Jan 29, 2010 at 5:35 PM, Mari Masuda  wrote:
> Hello,
> 
> I have a function that uses tidy to attempt to clean up a bunch of crappy 
> HTML that I inherited.  In order to use tidy, I write the crappy HTML to a 
> temporary file on disk, run tidy, and extract and return the clean(er) HTML.  
> The program itself works fine but with all of the disk access, it runs quite 
> slowly.
> 
> why read from disk in the first place?
> 
> http://us3.php.net/manual/en/tidy.parsestring.php
> 
> -nathan 

Thank you, this looks like exactly what I need.  Unfortunately I cannot get it 
to work on my machine.  I recompiled PHP with --with-tidy=/usr/local and this 
is the version and modules in use:

[Fri Jan 29 22:50:41] ~: php -vPHP 5.2.12 (cli) (built: Jan 29 2010 22:35:24) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
[Fri Jan 29 22:52:30] ~: php -m
[PHP Modules]
ctype
date
dom
filter
gd
hash
iconv
json
libxml
mbstring
mysql
mysqli
pcre
PDO
pdo_mysql
pdo_sqlite
posix
Reflection
session
SimpleXML
SPL
SQLite
standard
tidy
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

[Fri Jan 29 22:52:34] ~: 


When I run this test code
=
blahhello";
$config = array('indent' => true,
'wrap' => '0');

// Tidy
$tidy = new tidy();
var_dump($tidy);
$tidy->parseString($html, $config, 'utf8');
var_dump($tidy);
$tidy->cleanRepair();
var_dump($tidy);
echo tidy_get_output($tidy);
var_dump($tidy);
?>
=

I get this output:
=
object(tidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}
object(tidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}
object(tidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}
object(tidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}


I have no clue what I'm doing wrong...

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



Re: [PHP] how do I use php://memory?

2010-01-29 Thread Jochem Maas
Op 1/30/10 1:35 AM, Mari Masuda schreef:
> Hello,
> 
> I have a function that uses tidy to attempt to clean up a bunch of crappy 
> HTML that I inherited.  In order to use tidy, I write the crappy HTML to a 
> temporary file on disk, run tidy, and extract and return the clean(er) HTML.  
> The program itself works fine but with all of the disk access, it runs quite 
> slowly.  I saw on this page (http://www.php.net/manual/en/wrappers.php.php) 
> that I could write to memory by using php://memory.  Unfortunately, I could 
> not quite get it to work.  The problem is that in the below function, the 
> code within the [[[if (file_exists($dirty_file_path))]]] does not get run if 
> I change [[[$dirty_file_path]]] to "php://memory".  Has anyone ever 
> successfully used php://memory before?  If so, what can I do to use it in my 
> code?  Thank you.

what does it matter that it runs slowly, run it once and be done with it?
alternatively use the php tidy extension and avoid the file system and shelling 
out altogether.

actually I'd imagine shelling out from a webserver process is the bottle neck 
and not saving/reading
from the file system.

lastly I don't suppose you've heard of /dev/shm ?

and, er, no, I don't have experience with php://memory but you might try 
searching for
other people's code:


http://www.google.com/codesearch?q=php%3A%2F%2Fmemory&hl=en&btnG=Search+Code

> //==
> function cleanUpHtml($dirty_html, $enclose_text=true) {
> 
>   $parent_dir = "/filesWrittenFromPHP/";
>   $now = time();
>   $random = rand();
>   
>   //save dirty html to a file so tidy can process it
>   $dirty_file_path = $parent_dir . "dirty" . $now . "-" . $random . 
> ".txt";
>   $dirty_handle = fopen($dirty_file_path, "w");
>   fwrite($dirty_handle, $dirty_html);
>   fclose($dirty_handle);
> 
>   $cleaned_html = "";
>   $start = 0;
>   $end = 0;
> 
>   if (file_exists($dirty_file_path)) {
>   exec("/usr/local/bin/tidy -miq -wrap 0 -asxhtml --doctype 
> strict --preserve-entities yes --css-prefix \"tidy\" --tidy-mark no 
> --char-encoding utf8 --drop-proprietary-attributes yes  --fix-uri yes " . 
> ($enclose_text ? "--enclose-text yes " : "") . $dirty_file_path . " 2> 
> /dev/null");
> 
>   $tidied_html = file_get_contents($dirty_file_path);
>   
>   $start = strpos($tidied_html, "") + 6;
>   $end = strpos($tidied_html, "") - 1;
>   
>   $cleaned_html = trim(substr($tidied_html, $start, ($end - 
> $start)));
>   }
>   
>   unlink($dirty_file_path);
> 
> 
>   return $cleaned_html;
> }
> //==
> 
> 


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



Re: [PHP] how do I use php://memory?

2010-01-29 Thread Nathan Nobbe
On Fri, Jan 29, 2010 at 5:35 PM, Mari Masuda wrote:

> Hello,
>
> I have a function that uses tidy to attempt to clean up a bunch of crappy
> HTML that I inherited.  In order to use tidy, I write the crappy HTML to a
> temporary file on disk, run tidy, and extract and return the clean(er) HTML.
>  The program itself works fine but with all of the disk access, it runs
> quite slowly.


why read from disk in the first place?

http://us3.php.net/manual/en/tidy.parsestring.php

-nathan


[PHP] how do I use php://memory?

2010-01-29 Thread Mari Masuda
Hello,

I have a function that uses tidy to attempt to clean up a bunch of crappy HTML 
that I inherited.  In order to use tidy, I write the crappy HTML to a temporary 
file on disk, run tidy, and extract and return the clean(er) HTML.  The program 
itself works fine but with all of the disk access, it runs quite slowly.  I saw 
on this page (http://www.php.net/manual/en/wrappers.php.php) that I could write 
to memory by using php://memory.  Unfortunately, I could not quite get it to 
work.  The problem is that in the below function, the code within the [[[if 
(file_exists($dirty_file_path))]]] does not get run if I change 
[[[$dirty_file_path]]] to "php://memory".  Has anyone ever successfully used 
php://memory before?  If so, what can I do to use it in my code?  Thank you.


//==
function cleanUpHtml($dirty_html, $enclose_text=true) {

$parent_dir = "/filesWrittenFromPHP/";
$now = time();
$random = rand();

//save dirty html to a file so tidy can process it
$dirty_file_path = $parent_dir . "dirty" . $now . "-" . $random . 
".txt";
$dirty_handle = fopen($dirty_file_path, "w");
fwrite($dirty_handle, $dirty_html);
fclose($dirty_handle);

$cleaned_html = "";
$start = 0;
$end = 0;

if (file_exists($dirty_file_path)) {
exec("/usr/local/bin/tidy -miq -wrap 0 -asxhtml --doctype 
strict --preserve-entities yes --css-prefix \"tidy\" --tidy-mark no 
--char-encoding utf8 --drop-proprietary-attributes yes  --fix-uri yes " . 
($enclose_text ? "--enclose-text yes " : "") . $dirty_file_path . " 2> 
/dev/null");

$tidied_html = file_get_contents($dirty_file_path);

$start = strpos($tidied_html, "") + 6;
$end = strpos($tidied_html, "") - 1;

$cleaned_html = trim(substr($tidied_html, $start, ($end - 
$start)));
}

unlink($dirty_file_path);


return $cleaned_html;
}
//==


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



RE: [PHP] How do I remove unused GET parameters from the URL?

2010-01-20 Thread Ashley Sheridan
On Wed, 2010-01-20 at 13:06 -0800, Daevid Vincent wrote:

> Comments inline below...
> 
> > -Original Message-
> > From: Ashley Sheridan 
> > 
> > GET has a limit on the amount of data it may carry, which is
> > reduced the longer the base URL is. 
> 
> True, but for search parameters, it's IMHO best to use GET rather than POST
> so the page can be bookmarked.
> 
> This used to be a concern "back in the day" with 255 bytes.
> 
> http://classicasp.aspfaq.com/forms/what-is-the-limit-on-querystring/get/url
> -parameters.html
> 
> Not so much anymore with most browsers supporting > 2000 characters:
> 
> http://www.boutell.com/newfaq/misc/urllength.html
> http://support.microsoft.com/kb/208427
> http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-an-
> url
> 
> Re-writing it to handle $_REQUEST doesn't seem to solve much as the user
> would still need to know the form element names and the actual form would
> be either POST/GET. GET is the problem I have now. POST is a whole other
> problem of not being able to bookmark.
> 
> > -Original Message-
> > From: Nathan Rixham 
> > 
> > to do as you say on the clientside you'd probably be best to write a
> > short js script to build the get url from the form data; and on the
> > serverside just take the klunky approach you mentioned.
> > 
> > worth thinking about scenarios where a field is empty on the initial
> > search though; but a user may want to modify it by entering in a value
> > to a previously blank field (which would at this point be 
> > stripped); so maybe removal isn't the best option.
> 
> Also a very valid point that I hadn't fully considered.
> 
> > also you could just pass the url through to an url shrinker; 
> > if you use
> > the api of bit.ly or suchlike you could do this serverside; 
> > and reap the benefits of stats for each search too.
> 
> This is for an internal intranet site so I can't use an outside shrinker,
> however I suspect the code to create my own shrinker isn't so difficult and
> this is a pretty interesting idea. Given your above observation, perhaps
> this *is* the solution to persue further...
> 
> Way to think outside the box Nathan! :)
> 
> ÐÆ5ÏÐ 
> http://daevid.com
> 


What about sending the form via POST, but to a URL that includes some
sort of session in the URL the form is sent to, for example:



Then your server script can reproduce the search from saved parameters
stored under the sid value.

This way, you retain the ability to bookmark the search, and use as many
search parameters as you need, without worrying about going over the GET
data limit no matter what browser the user has.



Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] How do I remove unused GET parameters from the URL?

2010-01-20 Thread Daevid Vincent
Comments inline below...

> -Original Message-
> From: Ashley Sheridan 
> 
> GET has a limit on the amount of data it may carry, which is
> reduced the longer the base URL is. 

True, but for search parameters, it's IMHO best to use GET rather than POST
so the page can be bookmarked.

This used to be a concern "back in the day" with 255 bytes.

http://classicasp.aspfaq.com/forms/what-is-the-limit-on-querystring/get/url
-parameters.html

Not so much anymore with most browsers supporting > 2000 characters:

http://www.boutell.com/newfaq/misc/urllength.html
http://support.microsoft.com/kb/208427
http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-an-
url

Re-writing it to handle $_REQUEST doesn't seem to solve much as the user
would still need to know the form element names and the actual form would
be either POST/GET. GET is the problem I have now. POST is a whole other
problem of not being able to bookmark.

> -Original Message-
> From: Nathan Rixham 
> 
> to do as you say on the clientside you'd probably be best to write a
> short js script to build the get url from the form data; and on the
> serverside just take the klunky approach you mentioned.
> 
> worth thinking about scenarios where a field is empty on the initial
> search though; but a user may want to modify it by entering in a value
> to a previously blank field (which would at this point be 
> stripped); so maybe removal isn't the best option.

Also a very valid point that I hadn't fully considered.

> also you could just pass the url through to an url shrinker; 
> if you use
> the api of bit.ly or suchlike you could do this serverside; 
> and reap the benefits of stats for each search too.

This is for an internal intranet site so I can't use an outside shrinker,
however I suspect the code to create my own shrinker isn't so difficult and
this is a pretty interesting idea. Given your above observation, perhaps
this *is* the solution to persue further...

Way to think outside the box Nathan! :)

ÐÆ5ÏÐ 
http://daevid.com


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



Re: [PHP] How do I remove unused GET parameters from the URL?

2010-01-20 Thread Ashley Sheridan
On Wed, 2010-01-20 at 10:30 -0800, Michael A. Peters wrote:

> Rene Veerman wrote:
> > Michael, while i respect your choices, i think you should know that
> > jquery.com is pretty good at minimizing browser-incompatibility
> > headaches (and keeping js apps small), and the quircks that are left
> > are easy enough to learn about.
> > 
> > for things whereby
> > - the server needs to generate tons of HTML for a small(ish) dataset, or
> > - the client generates data (also to be translated to html) that the
> > server doesnt really need to know about (yet)
> > 
> > js can really take some stress off the server.
> 
> I also like to run any content that has user contributed data through a 
> server side filter that enforces Content Security Policy -
> 
> http://www.clfsrpm.net/xss/
> 
> That filter makes sure the content sent to the browser does not include 
> stuff that violates the defined CSP, and thus greatly reduces the risk 
> of malicious content that input filtering missed from reaching the end user.
> 
> Furthermore, when it does catch a violation, it reports the violating to 
> a log file notifying me of the problem.
> 
> The only way that works for content generated client side would be if 
> the user was running a browser that is CSP aware, and right now, they 
> just don't exist. Firefox has an experimental add-on for CSP but 
> virtually no one uses it.
> 
> Doing dynamic content server side allows me to run that content through 
> the enforcement filter server side thus catching policy violating 
> content before it is ever sent to the user.
> 
> That itself, btw, is probably the biggest stress on the server.
> 
> I understand prototype etc. is the "web 2.0" way but I really don't have 
> a high opinion of "Web 2.0". JavaScript, flash, etc. all have been used 
> far too often to do bad things.
> 
> Right now, if I don't block except for white listed web sites, I end up 
> with advertisements I don't care about expanding and covering the 
> content I do care about. Unfortunately the web is full of jerks who do 
> rude things with scripts, and people who do malicious things with scripts.
> 
> You wouldn't execute code that someone you don't know sent you an 
> e-mail, would you? I wouldn't, nor do I execute code someone I don't 
> know embeds in a web page.
> 
> I surf with script blockers (NoScript to be specific) and when I come 
> upon web sites that don't properly function, I'm a lot liklier to head 
> elsewhere than to enable scripting for that site. Since I surf that way, 
> I expect others do as well, doing things server side that can be done 
> server side allows users like me who block scripting to access the 
> content without compromising the security of our systems.
> 


It's for users like you that I keep saying to people that Javascript
shouldn't define functionality but enhance it. People will turn their
noses up at that attitude, but, like you said, some people get downright
nasty with the things they do online with their scripts.

I've not used that CSP thing you linked to before, it looks like it's
not for validating user input going *to* your server, but to sanitise
the downstream content from your server to the users browser. Validating
user input should prevent this as best as possible, as it shouldn't lead
to output from your script being used as part of an XSS attack. However,
the real worry is with ISP's that modify your pages before they are
output to the browser, as Canadian ISP Rogers has been found doing:

http://www.mattcutts.com/blog/confirmed-isp-modifies-google-home-page/

No PHP class will be able to prevent that, as the ISP is modifying the
content en route to its destination.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] How do I remove unused GET parameters from the URL?

2010-01-20 Thread Michael A. Peters

Rene Veerman wrote:

Michael, while i respect your choices, i think you should know that
jquery.com is pretty good at minimizing browser-incompatibility
headaches (and keeping js apps small), and the quircks that are left
are easy enough to learn about.

for things whereby
- the server needs to generate tons of HTML for a small(ish) dataset, or
- the client generates data (also to be translated to html) that the
server doesnt really need to know about (yet)

js can really take some stress off the server.


I also like to run any content that has user contributed data through a 
server side filter that enforces Content Security Policy -


http://www.clfsrpm.net/xss/

That filter makes sure the content sent to the browser does not include 
stuff that violates the defined CSP, and thus greatly reduces the risk 
of malicious content that input filtering missed from reaching the end user.


Furthermore, when it does catch a violation, it reports the violating to 
a log file notifying me of the problem.


The only way that works for content generated client side would be if 
the user was running a browser that is CSP aware, and right now, they 
just don't exist. Firefox has an experimental add-on for CSP but 
virtually no one uses it.


Doing dynamic content server side allows me to run that content through 
the enforcement filter server side thus catching policy violating 
content before it is ever sent to the user.


That itself, btw, is probably the biggest stress on the server.

I understand prototype etc. is the "web 2.0" way but I really don't have 
a high opinion of "Web 2.0". JavaScript, flash, etc. all have been used 
far too often to do bad things.


Right now, if I don't block except for white listed web sites, I end up 
with advertisements I don't care about expanding and covering the 
content I do care about. Unfortunately the web is full of jerks who do 
rude things with scripts, and people who do malicious things with scripts.


You wouldn't execute code that someone you don't know sent you an 
e-mail, would you? I wouldn't, nor do I execute code someone I don't 
know embeds in a web page.


I surf with script blockers (NoScript to be specific) and when I come 
upon web sites that don't properly function, I'm a lot liklier to head 
elsewhere than to enable scripting for that site. Since I surf that way, 
I expect others do as well, doing things server side that can be done 
server side allows users like me who block scripting to access the 
content without compromising the security of our systems.


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



Re: [PHP] How do I remove unused GET parameters from the URL?

2010-01-20 Thread Ashley Sheridan
On Tue, 2010-01-19 at 20:55 -0800, Daevid Vincent wrote:

> I have an HTML form with a hundred or so elements on it, used for searching
> a database.
>  
> When the user submits the form (via GET) the URL is loaded with ALL of
> these fields, and many of them are not even actually used in the search
> criteria.
>  
> https://mypse/dart2/ps_search.php?enter_date=2009-11-30&id_incident=&incide
> nt_date=&incident_hh=0&incident_mm=0&id_urgency_level=0&problem_description
> =&immediate_action=&unit_opened=&unit_authorized=&customer=&customer_contac
> t=&customer_address=&customer_country=&id_location=0&passengers_onboard=&su
> bmit=Search&part_number=&serial_number=&nomenclature=&manufacture_date=&mod
> _level=&id_lru_condition=&repair_history=&ac_type=&tail_number=&id_system_t
> ype=&id_lru_location=0&circuit_breaker=&circuit_breaker_amps=&seat_number=&
> seat_vendor=&seat_column_zone=&seat_zone=&tc_holder=&stc_holder=&asr_mor=&i
> mpounded=&id_authority=&id_region=&reported_by=&prepared_by=&preparer_locat
> ion=&field_engineer=&id_attach_pictures=&id_attach_mlr=&id_attach_lopa=&cab
> in_log=&parts_inspect=&id_organization=0&id_quality_engineer=0&car_number=&
> close_date=&closed_by=&qa_comment=&id_priority=&id_action=0&id_incident_sta
> tus=3&id_failure_type=&detail_status=&investigation_result=&osaka_action=&o
> saka_request=&newvsrepeat=&related_incident=&unit_received_date=&unit_retur
> ned_date=&tdr_to_pso_date=&tdr_date=&dcr_date=&dcr_reference_number=&ecr_da
> te=&ecr_reference_number=&eco_date=&eco_reference_number=&service_bulletin_
> date=&sb_reference_number=&sil_issue_date=&sil_reference_number=&til_issue_
> date=&til_reference_number=&customer_letter_issue_date=&subassembly=&rdm=&p
> svector=&oemmanuf=&defective_part_1=&defective_part_2=&defective_part_3=&de
> fective_part_4=
>  
> Is there some way via PHP/Apache Mod/Javascript to remove all the keys that
> don't have any value in them and just distill this down to the
> elements/keys that the user actually entered some input for? ie. defaulting
> all the rest to 'blank'.
>  
> In PHP, this would look something like this:
>  
> foreach ($_GET as $k => $v) if ($v == '') unset($_GET[$k]);
>  
> The problem as I see it, is that this "magic" happens when the user hits
> "Submit", so not sure PHP has any way to intercept at that point.
> Javascript might be able to do something on the "onClick" event or
> "onSubmit" I suspect. But this seems like something that someone should
> have solved before and common enough that I would think Apache could handle
> it transparently with a directive or module enabled so I don't have to code
> some hack on every page.
>  
> I guess I could always redirect to some 'scrubber' page that strips them
> out and redirects on to the refering page again, but that seems klunky.
>  
> BTW, I want to use GET so that the page can be bookmarked for future
> searches of the same data (or modified easily with different dates, etc.),
> so that's why I don't use POST.


You can't remove the empty fields server-side, as they never reach the
server. GET has a limit on the amount of data it may carry, which is
reduced the longer the base URL is. If you need to send large amounts of
data like that, you need to send it via POST. You can make minimal
changes to your PHP code to allow for this. If you use $_GET in your
PHP, swap it for $_REQUEST which contains both GET and POST data.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] How do I remove unused GET parameters from the URL?

2010-01-20 Thread Rene Veerman
Michael, while i respect your choices, i think you should know that
jquery.com is pretty good at minimizing browser-incompatibility
headaches (and keeping js apps small), and the quircks that are left
are easy enough to learn about.

for things whereby
- the server needs to generate tons of HTML for a small(ish) dataset, or
- the client generates data (also to be translated to html) that the
server doesnt really need to know about (yet)

js can really take some stress off the server.


On Wed, Jan 20, 2010 at 9:31 AM, Michael A. Peters  wrote:
> Rene Veerman wrote:
>>>
>>> That's how I would do it personally (opposed to js).
>>
>> wtf??!  js = less server stress :)
>>
>
> Many (myself included) surf with script blockers due to XSS and js is more
> difficult to thoroughly test because the implementation is done by browsers
> without a good standards body for validating the the code.
>
> I've run into a couple situations where scripts worked perfectly for me in
> Firefox, Opera, and Konq only to find out they failed in IE either because
> IE did things differently (like attaching events) or something as stupid as
> IE not liking a space that the other browsers worked fine with.
>
> window.open(url,'Download
> Media','width=620,height=200,toolbar=0,location=0,directories=0,menubar=0,resizable=0');
>
> failed in IE because of the space between Download and Media, yet worked in
> all other browsers I tried, and didn't even give a warning in Firefox with
> the firebug plugin.
>
> Thus for me to implement a solution in JavaScript, the testing time goes way
> up because I have to test it in several versions of several different
> browsers.
>
> If I can do it server side, the only issues are CSS and appropriate
> fallbacks for bleeding edge tags (like the html5 tags), but I have to test
> for those anyway so doing it server side doesn't cost me any extra testing
> time and doesn't end up with failures because I didn't test a particular
> version of a particular browser.
>
> Also, by minimizing the JavaScript, I minimize the amount of fallback
> testing I need to still keep viewers who have scripting disabled.
>
> Until there is some kind of a proper standard that the major browser vendors
> adhere to with a validator I can check my JS against that will pretty much
> guarantee any validating JS works in the various browsers, I will continue
> to do stuff server side as much as possible.
>
> I do use JavaScript for things like form validation (validated server side
> as well), upload progress, dynamic select menus where the content of one
> depends upon what was selected in another, etc. - but if I can do it server
> side I do, that's my philosophy. I understand it is a minority philosophy,
> but I get less headaches that way.
>

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



Re: [PHP] How do I remove unused GET parameters from the URL?

2010-01-19 Thread Michael A. Peters

Daevid Vincent wrote:

 
I guess I could always redirect to some 'scrubber' page that strips them

out and redirects on to the refering page again, but that seems klunky.
 
BTW, I want to use GET so that the page can be bookmarked for future

searches of the same data (or modified easily with different dates, etc.),
so that's why I don't use POST.



Another option is to use post in the form, and when your action page 
receives post, it redirects to itself with the used variables as get.


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



Re: [PHP] How do I remove unused GET parameters from the URL?

2010-01-19 Thread Michael A. Peters

Daevid Vincent wrote:
*snip*
 
The problem as I see it, is that this "magic" happens when the user hits

"Submit", so not sure PHP has any way to intercept at that point.
Javascript might be able to do something on the "onClick" event or
"onSubmit" I suspect. But this seems like something that someone should
have solved before and common enough that I would think Apache could handle
it transparently with a directive or module enabled so I don't have to code
some hack on every page.
 
I guess I could always redirect to some 'scrubber' page that strips them

out and redirects on to the refering page again, but that seems klunky.
 
BTW, I want to use GET so that the page can be bookmarked for future

searches of the same data (or modified easily with different dates, etc.),
so that's why I don't use POST.



JavaScript is the only client side way I know of.
Use document.getelementbyid() and yank the unused nodes before submit.

server side, redirect - it shouldn't be that clunky.
Put in a hidden input that tells your action script to redirect to 
itself without the unused get variables (and w/o the hidden input).


That's how I would do it personally (opposed to js).

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



[PHP] How do I remove unused GET parameters from the URL?

2010-01-19 Thread Daevid Vincent
I have an HTML form with a hundred or so elements on it, used for searching
a database.
 
When the user submits the form (via GET) the URL is loaded with ALL of
these fields, and many of them are not even actually used in the search
criteria.
 
https://mypse/dart2/ps_search.php?enter_date=2009-11-30&id_incident=&incide
nt_date=&incident_hh=0&incident_mm=0&id_urgency_level=0&problem_description
=&immediate_action=&unit_opened=&unit_authorized=&customer=&customer_contac
t=&customer_address=&customer_country=&id_location=0&passengers_onboard=&su
bmit=Search&part_number=&serial_number=&nomenclature=&manufacture_date=&mod
_level=&id_lru_condition=&repair_history=&ac_type=&tail_number=&id_system_t
ype=&id_lru_location=0&circuit_breaker=&circuit_breaker_amps=&seat_number=&
seat_vendor=&seat_column_zone=&seat_zone=&tc_holder=&stc_holder=&asr_mor=&i
mpounded=&id_authority=&id_region=&reported_by=&prepared_by=&preparer_locat
ion=&field_engineer=&id_attach_pictures=&id_attach_mlr=&id_attach_lopa=&cab
in_log=&parts_inspect=&id_organization=0&id_quality_engineer=0&car_number=&
close_date=&closed_by=&qa_comment=&id_priority=&id_action=0&id_incident_sta
tus=3&id_failure_type=&detail_status=&investigation_result=&osaka_action=&o
saka_request=&newvsrepeat=&related_incident=&unit_received_date=&unit_retur
ned_date=&tdr_to_pso_date=&tdr_date=&dcr_date=&dcr_reference_number=&ecr_da
te=&ecr_reference_number=&eco_date=&eco_reference_number=&service_bulletin_
date=&sb_reference_number=&sil_issue_date=&sil_reference_number=&til_issue_
date=&til_reference_number=&customer_letter_issue_date=&subassembly=&rdm=&p
svector=&oemmanuf=&defective_part_1=&defective_part_2=&defective_part_3=&de
fective_part_4=
 
Is there some way via PHP/Apache Mod/Javascript to remove all the keys that
don't have any value in them and just distill this down to the
elements/keys that the user actually entered some input for? ie. defaulting
all the rest to 'blank'.
 
In PHP, this would look something like this:
 
foreach ($_GET as $k => $v) if ($v == '') unset($_GET[$k]);
 
The problem as I see it, is that this "magic" happens when the user hits
"Submit", so not sure PHP has any way to intercept at that point.
Javascript might be able to do something on the "onClick" event or
"onSubmit" I suspect. But this seems like something that someone should
have solved before and common enough that I would think Apache could handle
it transparently with a directive or module enabled so I don't have to code
some hack on every page.
 
I guess I could always redirect to some 'scrubber' page that strips them
out and redirects on to the refering page again, but that seems klunky.
 
BTW, I want to use GET so that the page can be bookmarked for future
searches of the same data (or modified easily with different dates, etc.),
so that's why I don't use POST.


Re: [PHP] How do I get reliable COMPUTERNAME?

2009-11-05 Thread Andrew Ballard
On Thu, Nov 5, 2009 at 2:03 PM, Jim Lucas  wrote:
> Andrew Ballard wrote:
>> I want to store the name of the computer that is executing a script in
>> some log tables. (Our servers are load balanced, and I'd like to be
>> able to determine which physical machine is serving each request.)
>>
>> On my development machine (Windows PC running the debugger in Zend
>> Studio), I can find the name in three places:
>>
>> getenv('COMPUTERNAME')
>> $_ENV['COMPUTERNAME']
>> $_SERVER['COMPUTERNAME']
>>
>> On the development server, only the first works; $_ENV and $_SERVER
>> both return NULL and throw an undefined index notice.
>>
>> I'm concerned about the reliability of all of these methods, since it
>> seems that they are not always available and all three can be easily
>> overridden inside a script. However, I notice that the header
>> generated by phpinfo() remains correct even when I manually spoofed
>> all three values on my development machine. Is there a reliable way to
>> find this value?
>>
>> Andrew
>>
>
> Well, I looked at all the variables that are available.  Then I looked at the
> data in the output of phpinfo().
>
> The only place that I can find the information that you are looking for is
> available in the "PHP Configuration" section and it is in the System 
> information.
>
> So, looking at the phpinfo() page, I noticed the first comment down had a
> method/function for converting the output of phpinfo() into a multidimensional
> array.  Taking the output of that users function, you can access the data the
> data you are looking for.
>
> So, here is a link to the phpinfo() page.
>
> http://php.net/phpinfo
>
> From there, get the function called phpinfo_array()
>
> take the output of that and run it through the following set of commands.
>
> $data = phpinfo_array(TRUE);
> list(, $server_name) = explode(' ', $data['PHP Configuration']['System']);
> print( $server_name );
>
> This will give you what you are looking for.
>
> Jim
>

Close, but not quite what I need. On the Windows systems, the System
value is "Windows NT [hostname] [build]", so that just returns "NT".
Thanks, though. :-) You never know when something like that might be
useful.

I found php_uname('n') which looks like it will return the information
I'm after without having to dissect strings, and it appears to work
just fine across platforms.

Andrew

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



Re: [PHP] How do I get reliable COMPUTERNAME?

2009-11-05 Thread Jim Lucas
Andrew Ballard wrote:
> I want to store the name of the computer that is executing a script in
> some log tables. (Our servers are load balanced, and I'd like to be
> able to determine which physical machine is serving each request.)
> 
> On my development machine (Windows PC running the debugger in Zend
> Studio), I can find the name in three places:
> 
> getenv('COMPUTERNAME')
> $_ENV['COMPUTERNAME']
> $_SERVER['COMPUTERNAME']
> 
> On the development server, only the first works; $_ENV and $_SERVER
> both return NULL and throw an undefined index notice.
> 
> I'm concerned about the reliability of all of these methods, since it
> seems that they are not always available and all three can be easily
> overridden inside a script. However, I notice that the header
> generated by phpinfo() remains correct even when I manually spoofed
> all three values on my development machine. Is there a reliable way to
> find this value?
> 
> Andrew
> 

Well, I looked at all the variables that are available.  Then I looked at the
data in the output of phpinfo().

The only place that I can find the information that you are looking for is
available in the "PHP Configuration" section and it is in the System 
information.

So, looking at the phpinfo() page, I noticed the first comment down had a
method/function for converting the output of phpinfo() into a multidimensional
array.  Taking the output of that users function, you can access the data the
data you are looking for.

So, here is a link to the phpinfo() page.

http://php.net/phpinfo

>From there, get the function called phpinfo_array()

take the output of that and run it through the following set of commands.

$data = phpinfo_array(TRUE);
list(, $server_name) = explode(' ', $data['PHP Configuration']['System']);
print( $server_name );

This will give you what you are looking for.

Jim

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



[PHP] How do I extract link text from anchor tag as well as the URL from the "href" attribute

2009-08-16 Thread chrysanhy
I have the following code to extract the URLs from the anchor tags of an
HTML page:

$html = new DOMDocument();
$htmlpage->loadHtmlFile($location);
$xpath = new DOMXPath($htmlpage);
$links = $xpath->query( '//a' );
foreach ($links as $link)
{ $int_url_list[$i++] = $link->getAttribute( 'href' ) . "\n"; }

If I have a link http://X.com";>, how do I extract the
corresponding  which is displayed to the user as the text of the link
(if it's an image tag, I would like a DOMElement for that).
Thanks


[PHP] How do I Upload XML file using cUrl?

2009-06-12 Thread Rahul S. Johari

Ave,

I have a client who used Lead360.Com to manage their Leads. We have a  
Leads Management application in place that creates an XML file of the  
lead which give the client manually to download.


What are client is requesting is to POST the XML File directly to  
their Leads360.Com account. We have a POST Url from Leads360 where we  
can send the lead, but I'm not sure what kind of a cUrl script I need  
to use to POST an XML file. I've handled POST Data before using cUrl  
but I haven't written a cUrl script that uploads a file to a URL.


From what I have gathered so far ... this is what I have ...

[CODE]

$filename = "file.xml";
$handle = fopen($filename, "r");
$XPost = fread($handle, filesize($filename));
fclose($handle);

$url = "https://secure.leads360.com/Import.aspx";;
$ch = curl_init(); // initialize curl handle

curl_setopt($ch, CURLOPT_VERBOSE, 1); // set url to post to
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 40); // times out after 4s
curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost); // add POST fields
curl_setopt($ch, CURLOPT_POST, 1);

$result = curl_exec($ch); // run the whole process

[END CODE]

Am I on the right track here or am I missing something?

Thanks Guys!

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] How do I access a local variable?

2009-04-19 Thread Ashley Sheridan
On Sun, 2009-04-19 at 21:55 -0400, Paul M Foster wrote:
> On Mon, Apr 20, 2009 at 12:54:27AM +0100, abdulazeez alugo wrote:
> 
> > 
> > Hi guys,
> > 
> > I have a function inside which I set alocal variable to store a result. Can 
> > I access this variable in another function? if yes then how?
> > 
> > function tbl1($entrytitle, $entrytext)
> > 
> > {
> > 
> > global $conn;
> > 
> > $result= mysql_query("INSERT INTO tbl1(tbl1_id, title, text)
> > 
> >  VALUES('NULL', '$entrytitle', '$entrytext')", $conn);
> > 
> >  $tbl_id=mysql_insert_id($conn);// this is the local variable I'm 
> > setting to get the last auto increment id
> > 
> > } 
> > 
> >  
> > 
> > Now I wish to access that variable in another function thus:
> > 
> > function tbl2($name, $entrytitle, $entrytext)
> > 
> > {
> > 
> > global $conn;
> > 
> > $result =mysql_query("INSERT INTO tbl2(tbl1_id, name, title, text)
> > 
> >VALUES('$tbl1_id', '$name', '$entrytitle', 
> > '$entrytext' )", $Conn); 
> > 
> > }
> > 
> >  
> > 
> > Or is there a better way to store the variable?
> 
> If a variable is local to a function, there is no way to access that
> variable outside that function. You can pass it back as a return value
> from the original function, or make it global (not advised) to make it
> visible in other functions.
> 
> Paul
> 
> -- 
> Paul M. Foster
> 

Or pass it by reference to the functions, so that both are able to make
changes to it.



Ash
www.ashleysheridan.co.uk


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



Re: [PHP] How do I access a local variable?

2009-04-19 Thread Paul M Foster
On Mon, Apr 20, 2009 at 12:54:27AM +0100, abdulazeez alugo wrote:

> 
> Hi guys,
> 
> I have a function inside which I set alocal variable to store a result. Can I 
> access this variable in another function? if yes then how?
> 
> function tbl1($entrytitle, $entrytext)
> 
> {
> 
> global $conn;
> 
> $result= mysql_query("INSERT INTO tbl1(tbl1_id, title, text)
> 
>  VALUES('NULL', '$entrytitle', '$entrytext')", $conn);
> 
>  $tbl_id=mysql_insert_id($conn);// this is the local variable I'm setting 
> to get the last auto increment id
> 
> } 
> 
>  
> 
> Now I wish to access that variable in another function thus:
> 
> function tbl2($name, $entrytitle, $entrytext)
> 
> {
> 
> global $conn;
> 
> $result =mysql_query("INSERT INTO tbl2(tbl1_id, name, title, text)
> 
>VALUES('$tbl1_id', '$name', '$entrytitle', 
> '$entrytext' )", $Conn); 
> 
> }
> 
>  
> 
> Or is there a better way to store the variable?

If a variable is local to a function, there is no way to access that
variable outside that function. You can pass it back as a return value
from the original function, or make it global (not advised) to make it
visible in other functions.

Paul

-- 
Paul M. Foster

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



Re: [PHP] How do I access a local variable?

2009-04-19 Thread Chris

abdulazeez alugo wrote:

Hi guys,

I have a function inside which I set alocal variable to store a result. Can I 
access this variable in another function? if yes then how?


No, you can't. You either need to pass it back (recommended) or make it 
global (not recommended).



function tbl1($entrytitle, $entrytext)

{

global $conn;

$result= mysql_query("INSERT INTO tbl1(tbl1_id, title, text)

 VALUES('NULL', '$entrytitle', '$entrytext')", $conn);

 $tbl_id=mysql_insert_id($conn);// this is the local variable I'm setting 
to get the last auto increment id


return $tbl_id;

} 

 


Now I wish to access that variable in another function thus:

function tbl2($name, $entrytitle, $entrytext)

{


  $other_id = tbl1($entrytitle, $entrytext);
  echo $other_id;


global $conn;

$result =mysql_query("INSERT INTO tbl2(tbl1_id, name, title, text)

   VALUES('$tbl1_id', '$name', '$entrytitle', '$entrytext' )", $Conn); 


}


PS : look up mysql_real_escape_string for when you save your data.

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


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



[PHP] How do I access a local variable?

2009-04-19 Thread abdulazeez alugo

Hi guys,

I have a function inside which I set alocal variable to store a result. Can I 
access this variable in another function? if yes then how?

function tbl1($entrytitle, $entrytext)

{

global $conn;

$result= mysql_query("INSERT INTO tbl1(tbl1_id, title, text)

 VALUES('NULL', '$entrytitle', '$entrytext')", $conn);

 $tbl_id=mysql_insert_id($conn);// this is the local variable I'm setting 
to get the last auto increment id

} 

 

Now I wish to access that variable in another function thus:

function tbl2($name, $entrytitle, $entrytext)

{

global $conn;

$result =mysql_query("INSERT INTO tbl2(tbl1_id, name, title, text)

   VALUES('$tbl1_id', '$name', '$entrytitle', 
'$entrytext' )", $Conn); 

}

 

Or is there a better way to store the variable?

Thanks in advance.

 

Alugo Abdulazeez

www.frangeovic.com

_
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/

[PHP] How do I remove an array element from within a recursive function?

2009-02-26 Thread Daevid Vincent
I have an array like this and I simply need to recurse over it and find
a matching "menu" item to remove:

array(3) {

 ["dart"]=>
  array(10) {
[0]=>
object(menuItem)#4 (9) {
  ["menu"]=>
  string(7) "My DART"
  ["name"]=>
  string(7) "My DART"
  ["title"]=>
  string(39) "Data Analasys & Reliability Tracker"
  ["employee_only"]=>
  bool(false)
  ["page"]=>
  NULL
  ["children"]=>
  NULL
  ["parent"]=>
  NULL
  ["current"]=>
  bool(false)
  ["array_key"]=>
  string(4) "dart"
}
[1]=>
object(menuItem)#5 (9) {
  ["menu"]=>
  string(5) "Login"
  ["name"]=>
  string(5) "Login"
  ["title"]=>
  string(5) "Login"
  ["employee_only"]=>
  bool(false)
  ["page"]=>
  string(9) "login.php"
  ["children"]=>
  NULL
  ["parent"]=>
  NULL
  ["current"]=>
  bool(false)
  ["array_key"]=>
  string(4) "dart"
}
[2]=>
object(menuItem)#6 (9) {
  ["menu"]=>
  string(13) "Lost Password"
  ["name"]=>
  string(13) "Lost Password"
  ["title"]=>
  string(13) "Lost Password"
  ["employee_only"]=>
  bool(false)
  ["page"]=>
  string(12) "forgotpw.php"
  ["children"]=>
  NULL
  ["parent"]=>
  NULL
  ["current"]=>
  bool(false)
  ["array_key"]=>
  string(4) "dart"
}
...

I'm trying to remove ["menu"] == 'Login' from the array, but despite "finding" 
the element, it never removes.
isn't that what the & reference stuff is for?

menuItem::removeMenuItems($navArray['dart'], array('Login', 'Lost Password'));


public static final function removeMenuItems(&$menuItems, $removeArray)
{
foreach($menuItems as $value)
{
if (is_array($value->children))
menuItem::removeMenuItems(&$value->children, 
$removeArray);
else
{
//echo "*** CHECKING ".$value->menu." against 
".implode(',',$removeArray)." ***";
if (in_array($value->menu, $removeArray))
{
//echo "*** REMOVING ".$value->menu." 
***";
unset($value);
}
}
}
}


Re: [PHP] how do i allow more than 2 threads of php to run?

2008-12-09 Thread Ashley Sheridan
On Tue, 2008-12-09 at 12:19 -0800, Daevid Vincent wrote:
> Assuming this is in-fact your issue, I ALWAYS do this registry hack on
> my Windows computers:
> http://support.microsoft.com/kb/282402
> 
> 
> On Tue, 2008-12-09 at 22:10 +0200, Krister Karlström wrote:
> 
> > Hi!
> > 
> > Please note that most browser follows the RFC:s and does not allow more 
> > than two connections to each domain simultaneously. You can do 
> > work-arounds to solve this problem, like using subdomains for some 
> > requests. In Firefox you might also be able to disable this feature...
> > 
> > Regards,
> > Krister Karlström, Helsinki
> > 
> > Rene Veerman wrote:
> > > i'm getting freezes for the 3rd to Nth concurrent request on my 
> > > homeserver (got root, on debian4 + apache2).
> > > how can i allow more threads? like 50 or so?
> > > 
> > > 
> > > 
> > 
> 
> 
You still use IE? *gasp*


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] how do i allow more than 2 threads of php to run?

2008-12-09 Thread Daevid Vincent
Assuming this is in-fact your issue, I ALWAYS do this registry hack on
my Windows computers:
http://support.microsoft.com/kb/282402


On Tue, 2008-12-09 at 22:10 +0200, Krister Karlström wrote:

> Hi!
> 
> Please note that most browser follows the RFC:s and does not allow more 
> than two connections to each domain simultaneously. You can do 
> work-arounds to solve this problem, like using subdomains for some 
> requests. In Firefox you might also be able to disable this feature...
> 
> Regards,
> Krister Karlström, Helsinki
> 
> Rene Veerman wrote:
> > i'm getting freezes for the 3rd to Nth concurrent request on my 
> > homeserver (got root, on debian4 + apache2).
> > how can i allow more threads? like 50 or so?
> > 
> > 
> > 
> 




Re: [PHP] how do i allow more than 2 threads of php to run?

2008-12-09 Thread Krister Karlström

Hi!

Please note that most browser follows the RFC:s and does not allow more 
than two connections to each domain simultaneously. You can do 
work-arounds to solve this problem, like using subdomains for some 
requests. In Firefox you might also be able to disable this feature...


Regards,
Krister Karlström, Helsinki

Rene Veerman wrote:
i'm getting freezes for the 3rd to Nth concurrent request on my 
homeserver (got root, on debian4 + apache2).

how can i allow more threads? like 50 or so?





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



Re: [PHP] how do i allow more than 2 threads of php to run?

2008-12-09 Thread Rene Veerman

Jochem Maas wrote:

Rene Veerman schreef:
  

Jochem Maas wrote:


Rene Veerman schreef:
 
  

i'm getting freezes for the 3rd to Nth concurrent request on my
homeserver (got root, on debian4 + apache2).
how can i allow more threads? like 50 or so?



probably need to fix the apache.conf to allow more concurrent child
processes.

  
  

K, how do i do that?

I looked at the apache2 docs but couldnt find the setting to tweak




look for these (these just happen to be the settings for my local dev install):

StartServers 1
MinSpareServers  1
MaxSpareServers  2
MaxClients  16
MaxRequestsPerChild   1000

i'd imagine MaxClients is the one you will need to 'up'

also STW for 'apache prefork MPM'

  
sry, but that didn't fix things. it was already at 150 (i tried 250), 
and my webserver freezes on 1 to 3 open connections, can't tell for 
sure. but it's a real low number..



# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves

   StartServers  5
   MinSpareServers   5
   MaxSpareServers  10
   MaxClients  150
   MaxRequestsPerChild   0


# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves

   StartServers  2
   MaxClients  150
   MinSpareThreads  25
   MaxSpareThreads  75
   ThreadsPerChild  25
   MaxRequestsPerChild   0






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



Re: [PHP] how do i allow more than 2 threads of php to run?

2008-12-09 Thread Jochem Maas
Rene Veerman schreef:
> Jochem Maas wrote:
>> Rene Veerman schreef:
>>  
>>> i'm getting freezes for the 3rd to Nth concurrent request on my
>>> homeserver (got root, on debian4 + apache2).
>>> how can i allow more threads? like 50 or so?
>>> 
>>
>> probably need to fix the apache.conf to allow more concurrent child
>> processes.
>>
>>   
> 
> K, how do i do that?
> 
> I looked at the apache2 docs but couldnt find the setting to tweak
> 

look for these (these just happen to be the settings for my local dev install):

StartServers 1
MinSpareServers  1
MaxSpareServers  2
MaxClients  16
MaxRequestsPerChild   1000

i'd imagine MaxClients is the one you will need to 'up'

also STW for 'apache prefork MPM'


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



Re: [PHP] how do i allow more than 2 threads of php to run?

2008-12-09 Thread Rene Veerman

Jochem Maas wrote:

Rene Veerman schreef:
  

i'm getting freezes for the 3rd to Nth concurrent request on my
homeserver (got root, on debian4 + apache2).
how can i allow more threads? like 50 or so?



probably need to fix the apache.conf to allow more concurrent child processes.

  


K, how do i do that?

I looked at the apache2 docs but couldnt find the setting to tweak


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



Re: [PHP] how do i allow more than 2 threads of php to run?

2008-12-09 Thread Jochem Maas
Rene Veerman schreef:
> i'm getting freezes for the 3rd to Nth concurrent request on my
> homeserver (got root, on debian4 + apache2).
> how can i allow more threads? like 50 or so?

probably need to fix the apache.conf to allow more concurrent child processes.

also note I said 'processes' - php is not totally threadsafe (due to
unknowns in various extensions) and generally run under apache using the
[apache] pre-fork worker module.

it's apache that decides how many concurrent httpd processes are allowed to
run, php merely runs as a part of each httpd process in the form of
an apache module.

you could be running php as CGI or FastCGI SAPI, which is different to using the
apache module SAPI, but for the purposes on the above the same story goes.

and if it's not an apache config issue then I guess your looking at some
kind of OS limitation ... no idea about that I'm afraid.

> 


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



[PHP] how do i allow more than 2 threads of php to run?

2008-12-09 Thread Rene Veerman
i'm getting freezes for the 3rd to Nth concurrent request on my 
homeserver (got root, on debian4 + apache2).

how can i allow more threads? like 50 or so?



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



Re: [PHP] how do I stop Firefox doing a conditional get?

2008-05-15 Thread Per Jessen
Al wrote:

> Per Jessen wrote:
>> Al wrote:
>> 
>>> Make certain your steam is compressed
>>> http://www.whatsmyip.org/mod_gzip_test/
>>>
>> 
>> The files I was having the problem with are GIFs, so already LZW
>> compressed.
>> 
> Try by not LZW compressing and the use ob_start() and flush() so your
> files are gzip compressed. I don't know if Firefox knows how to
> readily handle LZW on the fly. It does know how to handle gzip.

Al, thanks for suggestion, but you're talking rubbish.  _All_ browsers
understand GIFs, and they are all LZW compressed.  There's absolutely
zero point in trying to gzip them as well. 


/Per Jessen, Zürich


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



Re: [PHP] how do I stop Firefox doing a conditional get?

2008-05-15 Thread Al
Try by not LZW compressing and the use ob_start() and flush() so your files are gzip compressed. I 
don't know if Firefox knows how to readily handle LZW on the fly. It does know how to handle gzip.


Per Jessen wrote:

Al wrote:


Make certain your steam is compressed
http://www.whatsmyip.org/mod_gzip_test/



The files I was having the problem with are GIFs, so already LZW
compressed. 



/Per Jessen, Zürich



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



Re: [PHP] how do I stop Firefox doing a conditional get?

2008-05-15 Thread Per Jessen
Al wrote:

> Make certain your steam is compressed
> http://www.whatsmyip.org/mod_gzip_test/
> 

The files I was having the problem with are GIFs, so already LZW
compressed. 


/Per Jessen, Zürich


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



Re: [PHP] how do I stop Firefox doing a conditional get?

2008-05-15 Thread Robin Vickery
On 15/05/2008, Al <[EMAIL PROTECTED]> wrote:
> Make certain your steam is compressed
> http://www.whatsmyip.org/mod_gzip_test/

Compressed steam can be dangerous:

http://en.wikipedia.org/wiki/2007_New_York_City_steam_explosion

-robin

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



Re: [PHP] how do I stop Firefox doing a conditional get?

2008-05-15 Thread Al

Make certain your steam is compressed http://www.whatsmyip.org/mod_gzip_test/



Per Jessen wrote:

Robin Vickery wrote:


2008/5/14 Per Jessen <[EMAIL PROTECTED]>:

 The issue is - I'd like this page to appear to be as "real time" as
 possible, and the occasional delay caused by the conditional get is
 a nuisance.  My images are clearly cached, so how do I prevent
 Firefox from doing the conditional get ?  There must be some HTTP
 header I  can use.

You can use either or both of 'Expires' or  'Cache-Control'


I've just now added 'Cache-Control' - I was already using 'Expires', but
that wasn't sufficient.  Thanks.


/Per Jessen, Zürich



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



Re: [PHP] how do I stop Firefox doing a conditional get?

2008-05-14 Thread Per Jessen
Robin Vickery wrote:

> 2008/5/14 Per Jessen <[EMAIL PROTECTED]>:
>>
>>  The issue is - I'd like this page to appear to be as "real time" as
>>  possible, and the occasional delay caused by the conditional get is
>>  a nuisance.  My images are clearly cached, so how do I prevent
>>  Firefox from doing the conditional get ?  There must be some HTTP
>>  header I  can use.
> 
> You can use either or both of 'Expires' or  'Cache-Control'

I've just now added 'Cache-Control' - I was already using 'Expires', but
that wasn't sufficient.  Thanks.


/Per Jessen, Zürich


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



Re: [PHP] how do I stop Firefox doing a conditional get?

2008-05-14 Thread Robin Vickery
2008/5/14 Per Jessen <[EMAIL PROTECTED]>:
> All,
>
>  not really PHP related, but I figured someone here would already
>  have solved this problem.
>  I've got a page with a single .  I change the src attribute
>  dynamically using javascript.  Although the images being served all
>  have long expiry times, Firefox still does a conditional get to which
>  apache says "304" as it should.
>
>  The issue is - I'd like this page to appear to be as "real time" as
>  possible, and the occasional delay caused by the conditional get is a
>  nuisance.  My images are clearly cached, so how do I prevent Firefox
>  from doing the conditional get ?  There must be some HTTP header I can
>  use.

You can use either or both of 'Expires' or  'Cache-Control'

-robin

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



[PHP] how do I stop Firefox doing a conditional get?

2008-05-14 Thread Per Jessen
All, 

not really PHP related, but I figured someone here would already
have solved this problem.  
I've got a page with a single .  I change the src attribute
dynamically using javascript.  Although the images being served all
have long expiry times, Firefox still does a conditional get to which
apache says "304" as it should.  

The issue is - I'd like this page to appear to be as "real time" as
possible, and the occasional delay caused by the conditional get is a
nuisance.  My images are clearly cached, so how do I prevent Firefox
from doing the conditional get ?  There must be some HTTP header I can
use. 


/Per Jessen, Zürich


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



Re: [PHP] How do I search the archives?

2008-03-11 Thread Daniel Brown
On Tue, Mar 11, 2008 at 12:11 PM, Stut <[EMAIL PROTECTED]> wrote:
>
> On 11 Mar 2008, at 16:02, Lamonte H wrote:
>  > I went to the page, but I didn't find a search box and what not.  Is
>  > there a
>  > way to search the archives?  Else when I get home I'll just create a
>  > script
>  > to DL all the links to a page then create a simple search box.
>
>  You might want to think about what you're actually considering doing
>  with that script before you go that. A little thought will probably
>  put you off the idea quickly.
>
>  To answer your question... http://marc.info/?l=php-general&r=1&w=2

Also, in case MARC goes down for whatever reason, there are a
number of other sites.

http://dir.gmane.org/gmane.comp.php.general
http://www.nabble.com/PHP---General-f140.html
 and a ton of others which you can find on Google.

My personal favorite is GMANE, but that's because of the fact that
I'm an old-school BBS/Newsgroup hack, and I like the added list
metrics.

-- 


Daniel P. Brown
Senior Unix Geek


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



Re: [PHP] How do I search the archives?

2008-03-11 Thread Stut

On 11 Mar 2008, at 16:02, Lamonte H wrote:
I went to the page, but I didn't find a search box and what not.  Is  
there a
way to search the archives?  Else when I get home I'll just create a  
script

to DL all the links to a page then create a simple search box.


You might want to think about what you're actually considering doing  
with that script before you go that. A little thought will probably  
put you off the idea quickly.


To answer your question... http://marc.info/?l=php-general&r=1&w=2

-Stut

--
http://stut.net/

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



[PHP] How do I search the archives?

2008-03-11 Thread Lamonte H
I went to the page, but I didn't find a search box and what not.  Is there a
way to search the archives?  Else when I get home I'll just create a script
to DL all the links to a page then create a simple search box.


Re: [PHP] how do i get a printout of original multipart post data

2007-11-28 Thread Olav Mørkrid
what is the thought behind php not providing access to original post
data? this removes any chance of analyzing corrupt upload data, which
is often the case with mobile browsers. can future versions of php
please include a way of viewing raw server requests in full?

On 26/11/2007, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> If you're with linux try netcat (nc) at listening mode.
> >
> > how can i get a raw and untouched printout of a multipart/form-data
> > POST? i need this to analyze what certain user agents do wrong when
> > uploading files.

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



Re: [PHP] how do i get a printout of original multipart post data

2007-11-26 Thread Robert . Degen
If you're with linux try netcat (nc) at listening mode.

Something like (not exactly)

nc -vtlp 80

and then submut against any localhost url.

greetings


- Ursprüngliche Nachricht -
Von: Olav Mørkrid <[EMAIL PROTECTED]>
Datum: Montag, November 26, 2007 1:52 pm
Betreff: [PHP] how do i get a printout of original multipart post data
An: php-general@lists.php.net

> hello
> 
> 
> how can i get a raw and untouched printout of a multipart/form-data
> POST? i need this to analyze what certain user agents do wrong when
> uploading files.
> 
> what happens is that php just fails to put files into $_FILES, and
> gives no way of seeing the original posting and exactly what is wrong
> with it.
> 
> according to the manual, neither "always_populate_raw_post_data" nor
>  work for multipart/form-data.
> 
> -- 
> 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



[PHP] how do i get a printout of original multipart post data

2007-11-26 Thread Olav Mørkrid
hello


how can i get a raw and untouched printout of a multipart/form-data
POST? i need this to analyze what certain user agents do wrong when
uploading files.

what happens is that php just fails to put files into $_FILES, and
gives no way of seeing the original posting and exactly what is wrong
with it.

according to the manual, neither "always_populate_raw_post_data" nor
 work for multipart/form-data.

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



Re: [PHP] How do I specify a local file for fopen()?

2007-11-04 Thread Cristian Vrabie
Server can't access files on clients computers as they wish or it would 
be madness. Nothing would be secure. However you can get to the file if 
you make it public in some way and with some restrictions. Therea are 
several methods:
1. (wich i think is best) install a ftp server and "share" the file 
through the server. use the php's ftp function to access the file
2. install a webserver like apache and place the file you want in the 
web-root folder (the public on). use fopen or whatever you want to open 
the file.


you must keep in mind that in order to do this you have to have a public 
ip adress (you can't do it if youre behind nat)



Jon Westcot wrote:

Hi all:

I've been beating my head against a brick wall trying to figure this out 
and I'm still no closer than I was two weeks ago.

How do I specify a local file on my computer to use with fopen() on the 
server?

I've checked and the allow_url_fopen setting is set to On.  I use the html  to let me browse to the file.  This, however, forces me to also POST the 
entire file to the server, which I DO NOT WANT it to do.  I just wanted to be able to use the 
 button to get to the file name.  But, even when I do this, the file name returned in 
the $_FILES array doesn't give me a file name that fopen() will actually open.

Do I somehow have to get the server to recognize my computer as an 
http-based address?  If so, how do I do this?  The computer that has the file 
to be opened is a Windows-based computer (running WinXP or Vista), and it 
obviously has an Internet connection.  Do I need to retrieve, from the server, 
my computer's IP address and use that, in whole or in part, to reference the 
file to be opened?  If so, how?

While I'm asking questions, does anyone know how to keep the file referenced in the 
 setup from actually being sent?  All I think I really need 
is the NAME of the file, not its actual contents, since I'm hoping to use fopen() to open the 
file and then to use fgetcsv() to retrieve the contents.

ANY help you all can send my way will be greatly appreciated!

Thanks in advance,

Jon

  


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



[PHP] How do I specify a local file for fopen()?

2007-11-04 Thread Jon Westcot
Hi all:

I've been beating my head against a brick wall trying to figure this out 
and I'm still no closer than I was two weeks ago.

How do I specify a local file on my computer to use with fopen() on the 
server?

I've checked and the allow_url_fopen setting is set to On.  I use the html 
 to let me browse to the file.  This, however, forces me to 
also POST the entire file to the server, which I DO NOT WANT it to do.  I just 
wanted to be able to use the  button to get to the file name.  But, 
even when I do this, the file name returned in the $_FILES array doesn't give 
me a file name that fopen() will actually open.

Do I somehow have to get the server to recognize my computer as an 
http-based address?  If so, how do I do this?  The computer that has the file 
to be opened is a Windows-based computer (running WinXP or Vista), and it 
obviously has an Internet connection.  Do I need to retrieve, from the server, 
my computer's IP address and use that, in whole or in part, to reference the 
file to be opened?  If so, how?

While I'm asking questions, does anyone know how to keep the file 
referenced in the  setup from actually being sent?  All I 
think I really need is the NAME of the file, not its actual contents, since I'm 
hoping to use fopen() to open the file and then to use fgetcsv() to retrieve 
the contents.

ANY help you all can send my way will be greatly appreciated!

Thanks in advance,

Jon


Re: [PHP] How do I get PHP to save a backslash in a Mysql table?

2007-10-10 Thread James Ausmus
On 10/10/07, Don Proshetsky <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a field in which a user inputs a Windows style directory path, hence
> using backslashes and not forward slashes.
>
> Example: c:\qb\data\mydatadile.qbw
>
> However, when the use clicks update, what gets saved is:
> c:qbdatamydatadile.qbw
>
> Does anyone know if there is a work around?

How are you checking the value actually saved in the database -
through another PHP script, or directly via the MySQL
command-line-interface? If you're using another script to view the
value, it might be the display script that is screwing up, not the
save script - check the value directly with the MySQL CLI client.

HTH-

James



>
> The backslashes mysteriously are stripped.  I use the following function to
> wrap each variable that's saved in the MySQL table:
>
> function update_database($value)
> {
>// Addslashes
>if (!(get_magic_quotes_gpc())) {
>$value = addslashes($value);
>}
>// Quote if not a number or a numeric string
>if (!is_numeric($value)) {
>$value = mysql_real_escape_string($value);
>}
>return $value;
> }
>
>

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



RE: [PHP] How do I get PHP to save a backslash in a Mysql table?

2007-10-10 Thread Bastien Koert

use mysql_real_escape_string
 
bastien> From: [EMAIL PROTECTED]> To: php-general@lists.php.net> Date: Wed, 10 
Oct 2007 13:48:03 -0400> Subject: [PHP] How do I get PHP to save a backslash in 
a Mysql table?> > Hi,> > I have a field in which a user inputs a Windows style 
directory path, hence > using backslashes and not forward slashes.> > Example: 
c:\qb\data\mydatadile.qbw> > However, when the use clicks update, what gets 
saved is: > c:qbdatamydatadile.qbw> > Does anyone know if there is a work 
around?> > The backslashes mysteriously are stripped. I use the following 
function to > wrap each variable that's saved in the MySQL table:> > function 
update_database($value)> {> // Addslashes> if (!(get_magic_quotes_gpc())) {> 
$value = addslashes($value);> }> // Quote if not a number or a numeric string> 
if (!is_numeric($value)) {> $value = mysql_real_escape_string($value);> }> 
return $value;> }> 
_
R U Ready for Windows Live Messenger Beta 8.5? Try it today!
http://entertainment.sympatico.msn.ca/WindowsLiveMessenger

Re: [PHP] How do I get PHP to save a backslash in a Mysql table?

2007-10-10 Thread TG

I didn't see all the responses to this, so maybe someone already recommended 
these things.

Looks like you may be over-complicating things in your code there.

First, if Magic Quotes are ON, then you probably want to stripslashes() to 
get rid of extra slashes.  If it's OFF, then don't worry about it.  (I 
think that's right.. been ages since I've had to deal with Magic Quotes so 
don't remember without playing with it).

Second.. you should be using, at minimum, mysql_real_escape_string() on all 
data items being inserted/updated/SELECT..WHERE'd, etc.  You can't trust 
user input or anything coming from the server.  Anything you don't type 
yourself as part of the query, that is.  Most of it can be forged.

And that "is_numeric" check shouldn't make a difference.  Even if it's 
supposed to be numeric data, you should still use 
mysql_real_escape_string() in case someone enters something bad (probably 
making it non-numeric, but you know... stick with a consistant data 
cleansing protocol).

Ok... quick recap...

Magic Quotes ON = extra slashes.. probably want to strip then before 
continuing.
Magic Quotes OFF = everything's cool.. proceed to 'standard operating 
procedure' (SOP) :)

SOP:
Use mysql_real_escape_string() on all data used in queries  (or the equiv 
function for your DB if it's not MySQL)

The only other thing to check is if you're viewing the echo'd results in a 
browser, you might do View Source to see exactly what's output.   Browsers 
will interpret things sometimes.  You might be able to enclose the output 
in  tags to get around that.   And make sure you're using 
single quotes in your echo, so things aren't being interpretted in the echo 
statement itself.

Some of these things are rare issues, but all things to check for if your 
output isn't what you expect it to be or want it to be.

-TG


- Original Message -
From: "Nathan Nobbe" <[EMAIL PROTECTED]>
To: "Don Proshetsky" <[EMAIL PROTECTED]>
Cc: php-general@lists.php.net
Date: Wed, 10 Oct 2007 14:12:34 -0400
Subject: Re: [PHP] How do I get PHP to save a backslash in a Mysql table?

> On 10/10/07, Don Proshetsky <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > I have a field in which a user inputs a Windows style directory path,
> > hence
> > using backslashes and not forward slashes.
> >
> > Example: c:\qb\data\mydatadile.qbw
> >
> > However, when the use clicks update, what gets saved is:
> > c:qbdatamydatadile.qbw
> >
> > Does anyone know if there is a work around?
> >
> > The backslashes mysteriously are stripped.  I use the following function
> > to
> > wrap each variable that's saved in the MySQL table:
> >
> > function update_database($value)
> > {
> >// Addslashes
> >if (!(get_magic_quotes_gpc())) {
> >$value = addslashes($value);
> >}
> >// Quote if not a number or a numeric string
> >if (!is_numeric($value)) {
> >$value = mysql_real_escape_string($value);
> >}
> >return $value;
> > }

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



Re: [PHP] How do I get PHP to save a backslash in a Mysql table?

2007-10-10 Thread Nathan Nobbe
On 10/10/07, Don Proshetsky <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have a field in which a user inputs a Windows style directory path,
> hence
> using backslashes and not forward slashes.
>
> Example: c:\qb\data\mydatadile.qbw
>
> However, when the use clicks update, what gets saved is:
> c:qbdatamydatadile.qbw
>
> Does anyone know if there is a work around?
>
> The backslashes mysteriously are stripped.  I use the following function
> to
> wrap each variable that's saved in the MySQL table:
>
> function update_database($value)
> {
>// Addslashes
>if (!(get_magic_quotes_gpc())) {
>$value = addslashes($value);
>}
>// Quote if not a number or a numeric string
>if (!is_numeric($value)) {
>$value = mysql_real_escape_string($value);
>}
>return $value;
> }



most likely neither of the conditions in the function is getting hit and
mysql is removing the \ characters
from the original string.
try echoing out  $value before the update to see if it is what you expect.

-nathan


Re: [PHP] How do I get Apache 1.3.36 to use PHP 5

2007-08-26 Thread Richard Lynch
On Sun, August 26, 2007 3:03 pm, Beauford wrote:

> I tried putting LoadModule php5_module /usr/local/apache/libphp5.so in
> my
> http.conf, but it doesn't exist.

>Example 2-2. Installation Instructions (Static Module Installation
> for
>Apache) for PHP

I think "static module installation" means you've compiled PHP *in* to
Apache, and it's not a libphp5.so file -- It's just part of httpd
binary.

> 8.  make
> 9.  make install

This step should tell you if it's copying libphp5.so into the Apache dir.

> 10. cd ../apache_1.3.x
>
> 11. ./configure --prefix=/www
> --activate-module=src/modules/php5/libphp5.a
> (The above line is correct! Yes, we know libphp5.a does not exist
> at
> this
> stage. It isn't supposed to. It will be created.)

Yup, this is where you are compiling php INTO the httpd binary.


If you want to end up with a libphp5.so, you have to follow the
instructions that involve apxs and not the "Static" instructions.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] How do I delete a composite key?

2007-08-26 Thread Richard Lynch


On Sun, August 26, 2007 2:05 pm, Stut wrote:
> nitrox . wrote:
>> Im trying to delete a composite key but cannot figure out the proper
>> format. Would somebody tell me where im messing up? I have an url
>> that
>> is supposed to send the member id and game id to a delete query. And
>> the
>> delete query is supposed to grab the id's based on type.
>>
>> This is the link:
>>
>> > href=\"member_commit.php?action=remove&type=Member&id={$record->Member_id}&gametype=Game&id={$record->Game_id}\">[GAME
>> REMOVAL]\n";
> 
>>$sql = "DELETE
>>   FROM xsm_membergames
>>   WHERE Member_id = '" .
>> mysql_real_escape_string((int)$_GET['id']) . " .
>> AND Game_id = '" . mysql_real_escape_string((int)$_GET['id']) .
>> "'";
>
> Your URL contains 2 instances of a GET variable named, which you then
> use in the SQL query. In this instance $_GET['id'] will contain just
> the
> Game_id. Change the name of one or both IDs and you should be ok.

Another possiblity, if you are trying to write this more generically,
would be to use:

?id[game]=$record->Game_id&id[Member]=$record->Member_id

$_GET['id'] will then be an array that looks something like this:
array('game' => 42, 'member' => 17);

You would then iterate through $_GET['id'] and show all the factors
that are going into the query/delete.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] How do I get Apache 1.3.36 to use PHP 5

2007-08-26 Thread Beauford
Not to sound like a total nob, but how do I get Apache 1.3.36 to use PHP5. I
have both 4 and 5 installed, but it still uses 4. I never had a problem with
4.

I read the followed the INSTALL file for PHP5, below. I reinstall Apache as
well and nothing - step 11.

I tried putting LoadModule php5_module /usr/local/apache/libphp5.so in my
http.conf, but it doesn't exist.

Any help is appreciated.

   Example 2-2. Installation Instructions (Static Module Installation for
   Apache) for PHP
1.  gunzip -c apache_1.3.x.tar.gz | tar xf -
2.  cd apache_1.3.x
3.  ./configure
4.  cd ..

5.  gunzip -c php-5.x.y.tar.gz | tar xf -
6.  cd php-5.x.y
7.  ./configure --with-mysql --with-apache=../apache_1.3.x
8.  make
9.  make install

10. cd ../apache_1.3.x

11. ./configure --prefix=/www --activate-module=src/modules/php5/libphp5.a
(The above line is correct! Yes, we know libphp5.a does not exist at
this
stage. It isn't supposed to. It will be created.)

12. make
(you should now have an httpd binary which you can copy to your Apache
bin d
ir if
it is your first install then you need to "make install" as well)

13. cd ../php-5.x.y
14. cp php.ini-dist /usr/local/lib/php.ini 

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



Re: [PHP] How do I delete a composite key?

2007-08-26 Thread Stut

nitrox . wrote:
Im trying to delete a composite key but cannot figure out the proper 
format. Would somebody tell me where im messing up? I have an url that 
is supposed to send the member id and game id to a delete query. And the 
delete query is supposed to grab the id's based on type.


This is the link:

href=\"member_commit.php?action=remove&type=Member&id={$record->Member_id}&gametype=Game&id={$record->Game_id}\">[GAME 
REMOVAL]\n";



   $sql = "DELETE
  FROM xsm_membergames
  WHERE Member_id = '" . 
mysql_real_escape_string((int)$_GET['id']) . " .

AND Game_id = '" . mysql_real_escape_string((int)$_GET['id']) . "'";


Your URL contains 2 instances of a GET variable named, which you then 
use in the SQL query. In this instance $_GET['id'] will contain just the 
Game_id. Change the name of one or both IDs and you should be ok.


-Stut

--
http://stut.net/

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



[PHP] How do I delete a composite key?

2007-08-26 Thread nitrox .
Im trying to delete a composite key but cannot figure out the proper format. 
Would somebody tell me where im messing up? I have an url that is supposed 
to send the member id and game id to a delete query. And the delete query is 
supposed to grab the id's based on type.




This is the link:

href=\"member_commit.php?action=remove&type=Member&id={$record->Member_id}&gametype=Game&id={$record->Game_id}\">[GAME 
REMOVAL]\n";




This is the code that recieves the link information:

case "remove":
 switch ($_GET['type']) {
   case "Member":
 if (!isset($_GET['do']) || $_GET['do'] != 1) {
?>
 
   Are you sure you want to delete this ?
   yes
   or Index
 
  WHERE Member_id = '" . mysql_real_escape_string((int)$_GET['id']) 
. " .

AND Game_id = '" . mysql_real_escape_string((int)$_GET['id']) . "'";
   }
 }

_
Messenger Café — open for fun 24/7. Hot games, cool activities served daily. 
Visit now. http://cafemessenger.com?ocid=TXT_TAGHM_AugHMtagline


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



Re: [PHP] how do I pass a variable with header?

2007-04-21 Thread Richard Lynch
On Sat, April 21, 2007 8:54 am, Ross wrote:
> header('Location: edit_property.php?property_id=.'$property_id'.');

"Location: edit_property.php?property_id=$property_id"

However, you should be using a complete URI in Location: to be within
HTTP spec.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] how do I pass a variable with header?

2007-04-21 Thread Stut

Ross wrote:

header('Location: edit_property.php?property_id=.'$property_id'.');


You read the manual to learn basic PHP syntax.

header('Location: edit_property.php?property_id='.
  urlencode($property_id));

Also, technically the URL given in a location header should be absolute 
not relative.


-Stut

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



[PHP] how do I pass a variable with header?

2007-04-21 Thread Ross
header('Location: edit_property.php?property_id=.'$property_id'.');


t: 0131 553 3935 | m:07816 996 930 | [EMAIL PROTECTED] | 
http://www:blue-fly.co.uk 

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



Re: [PHP] How do I force my script to exit after 5 seconds?

2007-02-23 Thread Richard Lynch
On Thu, February 22, 2007 9:06 am, Aaron Gould wrote:
> So, my question is:  how can I force this script to stop after 5
> seconds
> has elapsed?
>
> Here's the script:

Inlined code might work...

> 
> $fp = fsockopen('192.168.3.25', 10001, $errno, $errstr, 5);
>
> if (!$fp) {
>  echo 'Error...';
> } else {
>  $command = "KPRINT\r\n";
>
>  fwrite($fp, $command);
>
   $last_data = time();

>  while (!feof($fp)) {
>  $buffer = fgets($fp, 1024);

   if (strlen($buffer)) $last_data = time();
   if (time() - $last_data > 5){
 fclose($fp);
 exit;
   }

>  }
>
>  fclose($fp);
> }
> 

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] How do I force my script to exit after 5 seconds?

2007-02-22 Thread Aaron Gould
Thanks very much, I've added stream_set_timeout functionality, and it 
seems to work very well!


For reference, here's the modified script:


$fp = fsockopen('192.168.3.25', 10001, $errno, $errstr, 5);
if (!$fp) {
echo 'Error...';
} else {
/** Set socket timeout period */
stream_set_timeout($fp, 5);

/** KPRINT outputs scale values */
$command = "KPRINT\r\n";

fwrite($fp, $command);

while (!feof($fp)) {
/** Check for timeout */
$info = stream_get_meta_data($fp);
if ($info['timed_out']) {
echo 'Timeout...';
break;
}

$buffer = fgets($fp, 1024);
}

fclose($fp);
}



Brad Bonkoski wrote:

Aaron Gould wrote:
I tried this earlier, but it does not seem to work...  It appears to 
just hang when no data is returned from the networked device.  It 
seems as if the loop stops, and is waiting for something.




probably blocking on the socket
have you tried:
www.php.net/stream_set_timeout


Brad Bonkoski wrote:

I think something like this will work for you..

$start_time = time();
...loop..
   if( time() - $start_time > 5 ) exit;

-B
Aaron Gould wrote:
I have a script that connects to a networked device via PHP's socket 
functions.  This device accepts proprietary commands (e.g.: 
"KPRINT", as seen below), and returns data.  However, this device 
does not have any sort of "EXIT" command to end the processing of 
events.  So it essentially loops forever.


I do know that if this device does not return anything after 5 
seconds, it will never return anything.


So, my question is:  how can I force this script to stop after 5 
seconds has elapsed?


Here's the script:


$fp = fsockopen('192.168.3.25', 10001, $errno, $errstr, 5);

if (!$fp) {
echo 'Error...';
} else {
$command = "KPRINT\r\n";

fwrite($fp, $command);

while (!feof($fp)) {
$buffer = fgets($fp, 1024);
}

fclose($fp);
}



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



Re: [PHP] How do I force my script to exit after 5 seconds?

2007-02-22 Thread Robin Vickery

On 22/02/07, Aaron Gould <[EMAIL PROTECTED]> wrote:

I tried this earlier, but it does not seem to work...  It appears to
just hang when no data is returned from the networked device.  It seems
as if the loop stops, and is waiting for something.




http://www.php.net/manual/en/function.pcntl-alarm.php

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



Re: [PHP] How do I force my script to exit after 5 seconds?

2007-02-22 Thread Brad Bonkoski

Aaron Gould wrote:
I tried this earlier, but it does not seem to work...  It appears to 
just hang when no data is returned from the networked device.  It 
seems as if the loop stops, and is waiting for something.




probably blocking on the socket
have you tried:
www.php.net/stream_set_timeout


Brad Bonkoski wrote:

I think something like this will work for you..

$start_time = time();
...loop..
   if( time() - $start_time > 5 ) exit;

-B
Aaron Gould wrote:
I have a script that connects to a networked device via PHP's socket 
functions.  This device accepts proprietary commands (e.g.: 
"KPRINT", as seen below), and returns data.  However, this device 
does not have any sort of "EXIT" command to end the processing of 
events.  So it essentially loops forever.


I do know that if this device does not return anything after 5 
seconds, it will never return anything.


So, my question is:  how can I force this script to stop after 5 
seconds has elapsed?


Here's the script:


$fp = fsockopen('192.168.3.25', 10001, $errno, $errstr, 5);

if (!$fp) {
echo 'Error...';
} else {
$command = "KPRINT\r\n";

fwrite($fp, $command);

while (!feof($fp)) {
$buffer = fgets($fp, 1024);
}

fclose($fp);
}





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



Re: [PHP] How do I force my script to exit after 5 seconds?

2007-02-22 Thread Aaron Gould
I tried this earlier, but it does not seem to work...  It appears to 
just hang when no data is returned from the networked device.  It seems 
as if the loop stops, and is waiting for something.



Brad Bonkoski wrote:

I think something like this will work for you..

$start_time = time();
...loop..
   if( time() - $start_time > 5 ) exit;

-B
Aaron Gould wrote:
I have a script that connects to a networked device via PHP's socket 
functions.  This device accepts proprietary commands (e.g.: "KPRINT", 
as seen below), and returns data.  However, this device does not have 
any sort of "EXIT" command to end the processing of events.  So it 
essentially loops forever.


I do know that if this device does not return anything after 5 
seconds, it will never return anything.


So, my question is:  how can I force this script to stop after 5 
seconds has elapsed?


Here's the script:


$fp = fsockopen('192.168.3.25', 10001, $errno, $errstr, 5);

if (!$fp) {
echo 'Error...';
} else {
$command = "KPRINT\r\n";

fwrite($fp, $command);

while (!feof($fp)) {
$buffer = fgets($fp, 1024);
}

fclose($fp);
}



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



Re: [PHP] How do I force my script to exit after 5 seconds?

2007-02-22 Thread Brad Bonkoski

I think something like this will work for you..

$start_time = time();
...loop..
   if( time() - $start_time > 5 ) exit;

-B
Aaron Gould wrote:
I have a script that connects to a networked device via PHP's socket 
functions.  This device accepts proprietary commands (e.g.: "KPRINT", 
as seen below), and returns data.  However, this device does not have 
any sort of "EXIT" command to end the processing of events.  So it 
essentially loops forever.


I do know that if this device does not return anything after 5 
seconds, it will never return anything.


So, my question is:  how can I force this script to stop after 5 
seconds has elapsed?


Here's the script:


$fp = fsockopen('192.168.3.25', 10001, $errno, $errstr, 5);

if (!$fp) {
echo 'Error...';
} else {
$command = "KPRINT\r\n";

fwrite($fp, $command);

while (!feof($fp)) {
$buffer = fgets($fp, 1024);
}

fclose($fp);
}


Thanks!



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



[PHP] How do I force my script to exit after 5 seconds?

2007-02-22 Thread Aaron Gould
I have a script that connects to a networked device via PHP's socket 
functions.  This device accepts proprietary commands (e.g.: "KPRINT", as 
seen below), and returns data.  However, this device does not have any 
sort of "EXIT" command to end the processing of events.  So it 
essentially loops forever.


I do know that if this device does not return anything after 5 seconds, 
it will never return anything.


So, my question is:  how can I force this script to stop after 5 seconds 
has elapsed?


Here's the script:


$fp = fsockopen('192.168.3.25', 10001, $errno, $errstr, 5);

if (!$fp) {
echo 'Error...';
} else {
$command = "KPRINT\r\n";

fwrite($fp, $command);

while (!feof($fp)) {
$buffer = fgets($fp, 1024);
}

fclose($fp);
}


Thanks!

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



Re: [PHP] how do I just escape double quotes within a string?

2007-02-13 Thread tg-php
You could use addslashes():
http://us3.php.net/manual/en/function.addslashes.php

Or, the code you mentioned below, could be rewritten like:
str_replace("\"","\\"",$code);
or
str_replace('"','\"',$code);

And if you're doing it for a MySQL query call, then you want to use 
mysql-real-escape-string() instead of all that mess above:
http://www.php.net/manual/en/function.mysql-real-escape-string.php

What's happening with the example you gave is that you're having a conflict 
with using the same type of string encloser (what's the proper word for single 
and double quotes in this case? hah).

""" = "" with a dangling ".  Error.

"\"" = a string containing just a double quote.

Everything inside "" is interpreted.

Everything inside '' is taken literally.

'"' = a string containing a double quote

''' = '' with a dangling ' on the end
'\'' = a string containing '  (I think.. I think this is the only exception to 
no-interpretation-within-single-quotes)

Some more information on single and double quotes here:
http://us3.php.net/manual/en/language.types.string.php#language.types.string.syntax.single

-TG

= = = Original message = = =

If I use add slashes, it strips everything, I just want to replace all the
double quotes with slash double quote but this, of course, throws errors:

str_replace(""","\"",$code);


Thanks!


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

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



Re: [PHP] how do I just escape double quotes within a string?

2007-02-13 Thread Eric Butera

On 2/13/07, blackwater dev <[EMAIL PROTECTED]> wrote:

If I use add slashes, it strips everything, I just want to replace all the
double quotes with slash double quote but this, of course, throws errors:

str_replace(""","\"",$code);


Thanks!



Try this

$string = 'Hello "person." How are you?';
var_dump($string);
var_dump(str_replace('"', '\"', $string));

Notice you can use single and double quotes in the same string.

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



[PHP] how do I just escape double quotes within a string?

2007-02-13 Thread blackwater dev

If I use add slashes, it strips everything, I just want to replace all the
double quotes with slash double quote but this, of course, throws errors:

str_replace(""","\"",$code);


Thanks!


Re: [PHP] How do I get ini_set('output_handler', '') to work?!

2006-11-02 Thread Richard Lynch
On Wed, November 1, 2006 3:42 pm, Ed Lazor wrote:
>> Unless you want to pre-parse set_ini() for constants differently
>> than
>> set_ini() for variables. [shudder]
>
> It sounds like we just need support for pre-parser commands.  You end
> up with one set of variables, but now you have the opportunity to
> change attributes of the environment before script processing
> begins.  Then again, there's probably problems related to doing
> something like this.  Any idea of what they would be?

The pre-parser commands opens up a whole can of worms of complexity.

The issue has been resurrected since at least PHP 3.0 days, and
presumably before that.

The biggest stumbling block, imho, is that it goes against the grain
of the simplicity of PHP.

I'm sure that it could be done technologically.  But being able to do
something doesn't make it the Right Thing to do.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] How do I get ini_set('output_handler', '') to work?!

2006-11-01 Thread Ed Lazor

Unless you want to pre-parse set_ini() for constants differently than
set_ini() for variables. [shudder]


It sounds like we just need support for pre-parser commands.  You end  
up with one set of variables, but now you have the opportunity to  
change attributes of the environment before script processing  
begins.  Then again, there's probably problems related to doing  
something like this.  Any idea of what they would be?


-Ed

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



RE: [PHP] How do I get ini_set('output_handler', '') to work?!

2006-11-01 Thread Richard Lynch
On Tue, October 31, 2006 6:22 pm, Daevid Vincent wrote:
>> There is nothing to "re-compile" here.
>> The command line has an existing flag for you to specify the php.ini
>> file, or to override any setting[s] within the php.ini file.
>
> Mebbe so, but that's equally obnoxious to pass this command line
> parameter
> to a lot of existing scripts. It's just easier to re-compile and
> 'globally'
> set the output_handler in a different php.ini file to what it used to
> be
> before we optimized. This script issue has just started to rear it's
> ugly
> head as we used to just use the default handler till recently. Our web
> pages
> work great (obviously), but we've noticed strangeness with the CLI
> stuff.
> Hence this dilemna.

I just don't get this...

You're going to recompile all of PHP to embed a string into the
executable to point to a different "php.ini" instead of just putting
that in your shell script somewhere?

Okay.
[shrug]

Have at it.

>> Bottom line, you can't step in the same river twice, and if php.ini
>> tells PHP to set up an ob_* handler before your script runs, it's
>> impossible to "undo" that just because you changed a setting that's
>> already been acted upon.
>
> I would agree if PHP used a one-pass parser. But there is a
> pre-parsing to
> lint check and other 'setup' stuff. Seems that could utilize and
> prepare the
> set_ini() for the second pass which runs the actual script.
>
> Nothing is "impossible". It's just not implemented.

But many set_ini() are meant to be changed in real-time with the
execution of the script!

So you'd have to parse for only the set_ini() that has your particular
setting.

Plus, there's no law that the args to set_ini() can't be from a
database, or other dynamic data in a variable.  So you'd have to
execute the whole program to find out what the values are in some
cases.

Unless you want to pre-parse set_ini() for constants differently than
set_ini() for variables. [shudder]

If you think this should be implemented, feel free to take it up with
-internals@ or just submit a patch...

But I honestly think you haven't really examined this in enough detail
to understand why you're just not making sense here... :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] How do I get ini_set('output_handler', '') to work?!

2006-10-31 Thread Daevid Vincent
> There is nothing to "re-compile" here.
> The command line has an existing flag for you to specify the php.ini
> file, or to override any setting[s] within the php.ini file.

Mebbe so, but that's equally obnoxious to pass this command line parameter
to a lot of existing scripts. It's just easier to re-compile and 'globally'
set the output_handler in a different php.ini file to what it used to be
before we optimized. This script issue has just started to rear it's ugly
head as we used to just use the default handler till recently. Our web pages
work great (obviously), but we've noticed strangeness with the CLI stuff.
Hence this dilemna.

> Bottom line, you can't step in the same river twice, and if php.ini
> tells PHP to set up an ob_* handler before your script runs, it's
> impossible to "undo" that just because you changed a setting that's
> already been acted upon.

I would agree if PHP used a one-pass parser. But there is a pre-parsing to
lint check and other 'setup' stuff. Seems that could utilize and prepare the
set_ini() for the second pass which runs the actual script.

Nothing is "impossible". It's just not implemented.

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



RE: [PHP] How do I get ini_set('output_handler', '') to work?!

2006-10-31 Thread Richard Lynch
On Mon, October 30, 2006 7:19 pm, Daevid Vincent wrote:
> Thank you for the reply Richard (and Tom).
>
> That news sucks however. Seems that the PHP pre-parser should handle
> this
> better. It's not like it's a one-pass parser (like Ruby).
>
>  ini_set('output_handler', 'mb_output_handler');
> echo "\noutput_handler => " . ini_get('output_handler') . "\n";
> ?>
>
> I suppose I could re-compile my command line version with a different
> php.ini file, but that's kind of lame that I have to have two php.ini
> files
> for what ini_set() SHOULD handle.

There is nothing to "re-compile" here.

The command line has an existing flag for you to specify the php.ini
file, or to override any setting[s] within the php.ini file.

> What other undocumented "gotchas" are there with ini_set() I wonder...

Most of these ARE documented in that PER INI DIR page on php.net

This one probably is as well.

Bottom line, you can't step in the same river twice, and if php.ini
tells PHP to set up an ob_* handler before your script runs, it's
impossible to "undo" that just because you changed a setting that's
already been acted upon.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] How do I get ini_set('output_handler', '') to work?!

2006-10-30 Thread Ed Lazor


I suppose I could re-compile my command line version with a different
php.ini file, but that's kind of lame that I have to have two  
php.ini files

for what ini_set() SHOULD handle.


Would modifications via .htaccess work for you?
-Ed

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



  1   2   3   4   5   6   7   8   9   >