|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 11 Aug 2005 19:14:47 -0000 Issue 3619
php-general-digest-help
lists.php.net
Date: Thu Aug 11 2005 - 14:14:47 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 11 Aug 2005 19:14:47 -0000 Issue 3619
Topics (messages 220406 through 220466):
Re: force download
220406 by: Norbert Wenzel
Re: display error line in object method
220407 by: Norbert Wenzel
Re: dynamic object instances
220408 by: Thomas Angst
220410 by: Jochem Maas
220411 by: Jochem Maas
Re: How efficient is OOP in PHP5?
220409 by: Jochem Maas
220413 by: TalkativeDoggy
220414 by: Jochem Maas
220418 by: TalkativeDoggy
Regular expression question
220412 by: Leon Vismer
220423 by: b-bonini.cox.net
220427 by: Leon Vismer
220431 by: TalkativeDoggy
220434 by: Robin Vickery
220449 by: Leon Vismer
optional rule quick_form
220415 by: Uroš Gruber
220416 by: Torgny Bjers
220421 by: Uroš Gruber
220422 by: Torgny Bjers
Re: Redisplaying information from a HTML form
220417 by: Jim Moseby
220420 by: Torgny Bjers
Re: what should I look for with this error
220419 by: Jay Blanchard
220426 by: Bruce Gilbert
220430 by: John Nichel
220433 by: Jay Blanchard
220436 by: John Nichel
PHP script for removing/forwarding suspected spam from pop3 mailbox
220424 by: I. Gray
Re: REGEX for query
220425 by: Jay Blanchard
220428 by: Robin Vickery
220432 by: Jay Blanchard
220435 by: Michael Sims
Re: rename an uploaded file.
220429 by: Ford, Mike
XML manipulation using PHP
220437 by: Anas Mughal
220438 by: Jay Blanchard
220439 by: Jochem Maas
IP & Geographical
220440 by: John Taylor-Johnston
220441 by: Greg Donald
220442 by: Duncan Hill
220443 by: Greg Donald
220444 by: Jarratt Ingram
possible bug (string equality to zero)?
220445 by: Christopher J. Bottaro
220446 by: Jay Blanchard
220447 by: Torgny Bjers
220448 by: Scott Noyes
220451 by: Chris Shiflett
220452 by: Christopher J. Bottaro
220453 by: Christopher J. Bottaro
220454 by: Jay Blanchard
220457 by: xfedex
220463 by: Philip Hallstrom
Re: date field
220450 by: John Taylor-Johnston
Best practices for deleting and restoring records - moving vs flagging
220455 by: Saqib Ali
Oracle Question
220456 by: xfedex
220462 by: tg-php.gryffyndevelopment.com
220465 by: Joseph Oaks
PHP & smarty - nested queries and arrays
220458 by: Amanda Hemmerich
PHP and Active Directory
220459 by: xfedex
220460 by: Jay Blanchard
220461 by: Nathan Tobik
220466 by: xfedex
PHP, SSL and private keys
220464 by: Evert | Rooftop
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Richard Lynch wrote:
> Right-click is NOT universal.
>
> Macs don't even *have* a right-click!
Doesn't Ctrl-Click do the same as a right click?
Norbert
attached mail follows:
Richard Lynch wrote:
> There may also be some fancy new way to output the whole stack of
> functions called... I haven't really checked that out yet.
The function stack is printed by debug_backtrace(), isn't it? Supported
by PHP since 4.3.0.
Norbert
attached mail follows:
Eli schrieb:
> You're right that using eval() slows.. But using the _init() function
> as you suggested is actually tricking in a way you move the
> constructor params to another function, but the initialization params
> should be sent to the constructor!
>
> I guess that it would be better if PHP will add a possibility to
> construct a dynamic class with variant number of params... ;-)
>
If your read my original posting then you would know, that I expicitly
asked for a non-eval solution. Because we solved it with an eval too.
But I would like to watch for a solution without an eval.
thanks anyway
Thomas
attached mail follows:
Eli wrote:
> Jochem Maas wrote:
>
>> Eli wrote:
>>
>>> <?
>>> $obj_eval="return new $class(";
>>> for ($i=0; $i<count($args); $i++)
>>> $obj_eval.="\$args[$i],";
>>> $obj_eval=substr($obj_eval,0,-1).");";
>>> $obj=eval($obj_eval);
>>> ?>
>>
>>
>>
>> I believe that this is the kind of clever, evil stuff the OP was
>> trying to avoid...
>> (evil - eval :-) - besides eval is very slow - not something you (well
>> me then) want to
>> use in a function dedicated to object creation which is comparatively
>> slow anyway
>> (try comparing the speed of cloning and creating objects in php5 for
>> instance
>>
>> regardless - nice one for posting this Eli - I recommend anyone who
>> doesn't understand
>> what he wrote to go and figure it out, good learning material :-)
>>
>>>
> You're right that using eval() slows.. But using the _init() function as
> you suggested is actually tricking in a way you move the constructor
> params to another function, but the initialization params should be sent
> to the constructor!
true enough, thats why I suggested the OP might want to reevaluate the whole
idea ... personally I don't see much point in a create() function for new objects.
but anyway :-)
>
> I guess that it would be better if PHP will add a possibility to
> construct a dynamic class with variant number of params... ;-)
there is always runkit.
>
attached mail follows:
Thomas Angst wrote:
> Eli schrieb:
>
>> You're right that using eval() slows.. But using the _init() function
>> as you suggested is actually tricking in a way you move the
>> constructor params to another function, but the initialization params
>> should be sent to the constructor!
>>
>> I guess that it would be better if PHP will add a possibility to
>> construct a dynamic class with variant number of params... ;-)
>>
> If your read my original posting then you would know, that I expicitly
> asked for a non-eval solution. Because we solved it with an eval too.
> But I would like to watch for a solution without an eval.
sing it: "
you can't always get what you want,
you can'tr always get what ya need,
I can't get no ... satifaction.
"
>
> thanks anyway
> Thomas
>
attached mail follows:
TalkativeDoggy wrote:
> Hi all,
>
> I have heard that "function style is 400% faster than OOP in PHP", and
> give a little agreement. So in the past year, I write more PHP code in
> function way while less in OOP way.
>
> This morning, I read an article called "How efficient is OOP in PHP"
> according to the author's test, writing PHP code in procedural
> way(functions) is 200%+ faster than OOP way.
>
> But this article is written in 2003, now, I am using PHP5, how about the
> performance of OOP in PHP5? Could any one give me more efficient
> references?
objects are slower than functions.
functions are slower than straight up code.
OO in php5 is a lot better than in php4 also in terms of speed.
php5.1 brings a new execution model in the zend engine (IIRC),
regardless the change I refer to gives a not to small speed boost
for OO stuff.
bottom line - its fast enough, and if you need more speed maybe you
need to write a custom extension :-)
>
> Any suggestion or help will be greatly appreciated.
>
> Qin Jianxiang
>
attached mail follows:
Thanks for your help!
That is just what I wana hear.
Actually, in most web applications, the real bottle-neck of performance
is the Database, but not the PHP scripts-of coz, I don't take obvious
mistakes.
So I don't wana write my application without OOP or functions, just for
this bit performance improvement. I need a well maintianed product.
Jochem Maas wrote:
> TalkativeDoggy wrote:
>
>> Hi all,
>>
>> I have heard that "function style is 400% faster than OOP in PHP", and
>> give a little agreement. So in the past year, I write more PHP code in
>> function way while less in OOP way.
>>
>> This morning, I read an article called "How efficient is OOP in PHP"
>> according to the author's test, writing PHP code in procedural
>> way(functions) is 200%+ faster than OOP way.
>>
>> But this article is written in 2003, now, I am using PHP5, how about
>> the performance of OOP in PHP5? Could any one give me more efficient
>> references?
>
>
> objects are slower than functions.
> functions are slower than straight up code.
>
> OO in php5 is a lot better than in php4 also in terms of speed.
> php5.1 brings a new execution model in the zend engine (IIRC),
> regardless the change I refer to gives a not to small speed boost
> for OO stuff.
>
> bottom line - its fast enough, and if you need more speed maybe you
> need to write a custom extension :-)
>
>>
>> Any suggestion or help will be greatly appreciated.
>>
>> Qin Jianxiang
>>
attached mail follows:
TalkativeDoggy wrote:
> Thanks for your help!
>
> That is just what I wana hear.
>
> Actually, in most web applications, the real bottle-neck of performance
> is the Database, but not the PHP scripts-of coz, I don't take obvious
> mistakes.
>
> So I don't wana write my application without OOP or functions, just for
> this bit performance improvement. I need a well maintianed product.
my thought exactly - script speed is not that important;
maintainability, readability and extensibility are paramount unless you like
long hours and big headaches ;-)
> Jochem Maas wrote:
>
>> TalkativeDoggy wrote:
>>
>>> Hi all,
>>>
>>> I have heard that "function style is 400% faster than OOP in PHP",
>>> and give a little agreement. So in the past year, I write more PHP
>>> code in function way while less in OOP way.
>>>
>>> This morning, I read an article called "How efficient is OOP in PHP"
>>> according to the author's test, writing PHP code in procedural
>>> way(functions) is 200%+ faster than OOP way.
>>>
>>> But this article is written in 2003, now, I am using PHP5, how about
>>> the performance of OOP in PHP5? Could any one give me more efficient
>>> references?
>>
>>
>>
>> objects are slower than functions.
>> functions are slower than straight up code.
>>
>> OO in php5 is a lot better than in php4 also in terms of speed.
>> php5.1 brings a new execution model in the zend engine (IIRC),
>> regardless the change I refer to gives a not to small speed boost
>> for OO stuff.
>>
>> bottom line - its fast enough, and if you need more speed maybe you
>> need to write a custom extension :-)
>>
>>>
>>> Any suggestion or help will be greatly appreciated.
>>>
>>> Qin Jianxiang
>>>
>
attached mail follows:
I can't agree any more!
Maintainability is the most important, and if there is no readability or
extensibility, there is no maintainability.
So I recongnize what I should do now.
Jochem Maas wrote:
> TalkativeDoggy wrote:
>
>> Thanks for your help!
>>
>> That is just what I wana hear.
>>
>> Actually, in most web applications, the real bottle-neck of
>> performance is the Database, but not the PHP scripts-of coz, I don't
>> take obvious mistakes.
>>
>> So I don't wana write my application without OOP or functions, just
>> for this bit performance improvement. I need a well maintianed product.
>
>
> my thought exactly - script speed is not that important;
> maintainability, readability and extensibility are paramount unless you
> like
> long hours and big headaches ;-)
>
>> Jochem Maas wrote:
>>
>>> TalkativeDoggy wrote:
>>>
>>>> Hi all,
>>>>
>>>> I have heard that "function style is 400% faster than OOP in PHP",
>>>> and give a little agreement. So in the past year, I write more PHP
>>>> code in function way while less in OOP way.
>>>>
>>>> This morning, I read an article called "How efficient is OOP in PHP"
>>>> according to the author's test, writing PHP code in procedural
>>>> way(functions) is 200%+ faster than OOP way.
>>>>
>>>> But this article is written in 2003, now, I am using PHP5, how about
>>>> the performance of OOP in PHP5? Could any one give me more efficient
>>>> references?
>>>
>>>
>>>
>>>
>>> objects are slower than functions.
>>> functions are slower than straight up code.
>>>
>>> OO in php5 is a lot better than in php4 also in terms of speed.
>>> php5.1 brings a new execution model in the zend engine (IIRC),
>>> regardless the change I refer to gives a not to small speed boost
>>> for OO stuff.
>>>
>>> bottom line - its fast enough, and if you need more speed maybe you
>>> need to write a custom extension :-)
>>>
>>>>
>>>> Any suggestion or help will be greatly appreciated.
>>>>
>>>> Qin Jianxiang
>>>>
>>
attached mail follows:
Hi
I would like to convert from one naming convention within a sql statement to
another.
I have the following,
<code>
$str = "insert into userComment (userID, userName, userSurname) values (0,
'Leon', 'Vismer')";
$match = array(
"/([a-z]+)(ID)/",
"/([a-z]+)([A-Z])/"
);
$replace = array(
"\$1_id",
"\$1_\$2"
);
$nstr = preg_replace($match, $replace, $str);
echo $nstr ."\n";
</code>
the above gets me to
insert into user_Comment (user_id, user_Name, user_Surname) values (0, 'Leon',
'Vismer')
however I want to get to
insert into user_comment (user_id, user_name, user_surname) values (0, 'Leon',
'Vismer')
Some help from the regex experts ;-)
Many thanks
--
Leon
attached mail follows:
n Thu, 11 Aug 2005, Leon Vismer wrote:
> Hi
>
> I would like to convert from one naming convention within a sql statement to
> another.
>
> I have the following,
>
> <code>
> $str = "insert into userComment (userID, userName, userSurname) values (0,
> 'Leon', 'Vismer')";
>
> $match = array(
> "/([a-z]+)(ID)/",
> "/([a-z]+)([A-Z])/"
> );
>
> $replace = array(
> "\$1_id",
> "\$1_\$2"
> );
>
> $nstr = preg_replace($match, $replace, $str);
> echo $nstr ."\n";
> </code>
>
>
> the above gets me to
> insert into user_Comment (user_id, user_Name, user_Surname) values (0, 'Leon',
> 'Vismer')
>
> however I want to get to
>
> insert into user_comment (user_id, user_name, user_surname) values (0, 'Leon',
> 'Vismer')
>
> Some help from the regex experts ;-)
Just a quick note; why dont' you search on "user" since it's the constant and replace 'user[A-Z]' with 'user_[a-z]' or in the case of userID 'user[A-Z]{2}'
attached mail follows:
Hi
> Just a quick note; why dont' you search on "user" since it's the constant
> and replace 'user[A-Z]' with 'user_[a-z]' or in the case of userID
> 'user[A-Z]{2}'
This is part of my problem user will not always be constant, I basically want
to be able to change between two naming conventions.
Example:
userID becomes user_id
clientID becomes client_id
tableName becomes table_name
anotherTableName becomes another_table_name
etc.
Thanks
--
Leon
attached mail follows:
How about using the lower() function?
Leon Vismer wrote:
> Hi
>
> I would like to convert from one naming convention within a sql statement to
> another.
>
> I have the following,
>
> <code>
> $str = "insert into userComment (userID, userName, userSurname) values (0,
> 'Leon', 'Vismer')";
>
> $match = array(
> "/([a-z]+)(ID)/",
> "/([a-z]+)([A-Z])/"
> );
>
> $replace = array(
> "\$1_id",
> "\$1_\$2"
> );
>
> $nstr = preg_replace($match, $replace, $str);
> echo $nstr ."\n";
> </code>
>
> the above gets me to
> insert into user_Comment (user_id, user_Name, user_Surname) values (0, 'Leon',
> 'Vismer')
>
> however I want to get to
>
> insert into user_comment (user_id, user_name, user_surname) values (0, 'Leon',
> 'Vismer')
>
> Some help from the regex experts ;-)
>
> Many thanks
> --
> Leon
attached mail follows:
On 8/11/05, Leon Vismer <lvismer
tasmer.co.za> wrote:
> Hi
>
> I would like to convert from one naming convention within a sql statement to
> another.
>
> I have the following,
>
> <code>
> $str = "insert into userComment (userID, userName, userSurname) values (0,
> 'Leon', 'Vismer')";
>
> $match = array(
> "/([a-z]+)(ID)/",
> "/([a-z]+)([A-Z])/"
> );
>
> $replace = array(
> "\$1_id",
> "\$1_\$2"
> );
<?php
$str = "insert into userComment (userID, userName, userSurname) values
(0, 'Leon', 'Vismer')";
$match = '/(?<=[a-z])([A-Z]+)/e';
$replace = 'strtolower("_$1")';
print preg_replace($match, $replace, $str);
?>
insert into user_comment (user_id, user_name, user_surname) values (0,
'Leon', 'Vismer')
-robin
attached mail follows:
Hi Robin
Many thanks for this,
how would one extend this to support the following:
$str = "insert into userComment (userID, userName, userSurname) values (0,
'Leon', 'mcDonald')";
one does not want
$str = "insert into user_comment (user_id, user_name, user_surname) values (0,
'Leon', 'mc_donald')";
unfortunately lookbehind assertions does not support non-fixed length chars so
/(?<=(?<!')[a-z])([A-Z]+)/e will work for 'mDonald' but the following will not
work.
/(?<=(?<!')([a-z]+))([A-Z]+)/e
Any ideas?
Many thanks
--
Leon
> <?php
> $str = "insert into userComment (userID, userName, userSurname) values
> (0, 'Leon', 'Vismer')";
>
> $match = '/(?<=[a-z])([A-Z]+)/e';
> $replace = 'strtolower("_$1")';
> print preg_replace($match, $replace, $str);
> ?>
>
> insert into user_comment (user_id, user_name, user_surname) values (0,
> 'Leon', 'Vismer')
>
> -robin
attached mail follows:
Hi!
I have one checkbox. I checkbox is checked I show additional fields
(just set visiblity to true). But some of that fields are required only
if this checkbox is checked. Is this possible with quick_form. I try
myself with grouping but without any luck.
regards
Uros
attached mail follows:
I am assuming that this is after a post operation. If it's JavaScript, I
think the question should be directed to another list. So, if you group
the elements that should be validated after the checkbox has been
checked, you can activate/deactivate the group validation rules based on
the state of the checkbox. Makes sense?
Regards,
Torgny
Uroš Gruber wrote:
> Hi!
>
> I have one checkbox. I checkbox is checked I show additional fields
> (just set visiblity to true). But some of that fields are required
> only if this checkbox is checked. Is this possible with quick_form. I
> try myself with grouping but without any luck.
>
> regards
>
> Uros
>
attached mail follows:
Torgny Bjers said the following on 11.8.2005 14:44:
> I am assuming that this is after a post operation. If it's JavaScript, I
> think the question should be directed to another list. So, if you group
> the elements that should be validated after the checkbox has been
> checked, you can activate/deactivate the group validation rules based on
> the state of the checkbox. Makes sense?
If I understand your idea the code would look like this
$form->addElement('text', 'taxNumber', 'Tax:');
$checkbox = &HTML_QuickForm::createElement('checkbox', 'isCompany','');
if ($checkbox->getChecked()) {
$form->addRule('taxNumber','required','Tax number is required');
}
if ($form->validate()) {
....
Btw yes it must be checked when user submit this. But If it's possible
client option on rule, would be better.
regards
>>
>> I have one checkbox. I checkbox is checked I show additional fields
>> (just set visiblity to true). But some of that fields are required
>> only if this checkbox is checked. Is this possible with quick_form. I
>> try myself with grouping but without any luck.
attached mail follows:
Uroš Gruber wrote:
> Torgny Bjers said the following on 11.8.2005 14:44:
>
>> I am assuming that this is after a post operation. If it's JavaScript, I
>> think the question should be directed to another list. So, if you group
>> the elements that should be validated after the checkbox has been
>> checked, you can activate/deactivate the group validation rules based on
>> the state of the checkbox. Makes sense?
>
>
> If I understand your idea the code would look like this
> $form->addElement('text', 'taxNumber', 'Tax:');
> $checkbox = &HTML_QuickForm::createElement('checkbox', 'isCompany','');
>
> if ($checkbox->getChecked()) {
> $form->addRule('taxNumber','required','Tax number is required');
> }
>
> if ($form->validate()) {
> ....
That would be the idea, yes. It was some time since worked with
Quick_Form, so there might be a specific order you need to perform the
adding of the rule in relation to the validate() method call on the
$form object.
> Btw yes it must be checked when user submit this. But If it's possible
> client option on rule, would be better.
I am not sure about this, is there even client-side validation support
in Quick_Form? Haven't really looked into this. I would suggest writing
a manual javascript evaluation for the specific fields that should be
visible when the checkbox is checked, or to have a postback between. The
JavaScript option sounds most tempting, since it makes it a bit more
user-friendly. That way you can use the JavaScript alert() function to
present the fields that have erroneous information as well as altering
styles in the fields in question to perhaps have a red border to
indicate errors.
Regards,
Torgny
attached mail follows:
> Is there a way I can make these boxes and buttons
> retain their value?
Without a code example, I am forced to give a generic answer. Here's one
way to do it:
<?
$selection=5; // User previously picked option 5
$ddselection[$selection]=' selected ';
?>
<select name="D1">
<option<? echo $ddselection[1]; ?> value="1">Option 1</option>
<option<? echo $ddselection[2]; ?> value="2">Option 2</option>
<option<? echo $ddselection[3]; ?> value="3">Option 3</option>
<option<? echo $ddselection[4]; ?> value="4">Option 4</option>
<option<? echo $ddselection[5]; ?> value="5">Option 5</option>
<option<? echo $ddselection[6]; ?> value="6">Option 6</option>
<option<? echo $ddselection[7]; ?> value="7">Option 7</option>
<option<? echo $ddselection[8]; ?> value="8">Option 8</option>
</select>
JM
attached mail follows:
Ravi Gogna wrote:
[snip]
> I've managed to write the checking program in such a way that clicking
> submit launches an 'error' page which displays at the top of the page
> which field is wrong, and then redisplays the form. (The form
> redisplay is done using a function which uses the variables I used in
> the HTML form page). My problem is this: when the 'error' page comes
> up all of the text boxes will quite happily redisplay the data that
> was put into them, but I have a couple of drop-down boxes and radio
> buttons which lose their value. Is there a way I can make these boxes
> and buttons retain their value?
The easiest way to do this is to keep all the select option items in an
associative array and iterating this with foreach or for to output the
<option/> elements. That way you can directly check the value of each
option to detect which was selected.
MailerCode(tm):
<?php
$select = array('a' => 'Item 1', 'b' => 'Item 2', 'c' => 'Item 3');
?>
<form ...>
<select name="MySelect" id="MySelect">
<?php
foreach ($select as $value => $text) {
$selected = '';
if (!empty($_POST['MySelect']) && $_POST['MySelect'] == $value) {
$selected = ' selected';
}
printf('<option value="%s"%s>%s</option>%s', $value, $selected,
$text, "\r\n");
}
?>
</select>
</form>
Warm Regards,
Torgny
attached mail follows:
[snip]
Your HEREDOC appears to be messed up. On line 623 the closing identifier
is not in first column of the line (when I cut n paste the code into an
editor. That is a requirement for the heredoc.
You also didn't close the PHP block after END_FORM;
Then you need to open a PHP block at about line 635 before the if
statement.
[/snip]
Were you able to resolve this?
attached mail follows:
yea, I was able to get the form to display, thanks.
On 8/11/05, Jay Blanchard <jay.blanchard
niicommunications.com> wrote:
> [snip]
> Your HEREDOC appears to be messed up. On line 623 the closing identifier
> is not in first column of the line (when I cut n paste the code into an
> editor. That is a requirement for the heredoc.
>
> You also didn't close the PHP block after END_FORM;
> Then you need to open a PHP block at about line 635 before the if
> statement.
> [/snip]
>
> Were you able to resolve this?
>
--
::Bruce::
attached mail follows:
Jochem Maas wrote:
> John Nichel wrote:
>
>> Bruce Gilbert wrote:
>> <snip a ton of un-needed code>
>>
>> Your heredoc is messed up. Look into getting an editor which will
>> highlight the errors for you. This mailing list isn't here to syntax
>> check (unless it's 4:30 on a Friday).
>
>
> can we hold you to that John ;-)
I might pull time zone rules and say that your 4:30 is my 5:30, and that
I'm already home. ;)
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john
kegworks.com
attached mail follows:
[snip]
I might pull time zone rules and say that your 4:30 is my 5:30, and that
I'm already home. ;)
[/snip]
Another space-time continuum snafu brought to you by the Consortium For
Creative PHP Development
attached mail follows:
Jay Blanchard wrote:
> [snip]
> I might pull time zone rules and say that your 4:30 is my 5:30, and that
>
> I'm already home. ;)
> [/snip]
>
> Another space-time continuum snafu brought to you by the Consortium For
> Creative PHP Development
>
<picard>
Remember the Prime Directive, Number One.
</picard>
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john
kegworks.com
attached mail follows:
Hi.
I'd like to find or write a script that I can run every so often (hourly
for example) from cron that will check my pop3 mailboxes for any emails
with ****SPAM**** in the subject line and either delete them or forward
them to another email address. The best way would be to bundle all the
emails together and forward these as attachments to another email
address that I would use as spam.
I have found the documentation on using php for pop3 a little confusing
as it seems to be geared towards imap. I know it can be used for pop3
it's just the documentation on this seems to be a little scarce. Can
anyone help me find an already written script or give me some ideas on
how I can write my own.
Many thanks,
IG
attached mail follows:
[snip]
Assuming unix, I'd do the following from the root of the application to
get a list
of files that contain queries:
$ egrep "=[:space:]*\".*\b(SELECT|INSERT|UPDATE)\b" * -ril
...
Anyway, that's how I'd do it. Hope you got something out of this... :)
[/snip]
That is a good start, now all I need to do is get the whole query(s)
attached mail follows:
On 8/11/05, Jay Blanchard <jay.blanchard
niicommunications.com> wrote:
>
> That is a good start, now all I need to do is get the whole query(s)
Get them from the mysql logs?
-robin
attached mail follows:
[snip]
>
> That is a good start, now all I need to do is get the whole query(s)
Get them from the mysql logs?
[/snip]
While that sounds like a good idea there are two things that hamper the
effectiveness of this is a total solution;
1. The logs have many queries from other applications that *don't count*
in this scenario.
2. Not all of the queries may run frequently enough to appear in the
logs.
attached mail follows:
Jay Blanchard wrote:
> [snip]
> Assuming unix, I'd do the following from the root of the application
> to get a list
> of files that contain queries:
>
> $ egrep "=[:space:]*\".*\b(SELECT|INSERT|UPDATE)\b" * -ril
> ...
>
> Anyway, that's how I'd do it. Hope you got something out of this...
> :) [/snip]
>
> That is a good start, now all I need to do is get the whole query(s)
I guess I misunderstood your goal. You said before that you needed to LOCATE the
queries, which the above will do (if certain assumptions are true). What exactly
are you wanting to accomplish? Are you trying to write a script that will extract
the entire query from a set of PHP files?
If so, and given this:
$variableName = "INSERT INTO bar (foo) ";
$variableName .= "VALUES ('".$foo."') ";
Would you expect:
INSERT INTO bar (foo) VALUES ('')
or something else?
At any rate, if you are trying to automatically extract entire queries, I'd say
that's pretty tricky, unless your code uses very strict idioms for defining queries
that it doesn't stray from. For example, if the code always do this:
$query = "select .....";
$query .= "from .....";
$query .= "where ....";
That's one thing, but if it sometimes does this:
$query = "select ....".
"from .....".
"where .....";
Then that's something entirely different.
Assuming the first, you could perhaps use a two-pass approach where you first go
through a file and find the beginning of a query assignment (using a regex like the
one above), then extract the variable name and line number. Then on a second pass
start from each line number you saved and process line number + N lines (where N is
the largest number of lines the code normally takes to define a query, arbitrarily
chosen) and look for lines where the variable name is followed by an assignment
operator (= or .=). Then use a regex on those lines to extract everything between
quotes (hopefully just double quotes, unless the code tends to switch between double
and single). But then you run into problems when your N is too large and the end of
one chunk overlaps into the beginning of the next. I would imagine something like
this would take a lot of time to get right, and even then only be an 80% solution,
if that.
It seems to get this 100% right you'd have to have a full-fledged PHP parser, which
means hacking the parser that PHP itself uses. Even hacking the PHP parser probably
wouldn't get you a 100% solution because the compile stage won't be enough....there
is going to be code that may or may not be evaluated at runtime and I think it would
be impossible to know without actually running it.
So...if you absolutely have to have this done programmatically (as opposed to just
locating the beginning of the queries and manually extracting them) then I would say
good luck to you. :) Hopefully someone else has some ideas...
attached mail follows:
On 10 August 2005 22:19, Richard Lynch wrote:
> You can also, in some versions, "get away" with having \
> inside of "" so
> long as the following character isn't special:
> $string = "C:\homedirectory\uploadedfiles\\newfile.gif";
>
> Note that the 'n' character is special (newline) but 'h' and 'u' are
> not (I don't think) so this "should work"
>
> That doesn't make it Good Practice.
Especially as \u is likely to be a special sequence in the Unicode-enabled
PHP 6.0 when it comes out!
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford
leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
attached mail follows:
Could someone please share with me sample code for:
- Adding an XML node to an existing XML document.
- Modifying the value for a given XML node in an existing XML document.
Thank you.
--
Anas Mughal
attached mail follows:
[snip]
Could someone please share with me sample code for:
- Adding an XML node to an existing XML document.
- Modifying the value for a given XML node in an existing XML document.
[/snip]
Have you looked at the documentation?
http://www.php.net/xml
attached mail follows:
Jay Blanchard wrote:
> [snip]
> Could someone please share with me sample code for:
>
> - Adding an XML node to an existing XML document.
> - Modifying the value for a given XML node in an existing XML document.
> [/snip]
>
> Have you looked at the documentation?
hey Jay take it easy on the long words. ;-)
>
> http://www.php.net/xml
>
attached mail follows:
I have a field in my counter that collects IP addresses. Now the powers
that be want be to collect that data and sort it geographically etc.
Is there anyone who has done this? Where would I find some OS code? I've
heard of it done.
John
attached mail follows:
On 8/11/05, John Taylor-Johnston <taylorjo
collegesherbrooke.qc.ca> wrote:
> I have a field in my counter that collects IP addresses. Now the powers
> that be want be to collect that data and sort it geographically etc.
> Is there anyone who has done this? Where would I find some OS code? I've
> heard of it done.
http://sourceforge.net/projects/geoip/
--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/
attached mail follows:
On Thursday 11 August 2005 16:37, John Taylor-Johnston typed:
> I have a field in my counter that collects IP addresses. Now the powers
> that be want be to collect that data and sort it geographically etc.
> Is there anyone who has done this? Where would I find some OS code? I've
> heard of it done.
> John
maxmind.
attached mail follows:
On 8/11/05, Greg Donald <destiney
gmail.com> wrote:
> http://sourceforge.net/projects/geoip/
Actually, here's a better URL:
http://freshmeat.net/projects/geoip/
--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/
attached mail follows:
Hello John
http://www.ip-to-country.com/ provides a downloadable csv database
that should help you along your way.
HTH
On 8/11/05, John Taylor-Johnston <taylorjo
collegesherbrooke.qc.ca> wrote:
> I have a field in my counter that collects IP addresses. Now the powers
> that be want be to collect that data and sort it geographically etc.
> Is there anyone who has done this? Where would I find some OS code? I've
> heard of it done.
> John
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Is it a bug that ($var == 0) is always true for any string $var?
attached mail follows:
[snip]
Is it a bug that ($var == 0) is always true for any string $var?
[/snip]
You are comparing a string to an integer.
attached mail follows:
No, Christopher, that is not a bug. As long as the var is empty, and if
you try to compare with 0, or false, it will report true in the
comparison because the variable does not contain anything, which will
mean false for a boolean and 0 for a variable. If you are attempting to
discover if a string contains data, use empty() instead. You can also
check if the string is null or actual zero (0).
Regards,
Torgny
Christopher J. Bottaro wrote:
>Is it a bug that ($var == 0) is always true for any string $var?
>
attached mail follows:
> [snip]
> Is it a bug that ($var == 0) is always true for any string $var?
> [/snip]
>
> You are comparing a string to an integer.
Right. This is clearly documented at http://www.php.net/operators.comparison
attached mail follows:
Christopher J. Bottaro wrote:
> Is it a bug that ($var == 0) is always true for any string $var?
For any string? How about the string 5? :-)
PHP tries to help you out, but there's not much it can do when you ask
it to compare a string like 'foo' to an integer. It scans your string
from left to right and uses the leading numbers to create the integer.
For example, 53chris is 53, but chris53 is 0 (no leading numbers).
Hope that helps.
Chris
--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/
attached mail follows:
Torgny Bjers wrote:
> No, Christopher, that is not a bug. As long as the var is empty, and if
> you try to compare with 0, or false, it will report true in the
> comparison because the variable does not contain anything, which will
> mean false for a boolean and 0 for a variable. If you are attempting to
> discover if a string contains data, use empty() instead. You can also
> check if the string is null or actual zero (0).
But the var isn't empty.
$a[] = 'blah';
$a[] = 'blah';
$a['assoc'] = 'array';
foreach ($a as $k => $v)
if ($k == 'assoc')
# do something
The 'if' statement is incorrectly executing when $k is 0. I find it strange
that 0 == any string. The way I see it, 0 is false. false == 'a string'
should not be true.
Thanks for the reply,
-- C
> Regards,
> Torgny
>
> Christopher J. Bottaro wrote:
>
>>Is it a bug that ($var == 0) is always true for any string $var?
>>
>
attached mail follows:
Scott Noyes wrote:
>> [snip]
>> Is it a bug that ($var == 0) is always true for any string $var?
>> [/snip]
>>
>> You are comparing a string to an integer.
>
> Right. This is clearly documented at
> http://www.php.net/operators.comparison
>
Oh, I see...it converts the string into number, not the other way around.
Thanks for the link.
attached mail follows:
[snip]
But the var isn't empty.
$a[] = 'blah';
$a[] = 'blah';
$a['assoc'] = 'array';
foreach ($a as $k => $v)
if ($k == 'assoc')
# do something
The 'if' statement is incorrectly executing when $k is 0. I find it
strange
that 0 == any string. The way I see it, 0 is false. false == 'a
string'
should not be true.
[/snip]
I changed this sample to the following;
<?php
$a[] = 'blah';
$a[] = 'blah';
$a['assoc'] = 'array';
print_r($a);
foreach ($a as $k => $v){
if ($k == 'assoc'){
echo $v . "\n";
}
}
?>
Andf the output was;
Array
(
[0] => blah
[1] => blah
[assoc] => array
)
blah
array
Does it begin to make more sense now?
attached mail follows:
Hi,
> Is it a bug that ($var == 0) is always true for any string $var?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Check this out!
http://us3.php.net/manual/en/types.comparisons.php
attached mail follows:
>> No, Christopher, that is not a bug. As long as the var is empty, and if
>> you try to compare with 0, or false, it will report true in the
>> comparison because the variable does not contain anything, which will
>> mean false for a boolean and 0 for a variable. If you are attempting to
>> discover if a string contains data, use empty() instead. You can also
>> check if the string is null or actual zero (0).
>
> But the var isn't empty.
>
> $a[] = 'blah';
> $a[] = 'blah';
> $a['assoc'] = 'array';
> foreach ($a as $k => $v)
> if ($k == 'assoc')
> # do something
>
> The 'if' statement is incorrectly executing when $k is 0. I find it strange
> that 0 == any string. The way I see it, 0 is false. false == 'a string'
> should not be true.
>
You might try "===" instead of "==" to get type checking as well...
attached mail follows:
Thanks Ben!
John
Ben Ramsey wrote:
> In PHP, you could do something like:
>
> $updated = strtotime($db_result['updated']);
> $one_year_ago = strtotime('-1 year');
>
> if ($updated < $one_year_ago) {
> // updated date is older than a year ago
> }
>
>
> John Taylor-Johnston wrote:
>
>> I have a field 'updated' How can I tell if the date is older than 1
>> year ago (or should I think of 365 days)?
>>
>> `updated` date NOT NULL default '1999-12-12'
>>
>> I've looked at: http://ca3.php.net/manual/en/function.getdate.php
>>
>> Thanks,
>> John
>
>
>
--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."
' ' ' Collège de Sherbrooke:
ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/
- 819-569-2064
°v° Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures
/(_)\ Université de Sherbrooke
^ ^ http://compcanlit.ca/ T: 819.569.2064
attached mail follows:
Hello All,
What are best practices for deleting records in a DB. We need the
ability to restore the records.
Two obvious choices are:
1) Flag them deleted or undeleted
2) Move the deleted records to seperate table for deleted records.
We have a complex schema. However the the records that need to be
deleted and restored reside in 2 different tables (Table1 and Table2).
Table2 uses the primary key of the Table1 as the Foriegn key. The
Primary key for Table1 is auto-generated. This make the restoring with
the same primary key impossible, if we move deleted data to a
different table. However if we just flag the record as deleted the
restoring is quite easy.
Any thoughts/ideas ?
--
In Peace,
Saqib Ali
http://www.xml-dev.com/blog/
Consensus is good, but informed dictatorship is better.
attached mail follows:
Hi,
Can PHP connect to a remote Oracle db?
Because all oracle connecting functions only require 'user' and 'pass'
http://us3.php.net/manual/en/function.oci-connect.php
http://us3.php.net/manual/en/function.ora-plogon.php
Thanks,
Regards,
pancarne.
attached mail follows:
Yeah, you can connect to Oracle remotely. The standard PHP functions should do it probably, but I've done it using ADODB.
I don't know if this is the same on a *nix box, but I was running PHP on a Windows box and needed special Oracle stuff installed on my machine to connect to the Oracle DB. There's a file..something like "tsnames.ora" that has the database information. Sort of like their version of ODBC. You give it an aliased name, then give it all the server info, then when you connect to Oracle, you give it the name that's entered into "tsnames.ora" (or whatever the file is) and the username/password combo.
Maybe that'll give you a nudge in the right direction.
Good luck! Let us know what you find!
-TG
= = = Original message = = =
Hi,
Can PHP connect to a remote Oracle db?
Because all oracle connecting functions only require 'user' and 'pass'
http://us3.php.net/manual/en/function.oci-connect.php
http://us3.php.net/manual/en/function.ora-plogon.php
Thanks,
Regards,
pancarne.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
attached mail follows:
xfedex, yes you can connect to a remote Oracle DB, I'm doing for an app
I'm trying to write. You have to configure php with the oracle version
you have, more than likely with the --with-oci8=/u1/oracle/product/10g
line, of course your oracle location will differ.
I chose to use the PEAR::DB to do my oracle stuff instead of the oci calls.
This made it simple, and easy to read for me as I'm still learning.
The code looks cleaner also.
xfedex (xfedex
gmail.com) wrote:
>
> Hi,
>
> Can PHP connect to a remote Oracle db?
> Because all oracle connecting functions only require 'user' and 'pass'
>
> http://us3.php.net/manual/en/function.oci-connect.php
> http://us3.php.net/manual/en/function.ora-plogon.php
>
> Thanks,
> Regards,
> pancarne.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
"Computers are like air conditioners - they stop working properly when you
open Windows"
attached mail follows:
Hello!
I'm using PHP and Smarty to try to build an array of arrays using the
results from nested queries. I am just learning about nested arrays,
and I'm not sure what I'm doing wrong.
I am hoping someone can give me a hint as to what I am doing wrong. I
looked on php.net, but still couldn't figure it out.
If I remove the PHP foreach loop, it works fine, except, of course, no
sub projects show up. The error must be in there, but I'm just not
seeing it.
I get the following error with the code below:
Warning: Smarty error: unable to read resource: "welcome/Object.tpl" in
/usr/local/lib/php/Smarty/Smarty.class.php on line 1088
PHP STUFF
$query ="SELECT * FROM projects WHERE parent_project_id is NULL OR
parent_project_id = ''";
$projects = $db->getAssoc($query, DB_FETCHMODE_ASSOC);
foreach ($projects as $key => $project) {
$query ="SELECT * FROM projects WHERE parent_project_id =
$projects[$key]['project_id']";
$sub = $db->getAssoc($query, DB_FETCHMODE_ASSOC);
$projects[$key]['subs'] = $sub;
}
$tpl->assign('projects', $projects);
SMARTY STUFF
{foreach from=$projects item='entry'}
<b>{$entry.short_name}</b><br />
<ul>
{foreach from=$entry.subs item='sub'}
<li>{$sub.short_name}</li>
{foreachelse}
<li>No subs for this project</li>
{/foreach}
</ul>
{foreachelse}
<b>No projects found</b>
{/foreach}
Can anyone point me in the right direction?
Thanks,
Amanda
attached mail follows:
Hi,
Have someone make PHP to authenticate against AD?
Any comment, suggestion will be greatly appreciated.
Thanks,
pancarne.
attached mail follows:
[snip]
Have someone make PHP to authenticate against AD?
Any comment, suggestion will be greatly appreciated.
[/snip]
Are you, at all, familiar with TFM?
http://www.php.net/ldap
attached mail follows:
Here is a php class for Active Directory:
http://adldap.sourceforge.net/
Nate Tobik
(412)661-5700 x206
VigilantMinds
-----Original Message-----
From: xfedex [mailto:xfedex
gmail.com]
Sent: Thursday, August 11, 2005 2:41 PM
To: php-general
lists.php.net
Subject: [PHP] PHP and Active Directory
Hi,
Have someone make PHP to authenticate against AD?
Any comment, suggestion will be greatly appreciated.
Thanks,
pancarne.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
> [snip]
> Have someone make PHP to authenticate against AD?
> Any comment, suggestion will be greatly appreciated.
> [/snip]
>
> Are you, at all, familiar with TFM?
>
TFM?.....mmmmm no, can you tell me where to start?
attached mail follows:
Hi,
I would like to give my users the possibility to authenticate through a
private certificate to confirm their identity. I'm not really sure where
to start.
Has anyone seen a website explaining this? Some pointers would be very
welcome.
Thanks!
Evert
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]