php-general Digest 13 Jan 2008 06:07:00 -0000 Issue 5232
Topics (messages 267155 through 267163):
searching in multidimensional array for a date
267155 by: amosse\.libero\.it
Re: session_start problems with FireFox on Mac
267156 by: Terry Calie
267160 by: Anup Shukla
Re: SMTP vs mail()
267157 by: Manuel Lemos
Guestbook
267158 by: Andrés Robinet
Re: PHP shell commands
267159 by: Andrés Robinet
Any way to use header() or another function to force user to "top level"
267161 by: Chuck
267162 by: Jim Lucas
267163 by: Chuck
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Hello to everybody,
I am using the following function in order to search in multi-dimensional
array, as per note added on http://it.php.net/array_search,
[code]
function array_search_recursive($data0, $FinRecSet, $a=0, $nodes_temp=array()){
global $nodes_found;
$a++;
foreach ($FinRecSet as $key1=>$value1) {
$nodes_temp[$a] = $key1;
if (is_array($value1)){
array_search_recursive($data0, $value1, $a, $nodes_temp);
}
else if ($value1 === $data0){
$nodes_found = $nodes_temp[1];
}
}
return $nodes_found;
}
[/code]
where
$data0 is a date (ex:'1-1-2008')
and $FinRecSet is an array containing financial entries
like this
Array (
=> Array ( [Id] => 281 [Date] => 01-01-2008 [FCode] => A01 [Descr] => Prova
[Debit] => 100.00 [RunDeb] => 2065300.64 [Credit] => 0.00 [RunCre] =>
3020765.67 [RunBal] => -955465.03 [Rec] => 0 ) [1] => Array ( [Id] => 282
[Date] => 01-01-2008 [FCode] => A02 [Descr] => Prova [Debit] => 120.00 [RunDeb]
=> 2065420.64 [Credit] => 0.00 [RunCre] => 3020765.67 [RunBal] => -955345.03
[Rec] => 0 ) ect....
when I run function I get exactely the last entry with date = '1-1-2008',
problem is when I don't have entries on such date, for that I should modify
function in order to get entry on older date available before $data0.
For example if $date0 = '1-1-2008'
and first entry is available only on '30-12-2007', how should I modify function?
Thank you for your attention.
Amos
--- End Message ---
--- Begin Message ---
Hey... thanks for the replies. I installed the headers feature that
Richard suggested and found that no headers were output.
I started to transfer my php to another site to see if the problem
replicated and I wasn't able to recreate the problem.
It turns out that I "require" a file before the session_start that had
one stupid character of whitespace at the end of it. When I transferred
the php to recreate the problem, I replaced the "require" call with the
actual code - eliminating the whitespace at the end of the file, so the
problem didn't replicate. It took me a long time to figure out that was
the problem. What a killer!
To illustrate my php goes like this:
index.php
=========
<?php
code
code
require "index2.php"
code
?>
index2.php
========
<?php
code
code
code
?>
<whitespace character>
The <whitespace character> is actually just an extra newline "\n" at the
end of the file. So that gets output to the browser before the headers
and apparently doesn't lock up any browsers except FireFox on a Mac.
Thanks for the help. Just your courtesy in responses got me thinking in
a new direction.
Terry
Richard Lynch wrote:
Install Live HTTP Headers and see what headers are being sent.
Then search for those headers and FireFox Mac issues online.
On Fri, January 11, 2008 10:34 am, Terry Calie wrote:
Sorry if this is the wrong place to ask this question... if so please
help me figure out where to ask it. I've asked on FireFox forums and
was told it was a PHP problem and to ask the developers of PHP.
I have a PHP website that freezes in Firefox on a Mac. Every other
browser/operating system combination I have tested is fine. I've
narrowed down the problem to having to do with "session_start", which
is
the session tracking mechanism for php.
When I comment out session_start, the site works (but of course my
site
now becomes state-less). Again, the problem is ONLY on FireFox on a
Mac. It works fine on FireFox on a PC.
Any ideas as to what could be causing the problem with FireFox on Mac
and not on PC? (Safari on Mac works fine)
Thanks,
Terry
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Terry Calie wrote:
Hey... thanks for the replies. I installed the headers feature that
Richard suggested and found that no headers were output.
I started to transfer my php to another site to see if the problem
replicated and I wasn't able to recreate the problem.
It turns out that I "require" a file before the session_start that had
one stupid character of whitespace at the end of it. When I transferred
the php to recreate the problem, I replaced the "require" call with the
actual code - eliminating the whitespace at the end of the file, so the
problem didn't replicate. It took me a long time to figure out that was
the problem. What a killer!
You may use ob_clean() just before the header()
to get rid of the extra whitespaces.
--
Regards,
Anup Shukla
--- End Message ---
--- Begin Message ---
Hello,
on 01/12/2008 07:28 AM Per Jessen said the following:
>> Still if you want the fastest delivery in the world, you can skip
>> queueing and talk directly to the final SMTP server. That is what the
>> direct_delivery mode of this SMTP class does. I use it for deliverying
>> really urgent messages. It uses PHP only, there is no sendmail or any
>> MTA in the middle. That is why it is the fastest solution.
>
> Unless you're running on the mail-server or being NAT'ed through the
> same, this is not advisable. You run a significant risk of getting
> your emails caught as spam.
Of course PHP is running on the same machine as the MTA.
>> TCP connections are not a good idea for local connections. That is why
>> under Linux/Unix there are Unix domain sockets which are basically
>> pipes for inter-program communication.
>
> TCP connections are just fine for local connections. And on some
> platforms/setups they're even faster than Unix domain sockets.
!?!!? That is something odd to say. I would understand if you would say
that UDP sockets could be almost as fast as Unix domain sockets. But I
never heard of TCP sockets being faster than Unix domain sockets.
Every time I install MySQL on the same machine as the Web server, I
disable networking to make it use Unix domain sockets, for either
greater speed and security.
--
Regards,
Manuel Lemos
PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
Hi Guys,
Anybody knows of a free and decent PHP Multilanguage guestbook (or at least
supporting German and English)? I don't care if it is db-driven or uses flat
files.
I know how to write one, but it's for a website we didn't develop (but will
now host) and I'm feeling a bit lazy... maybe someone has a hint.
I don't care of how it looks, I can customize that, just want to write as
less code as possible and avoid any security headaches as well (yeah... the
good old lazy days :)).
Thanks in advance,
Rob
ndrés Robinet | Lead Developer | BESTPLACE CORPORATION
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308
| TEL 954-607-4207 | FAX 954-337-2695
Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE:
bestplace | Web: http://www.bestplace.biz | Web: http://www.seo-diy.com
--- End Message ---
--- Begin Message ---
Hi Lucas,
This is it http://www.suphp.org/Home.html. However, please bear in mind that
you may have some headaches after installing it. Some webmail scripts may
break, as well as existing websites, so you'd better off researching what
are the possible drawbacks.
My recommendation would be that if you work with a panel (Plesk, cPanel,
DirectAdmin, etc) you go to the panel's forums, because chances are high
that someone has already built a script to do the job for you, and you'll
also get answers to your questions before you run into trouble.
Also, I think there was a way of installing both PHP 4 and 5, one as CGI
(required by suPHP) and the other one as CLI so you could get the regular
PHP behaviour by setting up the corresponding VirtualHost.
For owr own domains we use PHP CLI only, as we control the code from top to
bottom, but for shared hosting, suPHP is recommended despite of the
headaches (mostly to your customers' poor PHP code, but in the end to your
support department)... though many hosting providers, just don't care and
run the risk (suPHP is not very old anyway).
Regards,
Rob
Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308
| TEL 954-607-4207 | FAX 954-337-2695
Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE:
bestplace | Web: http://www.bestplace.biz | Web: http://www.seo-diy.com
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
> Lucas Prado Melo
> Sent: Saturday, January 12, 2008 8:50 AM
> To: Andrés Robinet
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] PHP shell commands
>
> On Jan 12, 2008 4:12 AM, Andrés Robinet <[EMAIL PROTECTED]>
> wrote:
> > I guess what you are looking for is mod_suphp. STFW or ask the list,
> someone
> > will give you good hints for sure (sorry, have little time right
> now).
> >
> > Rob
> Thanks, I will take a look.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I have some code doing some checks that sit inside div tags using href elements:
...
<div class="pArea">
<a class="panel" href="code.php?xxxx=yyyy" target="pframe1" >Panel1</a>
...
In code.php, if various conditions aren't met, this script will do a
bunch of house cleaning, logging, then redirect using
header("Location: /some_url").
My problem is that /some_url comes up inside the div area, instead of
causing the browser to load /some_url as if accessed directly. Im
just starting to dabble with PHP so I'm sure there is another way of
doing this or maybe an argument to header() itself.
I'm looking for the same behavior as the HTML snippet <a href="/"
target="_top">here</a>
Once I make the call to header(), I no longer care about any state
information, session variables, or anything. Basically I am booting
the user out of the application and back to the login/splash page. All
information I need to retain has already been logged to various
mechanisms prior to calling header() which is immediately followed by
exit();
Thanks for any help,
CC
--- End Message ---
--- Begin Message ---
Chuck wrote:
I have some code doing some checks that sit inside div tags using href elements:
...
<div class="pArea">
<a class="panel" href="code.php?xxxx=yyyy" target="pframe1" >Panel1</a>
...
In code.php, if various conditions aren't met, this script will do a
bunch of house cleaning, logging, then redirect using
header("Location: /some_url").
My problem is that /some_url comes up inside the div area, instead of
causing the browser to load /some_url as if accessed directly. Im
just starting to dabble with PHP so I'm sure there is another way of
doing this or maybe an argument to header() itself.
I'm looking for the same behavior as the HTML snippet <a href="/"
target="_top">here</a>
Once I make the call to header(), I no longer care about any state
information, session variables, or anything. Basically I am booting
the user out of the application and back to the login/splash page. All
information I need to retain has already been logged to various
mechanisms prior to calling header() which is immediately followed by
exit();
Thanks for any help,
CC
Sounds like header() is what you are looking for then.
The one thing that you have to make sure is that you have not sent any
data to the browser. Use this:
<?php
#
#Do whatever you want here. Just don't output any data to the browser.
#
header('Location: http://www.example.com/');
exit;
# Always follow a header/location redirect with the "exit;" command.
?>
I have found that it is best to include the entire domain when using the
header/location redirect method.
--- End Message ---
--- Begin Message ---
That is exactly what I am using now but the location I am redirecting
to is loading within the <div> tags and at the top level of the
browser.
-CC
On 1/12/08, Jim Lucas <[EMAIL PROTECTED]> wrote:
> Chuck wrote:
> > I have some code doing some checks that sit inside div tags using href
> > elements:
> > ...
> > <div class="pArea">
> > <a class="panel" href="code.php?xxxx=yyyy" target="pframe1"
> > >Panel1</a>
> > ...
> >
> > In code.php, if various conditions aren't met, this script will do a
> > bunch of house cleaning, logging, then redirect using
> > header("Location: /some_url").
> >
> > My problem is that /some_url comes up inside the div area, instead of
> > causing the browser to load /some_url as if accessed directly. Im
> > just starting to dabble with PHP so I'm sure there is another way of
> > doing this or maybe an argument to header() itself.
> >
> > I'm looking for the same behavior as the HTML snippet <a href="/"
> > target="_top">here</a>
> >
> > Once I make the call to header(), I no longer care about any state
> > information, session variables, or anything. Basically I am booting
> > the user out of the application and back to the login/splash page. All
> > information I need to retain has already been logged to various
> > mechanisms prior to calling header() which is immediately followed by
> > exit();
> >
> > Thanks for any help,
> > CC
> >
>
> Sounds like header() is what you are looking for then.
>
> The one thing that you have to make sure is that you have not sent any
> data to the browser. Use this:
>
> <?php
>
> #
> #Do whatever you want here. Just don't output any data to the browser.
> #
>
> header('Location: http://www.example.com/');
> exit;
> # Always follow a header/location redirect with the "exit;" command.
>
> ?>
>
> I have found that it is best to include the entire domain when using the
> header/location redirect method.
>
>
--
Chuck Carson - Sr. Software Engineer
Galileo Educational Solutions
--- End Message ---