php-general Digest 3 Dec 2005 22:14:45 -0000 Issue 3830
Topics (messages 226810 through 226820):
PHP 5.1.1 still slower than PHP 4.x
226810 by: Brian Moon
Re: xml->load via dom and http authentication
226811 by: Curt Zirzow
Re: Mail SMTP settings
226812 by: Curt Zirzow
need session_start() to recall session data.
226813 by: Matt Monaco
226815 by: Curt Zirzow
226816 by: Matt Monaco
Re: Newline character problem...
226814 by: tg-php.gryffyndevelopment.com
Re: A basic question
226817 by: Unknown Unknown
Re: hi everyone
226818 by: Unknown Unknown
Re: javascript, forms and php
226819 by: Unknown Unknown
Security/$_REQUEST vars... How do you do it?
226820 by: Michael Hulse
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 ---
I had run the numbers a while back when 5.0 came out and found that it
was slower than the 4.x releases at that time. It seems that 5.1.1 does
not change this. Even very simple scripts take longer. Phorum does not
use any OO code, so, maybe that is the deal. Did OO get a big jump in
speed? I hope they did, because the folks that like procedural code got
no speed that I can find.
See my results here: http://phorum.org/phorum5/read.php?14,52162
Brian Moon
Phorum Dev Team
--- End Message ---
--- Begin Message ---
On Thu, Dec 01, 2005 at 11:31:45AM -0800, jonathan wrote:
> i'm loading a dynamically generated xml file like this:
>
>
> $xml=new DomDocument();
> $xml->load("menu_render.php?menu_id=$menu_id&format=xml");
>
> The problem is that this file is in a directory that requires http
> authentication (via the .htpasswds file).
>
> How could I specify the uname and pwd loading this? I'm using php5
> and apache 1.3.33
I'm assuming you actually have something like:
$xml->load("http://hostname/menu_render.php?menu_id=$menu_id&format=xml");
Just specify the username and pass in the url:
http://username:[EMAIL PROTECTED]/menu_render.php?...');
Curt.
--
cat .signature: No such file or directory
--- End Message ---
--- Begin Message ---
On Sat, Dec 03, 2005 at 12:45:24AM -0700, Dan wrote:
> I have a PHP 4.x install on an Apache server. I have a PHP
> application and a call to the mail function. I have 2 static IP's on
> the server and I have one web server and one instance of postfix for
> each IP to basically separate the two sites. The only issue I have
> right now is sending mail via PHP.
>
> I have tried to set the SMTP server and reply address via a php_value
> in my httpd.conf file and via the ini_set function for my site in
> question. Regardless of these setting mail is sent from the www user
> at my main site domain:
The ini setting is called 'sendmail_from'. or you can use the 5th
argument in the mail command.
Curt.
--
cat .signature: No such file or directory
--- End Message ---
--- Begin Message ---
I have the following two methods as part of a class I'm using to transport
data between pages.
static function pack($object)
{
if (session_id() == "") {
session_start();
}
$class = get_class($object);
$_SESSION["cmsSessionArray"][$class] = serialize($object);
}
static function unpack($strObject)
{
session_start();
return unserialize($_SESSION["cmsSessionArray"][$strObject]);
}
the pack() method is called by the destructor of the objects I want to save
like:
function __destruct()
{
parent::pack($this);
}
On subsequent pages the session data is not available until I do a
session_start(). Regardless of the fact that I think the session shouldn't
need to be restarted, I don't like the fact that if indeed it has been
closed that a session_start() on another page will bring back the data.
(Note, fortunately this doesn't not occur if the browser window has been
closed, at that point all session data is definitely lost as expected.)
Are session supposed to work this way?
--- End Message ---
--- Begin Message ---
On Sat, Dec 03, 2005 at 01:28:21PM -0500, Matt Monaco wrote:
> I have the following two methods as part of a class I'm using to transport
> data between pages.
>
> static function pack($object)
> {
> if (session_id() == "") {
> session_start();
I wouldn't put a random session_start() in places like this.
> }
>
> $class = get_class($object);
> $_SESSION["cmsSessionArray"][$class] = serialize($object);
> }
> ...
>
> the pack() method is called by the destructor of the objects I want to save
> like:
> function __destruct()
> {
> parent::pack($this);
> }
>
> On subsequent pages the session data is not available until I do a
> session_start(). Regardless of the fact that I think the session shouldn't
> need to be restarted, I don't like the fact that if indeed it has been
> closed that a session_start() on another page will bring back the data.
> (Note, fortunately this doesn't not occur if the browser window has been
> closed, at that point all session data is definitely lost as expected.)
I'm not sure what you mean by restarting a session or what 'indeed
has been closed'
btw, your pack and unpack aren't really needed. All you have to do
is in your __destruct() function is put something like:
$_SESSION['cmsSessionArray'][__CLASSNAME__] = $this;
And when you pull it out of the session:
$obj = $_SESSION['cmsSessionArray']['someClass'];
You'll have an instance of that class; you're really causing more
work than needed.
Curt.
--
cat .signature: No such file or directory
--- End Message ---
--- Begin Message ---
Yes, I actually changed the destructors to handle the session as you
indicated a few minutes after I posted, however I still have no clue as to
why I would need to do a session_start() to get data from the session.
"Curt Zirzow" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Sat, Dec 03, 2005 at 01:28:21PM -0500, Matt Monaco wrote:
>> I have the following two methods as part of a class I'm using to
>> transport
>> data between pages.
>>
>> static function pack($object)
>> {
>> if (session_id() == "") {
>> session_start();
>
> I wouldn't put a random session_start() in places like this.
>
>> }
>>
>> $class = get_class($object);
>> $_SESSION["cmsSessionArray"][$class] = serialize($object);
>> }
>> ...
>>
>> the pack() method is called by the destructor of the objects I want to
>> save
>> like:
>> function __destruct()
>> {
>> parent::pack($this);
>> }
>>
>
>> On subsequent pages the session data is not available until I do a
>> session_start(). Regardless of the fact that I think the session
>> shouldn't
>> need to be restarted, I don't like the fact that if indeed it has been
>> closed that a session_start() on another page will bring back the data.
>> (Note, fortunately this doesn't not occur if the browser window has been
>> closed, at that point all session data is definitely lost as expected.)
>
> I'm not sure what you mean by restarting a session or what 'indeed
> has been closed'
>
> btw, your pack and unpack aren't really needed. All you have to do
> is in your __destruct() function is put something like:
>
> $_SESSION['cmsSessionArray'][__CLASSNAME__] = $this;
>
> And when you pull it out of the session:
> $obj = $_SESSION['cmsSessionArray']['someClass'];
>
> You'll have an instance of that class; you're really causing more
> work than needed.
>
> Curt.
> --
> cat .signature: No such file or directory
--- End Message ---
--- Begin Message ---
In addition to what was mentioned below, you can also wrap your text in
<PRE></PRE> tags to have it output exactly as you've formatted it:
echo "<PRE>\n";
echo "one\n";
echo "two\n";
echo "</PRE>\n";
Actually, I don't think either of these methods is going to output what you
want. Even though \n is newline, it's still interpreted as newline/carriage
return. Unix, Mac and DOS/Windows PC's all use something different for a
newline character. I believe Unix was \n, Mac was \r at some point and
DOS/Windows PC's used \n\r. Think my old Amiga used \r as well. Goofy.
Anyway, it's proably because of this that you can't just do \n and expect it to
be represented as just a newline (sans carriage return).
If you use the <PRE> tag, then you can manually do what you want to do:
echo "<PRE>\n";
echo "one\n";
echo " two";
echo "</PRE>\n";
If you don't use the <PRE> tag, there's an HTML entity that you can use for a
hard space.. Unfortunately in HTML, if you stack a bunch of spaces,
it compresses them to one space.
echo "one two";
..and..
echo "one two";
Will both result in:
one two
If you use instead of spaces, it'll space it out further:
echo "one two";
Ugly but it works.
Unfortunately (again), if you don't use the <PRE> tags, you'll have to remember
to set a monospace font face or you won't get the text alignment you might want.
One other side nugget related to this (formatted and spaces and all that
nonsense), you can use the <NOBR></NOBR> tag to tell HTML not to word-wrap the
text within it. Comes in handy when you want to force a column heading to be
one line even though it's got a space in it and your browser wants to wrap the
line.
Good luck! Hope this helped a little.
-TG
= = = Original message = = =
Robert napisal(a):
> I'm new to PHP but not programming in general. I have used C++ for a while
> and I'm familiar with the newline character as it's basically the same in
> PHP.
> This is the most basic of examples:
> print 'one' ;
> print "\n" ;
> print 'two' ;
>
> The output of this when accessed on my server is: one two
> It should be: one
> two
Hi
well this isn't apache or php related, as it's webbrowser related, and
even more, it's correct.
The thing is, what You see in Your browser is an interpreted version of
the html outputed by the php (obvious?), so if You do a html file, and put:
one
two
in there, and view it with Your browser, it will still look like this:
one two
to get the expected (as in C/C++) result, You need to add a <br> or any
other line breaking method in there (<p>one</p><p>two</p> is another one)
Now, if You'd see the generated source code, You'd notice that there is
in fact the line break as it should be :)
so it is good to use '\n' to get the output code clear to read, for
debugging and so..
Best wishes
?ukasz Hejnak
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
--- End Message ---
--- Begin Message ---
Yeah, Apache (or other web server) just gives the HTML page to the web
browser without really doing anything, if a page has a .php extension Apache
gives the page to PHP which proccesses it and returns it to Apache and
Apache gives it to the client. You could do what Matt Monaco says and let
every HTML and PHP page be parsed by PHP but it makes load time slower for
HTML pages with no PHP in them
On 11/27/05, Matt Monaco <[EMAIL PROTECTED]> wrote:
>
> In your server configuration file (httpd.conf for apache) you specify
> which
> extensions are parsed by the php module. It is perfectly acceptable for
> you
> to specify .html in addition to .php as a parsed extension.
>
> "Oil Pine" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi,
> >
> > I am new to php scripting and would like to ask you a basic question.
> >
> > Could you kindly explain to me why "time.php" works but "time.html" does
> > not?
> >
> > pine
> >
> >
> >
> > time.php
> > ------------------------------------------------------
> > <?php
> >
> > $serverdate = date("l, d F Y h:i a");
> > print ("$serverdate");
> > print (" <p>");
> >
> > ?>
> > ---------------------------------------------------------
> >
> >
> > time.html
> > ---------------------------------------------------------------
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> > "http://www.w3.org/TR/html4/loose.dtd">
> > <html>
> >
> > <head>
> > <title>Local Time</title>
> > <meta name="GENERATOR" content="Text Editor">
> > <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
> > </head>
> > <body>
> > <p>This is a test.</p>
> > <?php
> > $serverdate = date("l, d F Y h:i a");
> > print ("$serverdate");
> > print (" <br>");
> > ?>
> > <p></p><p>This is the end.</p>
> > </body>
> > </html>
> > -------------------------------------------------------------------
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Hi Everyone, I am running PHP 5 on Windosws XP SP2 with MySQL5, Bye Now!
--- End Message ---
--- Begin Message ---
Quiet? you GOTTA be kidding me, i got like 400 PHP email's here, I don't
have to time to read em all
On 12/1/05, Mehmet Fatih AKBULUT <[EMAIL PROTECTED]> wrote:
>
> hi.
> me is registered but till now have had no crucial questions to ask :p
> but soon will need professional help on php ldap functions :)
> then will ask for help from you masters :p
> Regards.
> Bye for now.
>
>
--
Hi Everyone, I am running PHP 5 on Windosws XP SP2 with MySQL5, Bye Now!
--- End Message ---
--- Begin Message ---
DO NOT validate anything important with javascript, the user can easily
bypass the javascript by creating his own HTML page or disabling javascript
on his browser. if you *Absouloutly* need to use javascript, check the last
page the browser visited with Javascript or PHP and either allow or deny
access, still, even that is insecure. Now, for your main question, this is a
PHP board, not a Javascript board post this on a javascript list
On 12/1/05, Brent Baisley <[EMAIL PROTECTED]> wrote:
>
> You should have posted this to a javascript board, it has nothing to
> do with PHP. That said, if the form field name contains special
> characters, like [], you can reference it like this:
> document.formname.elements['checkbox1[]'].
>
> Use the elements[] reference style.
>
> On Dec 1, 2005, at 12:42 PM, Kelly Meeks wrote:
>
> > Hi all,
> >
> >
> >
> > I'm hoping someone can help me with this problem.
> >
> >
> >
> > I'm using javascript for some client side field validation in a form
> > (method=post) that gets managed via php.
> >
> >
> >
> > This particular form makes extensive use of checkboxes. I've
> > always like
> > how when named properly (field name of "checkbox1[ ]"), php will
> > pass that
> > variable as an array that contains all the values selected in the
> > form.
> > Very handy. BUT,
> >
> >
> >
> > How do you then reference that variable via javascript to do any
> > client-side
> > validation? The code I use makes reference to the field's id, and
> > it still
> > doesn't seem to check things properly.
> >
> >
> >
> > Is there any way around this, or what am I missing?
> >
> >
> >
> > TIA,
> >
> >
> >
> > Kelly
> >
> >
> > --
> > This message has been scanned for viruses and
> > dangerous content by MailScanner, and is
> > believed to be clean.
> >
>
> --
> Brent Baisley
> Systems Architect
> Landover Associates, Inc.
> Search & Advisory Services for Advanced Technology Environments
> p: 212.759.6400/800.759.0577
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Hi Everyone, I am running PHP 5 on Windosws XP SP2 with MySQL5, Bye Now!
--- End Message ---
--- Begin Message ---
Hello,
This is my first time posting to the list... I hope this question is
not too silly, I am definitely not a guru at PHP.
Anyway, in one of my latest projects, I find myself using this bit of
code quite a bit:
if((isset($_REQUEST['sub'])) && (!empty($_REQUEST['sub']))) {
... code here...
}
Can I write a function that would make my life easier? Maybe something
like this (not tested):
//////// function security_check():
function security_check($x) {
$error = false;
if((isset($x)) && (!empty($x))) {
$error = false;
return $error;
} else {
$error = true;
return $error;
}
}
Or, is it perfectly valid and secure to use @, like so:
@... code here...
I know that it completely depends on the what one is trying to
accomplish in ones scripts, but any guidance and/or suggestions would
be greatly appreciated.
Thanks, I really appreciate your time.
Cheers,
Micky
--
¸.·´¯`·.¸¸><(((º>`·.¸¸.·´¯`·.¸¸><((((º>
·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸><((((º>
`·.¸><((((º>¸.·´¯`·.¸¸><((((º>
--- End Message ---