php-general Digest 6 Mar 2008 09:39:54 -0000 Issue 5332
Topics (messages 271051 through 271068):
Re: Pear Installation Problem - Ubuntu
271051 by: Stephen
271053 by: Shawn McKenzie
271054 by: Stephen
Re: Preserving URL after redirect?
271052 by: Shawn McKenzie
Open Source Software Recomendation
271055 by: Joey
Re: Array questions...
271056 by: Jim Lucas
Alternative to Quickforms - Not Use Tables
271057 by: Stephen
271059 by: Manuel Lemos
271060 by: Shawn McKenzie
SOAP PHP 5.2.5 and Outside WSDL's
271058 by: Jonathan Pitcher
How to measure memory leakage/usage in PHP?
271061 by: Zareef Ahmed
271062 by: Chris
271063 by: Zareef Ahmed
271064 by: Chris
271065 by: Zareef Ahmed
271067 by: Frank Arensmeier
Re: imagettftext and utf-8 (swedish characters)
271066 by: David Sveningsson
Re: Logging session timeout in DB
271068 by: Angelo Zanetti
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 ---
Wolf wrote:
Open a terminal window on the server
at the prompt type:
locate QuickForm.php
If it comes back with the path/file, make sure the path to the file is in the
include folder
If it comes back to just a regular terminal prompt right away, then you need to
install it.
The following is what you get when it is NOT located:
~$ locate Quickform.php
~$
You could also run the following:
~$ pear list
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.3.2 stable
Auth 1.5.4 stable
> .....
Thank you.
I just have four packages installed. I need to grab some and install them.
Stephen
--- End Message ---
--- Begin Message ---
Stephen wrote:
> Wolf wrote:
>
>> Open a terminal window on the server
>> at the prompt type:
>> locate QuickForm.php
>>
>> If it comes back with the path/file, make sure the path to the file is
>> in the include folder
>>
>> If it comes back to just a regular terminal prompt right away, then
>> you need to install it.
>>
>> The following is what you get when it is NOT located:
>> ~$ locate Quickform.php
>> ~$
>> You could also run the following:
>> ~$ pear list
>> Installed packages, channel pear.php.net:
>> =========================================
>> Package Version State
>> Archive_Tar 1.3.2 stable
>> Auth 1.5.4 stable
>> .....
>
> Thank you.
>
> I just have four packages installed. I need to grab some and install them.
>
> Stephen
>
sudo pear install HTML_QuickForm
--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:
sudo pear install HTML_QuickForm
That was so easy.
Thank you!
Stephen
--- End Message ---
--- Begin Message ---
Skip Evans wrote:
> (Apologies to Shawn for sending this directly to him and not the entire
> list, that was an accident. Here it is for the list.)
>
> Shawn McKenzie wrote:
> <SNIP!>
>>
>> Rewrite rule would look something like:
>>
>> <IfModule mod_rewrite.c>
>> RewriteEngine On
>> RewriteCond %{REQUEST_FILENAME} !-d
>> RewriteCond %{REQUEST_FILENAME} !-f
>> RewriteRule ^(.*)$ index.php?path=$1 [QSA,L]
>> </IfModule>
>>
>> -Shawn
>>
>
> My httpd.conf file has this
>
> LoadModule rewrite_module
> libexec/apache2/mod_rewrite.so
>
> But your .htaccess sample has
>
> IfModule mod_rewrite.c
>
> Is that okay?
>
It Works for me and I have the same mod_rewrite.so line. Not sure the
specifics of why this is as it is.
> Also, it does look like .htaccess is enabled in
> httpd.conf with entries like:
>
> #
> # AllowOverride controls what directives may be
> placed in .htaccess files.
> # It can be "All", "None", or any combination of
> the keywords:
> # Options FileInfo AuthConfig Limit
> #
> AllowOverride All
>
> #
> # AccessFileName: The name of the file to look for
> in each directory
> # for additional configuration directives. See
> also the AllowOverride
> # directive.
> #
> AccessFileName .htaccess
>
> But when I tried out Shawn's file I got 404 errors
> on the URLs (after renaming the wi directory, to
> be sure the .htaccess file was in control.)
>
> Any suggestions would be greatly appreciated.
>
> I'm going through a pretty good page on htaccess files at
>
> http://corz.org/serv/tricks/htaccess2.php
>
> But it starts off with "Make no mistake, mod_rewrite is complex."
>
> *gulp!*
>
> Skip
>
So you have the .htaccess file in the root dir alongside the index.php?
I just tested and this is working for me. What I posted rewrites
everything to index.php so if you have other php pages that are loaded
by the browser then you would need better rules in .htaccess.
To see more you might add the following and then check the log:
RewriteLog "/somepath/rewrite.log"
RewriteLogLevel 3
-Shawn
--- End Message ---
--- Begin Message ---
Hey All,
Can you guys tell me of a good open source package which does things like
craiglist/backpage etc?
Also has anyone had good success with PHPcalendar?
Thanks!
--- End Message ---
--- Begin Message ---
I won't address the main issue of your question, since it looks like that has
been solved. But I want to point out a few other things that might help you.
Follow along below...
Jason Pruim wrote:
So for some reason, arrays always mess me up... I don't know what it is,
but it just hasn't clicked yet... So I'm sure this is a simple question
for someone who knows and understands arrays :)
So with that being said here's the code I'm using:
$self = $_SERVER['PHP_SELF'];
$i="0";
if (isset($_GET['txtNum'])) {
$numBox= $_GET['txtNum'];
$_SESSION['num'] = $_GET['txtNum'];
}else{
here you need to make sure that $_SESSION['num'] exists.
If not you will get a E_NOTICE warning level error.
So, you should have this
} else if ( isset($_SESSION['num']) ) {
$numBox = $_SESSION['num'];
}
And then follow up the previous thing with this else statement
} else {
echo 'no "num" set';
// AND / OR
$numBox = 0;
}
echo "store box variable". $_SESSION['num'];
echo <<<HTML
<form method="GET">
How many boxes? <input type="text" size="2" name="txtNum">
<BR>
<input type="submit"></form>
HTML;
$NumArray= Array($_POST['txtNumArray[]']);
echo <<<TABLE
<P>Weight of 100 pieces: <input type="text" size="5"
name="txtPieceWeight"></P>
<table border="1"><tr><th>Route #</th><th>Pieces in
route</th><th>Weight of route</th></tr>
TABLE;
echo "<form method=\"POST\" action=\"$self\">";
Change this to "post" <-- spec says lower case on the value
And, you could get rid of the echo and move it to the last line of the previous
HEREDOC statement
while($i < $numBox){
echo <<<HTML
<tr>
<td>
<input type="text" size="5" name="txtNumArray[]"
Here you would use just value="txtNumArray[{$i}]"
value="txtNumArray[$i]">
Here you would use just value="{$i}"
</td>
<td>
<input type="text" size="5" name="txtPiecesArray[]"
Here you would use just value="txtPiecesArray[{$i}]"
value="txtPiecesArray[$i]">
Here you would use just value="{$i}"
</td>
<td>
<input type="text" size="5" name="txtWeightArray[]"
Here you would use just value="txtWeightArray[{$i}]"
value="txtWeightArray[$i]">
Here you would use just value="{$i}"
</td>
</tr>
HTML;
$i++;
}
echo "<input type=\"submit\"></form>";
The reason I would do the above, is to make sure that all three arrays are in
sync.
What I'm attempting to do, is grab the info out of txtNumArray[] and put
it into the variable $numArray Sounds easy enough right? Well I've tried
using $NumArray = Array($_POST['txtNumArray[]'); but that's not
working... I've tried $NumArray = $_POST['txtNumArray[]']; which didn't
work... and I've looked on the php manual, but they all assume you
understand this stuff which I do not :)
Anyone know what I'm doing wrong? Or could at least point me to some
text like "Array's for Dummies"? :)
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
Subject says it.
Is there an open source class for forms that provides for the use of CSS
for the layout of forms?
Thanks
Stephen
--- End Message ---
--- Begin Message ---
Hello,
on 03/05/2008 08:22 PM Stephen said the following:
> Subject says it.
>
> Is there an open source class for forms that provides for the use of CSS
> for the layout of forms?
You may want to try this forms generation and validation class. It comes
with a vertical layout plug-in. By default it uses tables, so you do not
have to hardcode widths to make field rows and label columns align, but
you can override the default templates and set them to use tableless HTML.
http://www.phpclasses.org/formsgeneration
Take a look at the test_auto_layout_form.php example.
--
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 ---
Manuel Lemos wrote:
> Hello,
>
> on 03/05/2008 08:22 PM Stephen said the following:
>> Subject says it.
>>
>> Is there an open source class for forms that provides for the use of CSS
>> for the layout of forms?
>
> You may want to try this forms generation and validation class. It comes
> with a vertical layout plug-in. By default it uses tables, so you do not
> have to hardcode widths to make field rows and label columns align, but
> you can override the default templates and set them to use tableless HTML.
>
> http://www.phpclasses.org/formsgeneration
>
> Take a look at the test_auto_layout_form.php example.
>
I knew it! I was going to suggest phpclasses. Also, depending upon
what you do in your apps, consider a framework. There are many to
choose from. I have evaluated several and prefer cakephp. Normally you
won't use php to build the form but use html templates.
-Shawn
--- End Message ---
--- Begin Message ---
I am connecting to a Third Party WSDL that needs me to turn return an Array
of results to them. I do and PHP returns this ...
<SOAP-ENV:Body>
<ns1:addParties>
<in0 xsi:type="ns2:AuthenticationInfo">
<locale xsi:type="xsd:string">en</locale>
<token
xsi:type="xsd:string">50d3c78a0213b3e083ce7b6c7fa760a299798246fb6bbf1dc2dc81
12a841454d5bcb9cb752b18e299cd9be84214175b6c971065d8df08b52283408b925dd854128
5a031ca29c39b945989b951e2523594f5c9c0aa7bbfc328c87441830b47cd0</token>
<userType xsi:type="xsd:int">1</userType>
</in0>
<in1 SOAP-ENC:arrayType="ns2:EditConferenceParty[2]"
xsi:type="ns3:ArrayOf_tns1_EditConferenceParty">
<item xsi:type="ns2:EditConferenceParty">
<conferenceId xsi:type="xsd:int">163</conferenceId>
<phoneNumber xsi:type="xsd:string">9999999999</phoneNumber>
</item>
<item xsi:type="ns2:EditConferenceParty">
<conferenceId xsi:type="xsd:int">163</conferenceId>
<phoneNumber xsi:type="xsd:string">9999999999</phoneNumber>
</item>
</in1>
</ns1:addParties>
</SOAP-ENV:Body>
Problem is they need something like:
<EditConference>
<conferenceId>163</conferenceId>
<phoneNumber>9999999999</ phoneNumber>
</EditConference>
<EditConference>
<conferenceId>163</conferenceId>
<phoneNumber>9999999999</ phoneNumber>
</EditConference>
I found a good read here that says it deals with the way PHP handles
outputting arrays.
http://archive.netbsd.se/?ml=soap&a=2006-01&m=1677392
Is this truly considered a bug ? If so has it been resolved in the current
releases of PHP ?
If not does anyone have a simple solution ? I can figure out a way to code
the XML myself and send it but honestly was hoping for a simplier solution
that didn't envolve writing XML by hand.
Jonathan Pitcher
--- End Message ---
--- Begin Message ---
Hi All,
I am looking into the concepts behind memory management in PHP. Which
kind of approach will be best to measure memory leakage or usage in a PHP
script?
I can measure my apache process but is there any way by which I can know
which exact part of script is consuming how much memory?
--
Zareef Ahmed
http://www.zareef.net
A PHP Developer in India
--- End Message ---
--- Begin Message ---
Zareef Ahmed wrote:
Hi All,
I am looking into the concepts behind memory management in PHP. Which
kind of approach will be best to measure memory leakage or usage in a PHP
script?
I can measure my apache process but is there any way by which I can know
which exact part of script is consuming how much memory?
Start off with putting something like this:
error_log('in file ' . __FILE__ . ' at line ' . __LINE__ . ' memory
usage is ' . memory_get_usage(true) . "\n", 3, '/path/to/log.file');
every 100 lines and work out where your spikes are.
When you're looking at a section that jumps a lot, put it every 10 lines
- work out which parts are causing the big jumps and go from there.
Or use xdebug profiling to work out which parts of your app are being
used the most and start there - http://xdebug.org/docs/profiler
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Hi Chris,
Thanks for such quick response.
quite good suggestion, but my application is using a framework and lots of
includes and even autoloads of classes are being done, so using break point
approach is not possible for me.
Well, trying to do something so I can call my memory usage function after
certain number of lines or predefined life time of php script, any
suggestion?
Thanks and Regards
Zareef Ahmed
On 3/6/08, Chris <[EMAIL PROTECTED]> wrote:
>
> Zareef Ahmed wrote:
> > Hi All,
> >
> > I am looking into the concepts behind memory management in PHP. Which
> > kind of approach will be best to measure memory leakage or usage in a
> PHP
> > script?
> >
> > I can measure my apache process but is there any way by which I can know
> > which exact part of script is consuming how much memory?
>
>
> Start off with putting something like this:
>
> error_log('in file ' . __FILE__ . ' at line ' . __LINE__ . ' memory
> usage is ' . memory_get_usage(true) . "\n", 3, '/path/to/log.file');
>
> every 100 lines and work out where your spikes are.
>
> When you're looking at a section that jumps a lot, put it every 10 lines
> - work out which parts are causing the big jumps and go from there.
>
>
> Or use xdebug profiling to work out which parts of your app are being
> used the most and start there - http://xdebug.org/docs/profiler
>
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
--
Zareef Ahmed
http://www.zareef.net
A PHP Developer in India
--- End Message ---
--- Begin Message ---
Zareef Ahmed wrote:
Hi Chris,
Thanks for such quick response.
quite good suggestion, but my application is using a framework and lots
of includes and even autoloads of classes are being done, so using break
point approach is not possible for me.
Why not? It just means the files are spread out in different folders
instead of one place.
If you're using a framework, set up a new very simple environment and
see how much memory that uses by itself (see
http://www.php.net/memory_get_peak_usage).
That'll at least tell you whether it's the framework using all the
memory or your specific changes to it.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
HI Chirs,
On 3/6/08, Chris <[EMAIL PROTECTED]> wrote:
>
> Zareef Ahmed wrote:
> > Hi Chris,
> >
> > Thanks for such quick response.
> >
> > quite good suggestion, but my application is using a framework and lots
> > of includes and even autoloads of classes are being done, so using break
> > point approach is not possible for me.
>
>
> Why not? It just means the files are spread out in different folders
> instead of one place.
>
> If you're using a framework, set up a new very simple environment and
> see how much memory that uses by itself (see
> http://www.php.net/memory_get_peak_usage).
>
> That'll at least tell you whether it's the framework using all the
> memory or your specific changes to it.
I have done that check and I am sure that only my changes are taking time,
but they are large in numbers, so I was looking something to pin point the
exact change which is consuming more memory. Thanks for your suggestions, I
will definitely use them.
--
>
> Postgresql & php tutorials
> http://www.designmagick.com/
>
--
Zareef Ahmed
http://www.zareef.net
A PHP Developer in India
--- End Message ---
--- Begin Message ---
6 mar 2008 kl. 06.10 skrev Zareef Ahmed:
HI Chirs,
On 3/6/08, Chris <[EMAIL PROTECTED]> wrote:
Zareef Ahmed wrote:
Hi Chris,
Thanks for such quick response.
quite good suggestion, but my application is using a framework
and lots
of includes and even autoloads of classes are being done, so
using break
point approach is not possible for me.
Why not? It just means the files are spread out in different folders
instead of one place.
If you're using a framework, set up a new very simple environment and
see how much memory that uses by itself (see
http://www.php.net/memory_get_peak_usage).
That'll at least tell you whether it's the framework using all the
memory or your specific changes to it.
I have done that check and I am sure that only my changes are
taking time,
but they are large in numbers, so I was looking something to pin
point the
exact change which is consuming more memory. Thanks for your
suggestions, I
will definitely use them.
You should be able to do that with a so called tick function.
From the manual: "A tick is an event that occurs for every N low-
level statements executed by the parser within the declare block. The
value for N is specified using ticks=N within the declare blocks's
directive section."
Have a look at the function 'register_tick_function'. Take the
function that was suggested previously by Chris and make it a tick
function.
//frank
--
Postgresql & php tutorials
http://www.designmagick.com/
--
Zareef Ahmed
http://www.zareef.net
A PHP Developer in India
--- End Message ---
--- Begin Message ---
tedd skrev:
At 2:17 AM +0000 2/29/08, Nathan Rixham wrote:
Nathan Rixham wrote:
try changing:
imagettftext( $im, $title_size, 0, 50, 50, $white, $font, $title );
to:
imagettftext($im, $title_size, 0, 50, 50, $white, $font,
utf8_decode($title));
Both statements work for me. -- see here:
http://www.webbytedd.com/b1/special-char/
But I don't know -- it looks Swedish to me. :-)
Cheers,
tedd
I've started thinking something is wrong with my php installation as it
seems to work for everyone else. Wrote more details in an earlier mail.
Sidenote: If I replace åäö with numerical html entities it works, but
that's not a reasonable solution to me.
--
//*David Sveningsson [eXt]*
Freelance coder | Game Development Student
http://sidvind.com
Thou shalt make thy program's purpose and structure clear to thy fellow
man by using the One True Brace Style, even if thou likest it not, for
thy creativity is better used in solving problems than in creating
beautiful new impediments to understanding.
--- End Message ---
--- Begin Message ---
Thanks Daniel, this is a good solution, I will implement it and get it
working!
Cheers
Angelo
-----Original Message-----
From: Daniel Brown [mailto:[EMAIL PROTECTED]
Sent: 05 March 2008 20:37
To: Angelo Zanetti
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Logging session timeout in DB
On Wed, Mar 5, 2008 at 3:08 AM, Angelo Zanetti <[EMAIL PROTECTED]>
wrote:
[snip!]
> No what I would like to know is how can I record when a user closes the
> browser or the session expires? There is no action for these items. So
what
> would the best way be to keep a record of this? Would the use of a cron
job
> be appropriate? I read in the archives that the banks use javascript but
I
> don't want to go that route.
One way that comes to mind right off the bat would be to utilize
an idea similar to the following. You'll need to secure it and tailor
it to your own needs, but it should point you in the right direction.
<?
// Place this function in a file that's included
// in all pages for users that are logged in.
// The field last_seen is INT(10)
function updateLoginTable($uid) {
$sql = "UPDATE yourTable SET last_seen='".time()."' WHERE
uid='".$uid."' LIMIT 1";
mysql_query($sql);
}
?>
<?
// This will be your cron job.
// Include your database config here.
// The field is_active is BOOL
$secs = 600; // Number of seconds to wait before considering logged out
$diff_secs = (time() - $secs);
$sql = "UPDATE yourTable SET is_active='0' WHERE last_seen >
'".$diff_secs."'";
mysql_query($sql);
?>
Then, add this to your crontab:
*/1 * * * * `which php` /path/to/cron/script.php
It will run every minute, making users who have not accessed a
page within the previous 10 minutes inactive. It's untested, but
hopefully it will point you in the right direction anyway.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---