|
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 12 Jun 2006 02:29:43 -0000 Issue 4180
php-general-digest-help
lists.php.net
Date: Sun Jun 11 2006 - 21:29:43 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 12 Jun 2006 02:29:43 -0000 Issue 4180
Topics (messages 237759 through 237775):
Re: Simultaneous post/get?
237759 by: Stut
237761 by: tedd
237762 by: Stut
237764 by: tedd
237765 by: Stut
237766 by: tedd
237771 by: Lowell Allen
limiting downloads
237760 by: Michelle Konzack
237763 by: tedd
Re: remove keys from array
237767 by: Rabin Vincent
237772 by: Afan Pasalic
MySpace stuff?
237768 by: Brian Dunning
237774 by: Thorsten Suckow-Homberg
Re: How to re-order an array
237769 by: Rafael
Re: parsing out quoted text
237770 by: Stian Berger
Re: transform RDF to HTML via XSL and PHP
237773 by: Anthony Ettinger
Re: mail() function dying half way through. [SOLVED]
237775 by: Dave M G
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:
tedd wrote:
> I am trying to use ajax to accomplish this.
>
> The following statement works great and does what I want:
>
> <input type="submit" value="Submit" onClick="javascript:sndReq()" >
>
> However, when I place the statement within a form, like thus --
>
> <form method="post" enctype="multipart/form-data"> <input
> type="hidden" name="MAX_FILE_SIZE" value="30000"> <input
> type="hidden" name="stage" value="1"> <input type="submit"
> value="Submit" onClick="javascript:sndReq()" > </form>
>
> -- the statement appears to no longer work.
The form is being submitted to the current URL which will stop any
javascript executing at the time. What you need to do is prevent the
form from being submitted, or control when it is submitted. Instead of
using the onclick attribute on the button you should be using the
onsubmit attribute in the form tag to control this. Fairly good
explanation of this here:
http://www.htmlcodetutorial.com/forms/_FORM_onSubmit.html
-Stut
attached mail follows:
At 3:21 PM +0100 6/11/06, Stut wrote:
>tedd wrote:
>>I am trying to use ajax to accomplish this.
>>
>>The following statement works great and does what I want:
>>
>><input type="submit" value="Submit" onClick="javascript:sndReq()" >
>>
>>However, when I place the statement within a form, like thus --
>>
>><form method="post" enctype="multipart/form-data"> <input
>>type="hidden" name="MAX_FILE_SIZE" value="30000"> <input
>>type="hidden" name="stage" value="1"> <input type="submit"
>>value="Submit" onClick="javascript:sndReq()" > </form>
>>
>>-- the statement appears to no longer work.
>
>The form is being submitted to the current URL which will stop any javascript executing at the time. What you need to do is prevent the form from being submitted, or control when it is submitted. Instead of using the onclick attribute on the button you should be using the onsubmit attribute in the form tag to control this. Fairly good explanation of this here:
>
> http://www.htmlcodetutorial.com/forms/_FORM_onSubmit.html
>
>-Stut
-Stut:
Great suggestion, but I think an "upload file" a different critter.
http://www.htmlcodetutorial.com/forms/_INPUT_TYPE_FILE.html
For example, I took my above code and changed it like so --
<form method="post" enctype="multipart/form-data" onSubmit="javascript:sndReq()">
<input type="file" name="image" value="30000">
<input type="hidden" name="stage" value="1">
<input type="submit" value="submit">
</form>
-- and the result was the same. The file uploaded, but nothing happened.
I also took the code you referenced, exactly "as-was" and I changed the <FORM statement to --
<form method="post" enctype="multipart/form-data" onSubmit="return TestDataCheck()">
-- and it didn't work the way one would expect either.
Apparently, the "built-in" upload-file thing has it's own way of processing events. What do you think?
Thanks for your time.
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
tedd wrote:
> At 3:21 PM +0100 6/11/06, Stut wrote:
>> The form is being submitted to the current URL which will stop any
>> javascript executing at the time. What you need to do is prevent
>> the form from being submitted, or control when it is submitted.
>> Instead of using the onclick attribute on the button you should be
>> using the onsubmit attribute in the form tag to control this.
>> Fairly good explanation of this here:
>>
>> http://www.htmlcodetutorial.com/forms/_FORM_onSubmit.html
>>
>> -Stut
>
> -Stut:
>
> Great suggestion, but I think an "upload file" a different critter.
>
> http://www.htmlcodetutorial.com/forms/_INPUT_TYPE_FILE.html
>
> For example, I took my above code and changed it like so --
>
> <form method="post" enctype="multipart/form-data"
> onSubmit="javascript:sndReq()"> <input type="file" name="image"
> value="30000"> <input type="hidden" name="stage" value="1"> <input
> type="submit" value="submit"> </form>
>
> -- and the result was the same. The file uploaded, but nothing
> happened.
>
> I also took the code you referenced, exactly "as-was" and I changed
> the <FORM statement to --
>
> <form method="post" enctype="multipart/form-data" onSubmit="return
> TestDataCheck()">
>
> -- and it didn't work the way one would expect either.
>
> Apparently, the "built-in" upload-file thing has it's own way of
> processing events. What do you think?
Maybe I'm not understanding what you're trying to do. I think you're
trying to show an animated GIF before starting the file upload. Is that
right? If it is, this is what you need to do...
The form, with onsubmit="return sndReq()". sndReq does the AJAX image
thing (although I don't know why you're using AJAX here, but it doesn't
matter). sndReq *must* return false!!
When the AJAX request completes the response presumably gets handled by
another JS function. That function does whatever it needs to with the
AJAX response, and then submits the form. I'm not sure if
programmatically submitting a form calls the onsubmit handler, you'll
have to check that. If it does just make sure sndReq does nothing on the
second call except return true - that will tell the form it's ok to do
the submit.
Another way you might want to consider for this is to use an iframe. Set
the target of the form to an iframe, that way the JS running in the main
page will not get stopped.
Hope that helps.
-Stut
attached mail follows:
At 4:35 PM +0100 6/11/06, Stut wrote:
-snip-
>Maybe I'm not understanding what you're trying to do. I think you're trying to show an animated GIF before starting the file upload. Is that right? If it is, this is what you need to do...
That's exactly what I'm trying to do.
>The form, with onsubmit="return sndReq()". sndReq does the AJAX image thing (although I don't know why you're using AJAX here,
I'm using ajax because it's a method to inject an image in a DOM div without having to reload the current page.
My method is pretty straightforward.
1. Present the user with a page that has the typical "Choose File" and "Submit" button for uploading an image file.
2. After the user selects the file he/she wants to upload, they then click "Submit" and the file uploads (a wait) and then they go to the next step on another page.
All I want to do is present an image during the "wait".
Is there an easier way to do this?
I'll investigate your suggestion to look into iframes.
Thanks.
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
tedd wrote:
> At 4:35 PM +0100 6/11/06, Stut wrote:
>> The form, with onsubmit="return sndReq()". sndReq does the AJAX
>> image thing (although I don't know why you're using AJAX here,
>
> I'm using ajax because it's a method to inject an image in a DOM div
> without having to reload the current page.
>
> All I want to do is present an image during the "wait".
>
> Is there an easier way to do this?
There is no need to hit the server for this. Simply include "display:
none;" in the style for either the img tag or the div containing it so
it's not shown when the page initially loads. In the onsubmit for the
form change that display to 'block' to show the image. This also avoids
the need to postpone posting the form since the image has already loaded.
Image...
<img id="waitimg" src="/whatever.gif" style="display: none;" />
Form...
<form ... onsubmit="document.getElementById('waitimg').style.display =
'block'; return true;">
> I'll investigate your suggestion to look into iframes.
Ignore that. An iframe is not the best way to solve this.
-Stut
attached mail follows:
At 5:46 PM +0100 6/11/06, Stut wrote:
>tedd wrote:
>>At 4:35 PM +0100 6/11/06, Stut wrote:
>>>The form, with onsubmit="return sndReq()". sndReq does the AJAX image thing (although I don't know why you're using AJAX here,
>>
>>I'm using ajax because it's a method to inject an image in a DOM div without having to reload the current page.
>>
>>All I want to do is present an image during the "wait".
>>
>>Is there an easier way to do this?
>
>There is no need to hit the server for this. Simply include "display:
>none;" in the style for either the img tag or the div containing it so
>it's not shown when the page initially loads. In the onsubmit for the
>form change that display to 'block' to show the image. This also avoids
>the need to postpone posting the form since the image has already loaded.
>
>Image...
>
><img id="waitimg" src="/whatever.gif" style="display: none;" />
>
>Form...
>
><form ... onsubmit="document.getElementById('waitimg').style.display =
>'block'; return true;">
Bingo!
That works slick ! While I *think* I know css, it would have taken me a long while before I would have turned to css to solve this.
Your solution works much better than the convoluted code I was writing. It's clear that I need to understand js better.
Thanks much Stut.
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
On Jun 11, 2006, at 2:02 PM, tedd wrote:
> At 5:46 PM +0100 6/11/06, Stut wrote:
>> tedd wrote:
>>> At 4:35 PM +0100 6/11/06, Stut wrote:
>>>> The form, with onsubmit="return sndReq()". sndReq does the AJAX
>>>> image thing (although I don't know why you're using AJAX here,
>>>
>>> I'm using ajax because it's a method to inject an image in a DOM div
>>> without having to reload the current page.
>>>
>>> All I want to do is present an image during the "wait".
>>>
>>> Is there an easier way to do this?
>>
>> There is no need to hit the server for this. Simply include "display:
>> none;" in the style for either the img tag or the div containing it so
>> it's not shown when the page initially loads. In the onsubmit for the
>> form change that display to 'block' to show the image. This also
>> avoids
>> the need to postpone posting the form since the image has already
>> loaded.
>>
>> Image...
>>
>> <img id="waitimg" src="/whatever.gif" style="display: none;" />
>>
>> Form...
>>
>> <form ... onsubmit="document.getElementById('waitimg').style.display =
>> 'block'; return true;">
>
> Bingo!
>
> That works slick ! While I *think* I know css, it would have taken me
> a long while before I would have turned to css to solve this.
I recall trying this (exactly this I think) a couple months ago and
finding that it works in most browsers, but not in Windows IE6 (of
course). Is it working in Windows IE6 for you?
I got a working upload progress bar by using Uber Uploader
<http://sourceforge.net/projects/uber-uploader>.
--
Lowell Allen
attached mail follows:
Hello *,
I am on over 100 Mailinglists and want to make my archive (monthly
tarbals) public availlable. my problem is, that they are around
20 GByte compressed archives and I want to prevent peoples to suck
the whole archive at once...
I was trying several things but failed.
Does anyone have a code sniplet which limit clients to, e.g. four
downloads, per day?
I think, I must use a database or something like this, because I
must track th IP, date, time, and the used download client...
I think, downloads limiting by creating accounts with passwords
will not help since spamer can create Yahoo or Hotmail accounts
faster than you can stop it...
Or should I pass the downloads via this nifty PIC/IMAGE verification,
where $USER must type in the numbers/letters created by a php script?
Greetings
Michelle Konzack
--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
attached mail follows:
At 1:51 PM +0200 6/10/06, Michelle Konzack wrote:
>Hello *,
>
>I am on over 100 Mailinglists and want to make my archive (monthly
>tarbals) public availlable. my problem is, that they are around
>20 GByte compressed archives and I want to prevent peoples to suck
>the whole archive at once...
>
>I was trying several things but failed.
>
>Does anyone have a code sniplet which limit clients to, e.g. four
>downloads, per day?
>
>I think, I must use a database or something like this, because I
>must track th IP, date, time, and the used download client...
>
>I think, downloads limiting by creating accounts with passwords
>will not help since spamer can create Yahoo or Hotmail accounts
>faster than you can stop it...
>
>Or should I pass the downloads via this nifty PIC/IMAGE verification,
>where $USER must type in the numbers/letters created by a php script?
>
>Greetings
> Michelle Konzack
Michelle:
If it was my problem, I would have people register and store their registration (logon and password) in a dB and require them to accept cookies. I think that would both slow-down and limit downloads.
As for PIC/IMAGE thing it's called CAPTCHLA and that would help keep out spammers, but you would cut out the visually impaired. You might want to read this:
http://www.access-matters.com/2005/05/22/quiz-115-did-a-captcha-catch-ya/
hth's
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
On 6/11/06, Ahmed Abdel-Aliem <me2resh
gmail.com> wrote:
> when i have array in the form of :
> Array ( [0] => 2 [ID] => 2 [1] => asdasd [CategoryName] => asdasd ) )
> how can i make it in the form of :
> Array ( [ID] => 2 [CategoryName] => asdasd ) )
To remove a single element you can use unset: unset($arr[0]);. To
remove all the elements with integer indices you could just loop, check,
and unset those ones.
What do you need to do this for? Your examples looks like arrays got
from mysql_fetch_array. If this is so, using mysql_fetch_assoc() instead
of that will get you only the associative array.
Rabin
attached mail follows:
if you pull this array from mysql use this:
$query = mysql_query("SELECT * FROM table");
$result = mysql_fetch_array($query, MYSQL_ASSOC);
-afan
Rabin Vincent wrote:
> On 6/11/06, Ahmed Abdel-Aliem <me2resh
gmail.com> wrote:
>> when i have array in the form of :
>> Array ( [0] => 2 [ID] => 2 [1] => asdasd [CategoryName] => asdasd ) )
>> how can i make it in the form of :
>> Array ( [ID] => 2 [CategoryName] => asdasd ) )
>
> To remove a single element you can use unset: unset($arr[0]);. To
> remove all the elements with integer indices you could just loop, check,
> and unset those ones.
>
> What do you need to do this for? Your examples looks like arrays got
> from mysql_fetch_array. If this is so, using mysql_fetch_assoc() instead
> of that will get you only the associative array.
>
> Rabin
>
attached mail follows:
Has anyone made some classes for automating MySpace activities: a
friend adder, comment poster, etc.? Thanks...
attached mail follows:
> Has anyone made some classes for automating MySpace activities: a
> friend adder, comment poster, etc.? Thanks...
>
http://blog.phpdoc.info/archives/39-MySpace-Welcome-to-Web-0.5-and-a-Y!Maps-toy.html
I don't know if it will help you, but it is worth the read :D
attached mail follows:
jekillen wrote:
[···]
> You misunderstand my question. I know the limitations of javascript. The
> server won't respond to events registered in the browser. I write tons
> of forms that are all processed
> by the client with javascript. I have written ferocious regex filters
> that hack apart form submissions before they even leave the client. I
> have set it up so if the client doesn't
> have javascript enabled, the form won't submit if it is going to the
> server. That is why as much as possible I shift form processing to the
> client as much as possible, for
> security and to off load work to the client. I use php to dynamically
> write js files when necessary, anticipating what data will be requested.
I didn't (misunderstood), what I told you is that you cannot rely on
javascript (actually, that would be "anything coming from the client")
You need to do validate on the server, and it doesn't matter if you
already did it on the client or not (simply because you cannot know that
for sure)
> This is a problem that is more a matter of programming theory. I have
> posted to javascript forums and lists and have never got a response.
> I will be applying this to dhtml which the server won't and can't do but
> may help things along with Ajax.
> Just a simple suggestion about how to reorder arrays if you have a few
> words and suggestions. I'm not looking for free training.
> I have been learning and using php and javascript for some five years
> and have developed my own approach to testing and debugging
> and such. So I am not really a newby. I have made the dumb mistakes of
> asking for help from forums and lists when it was just a dumb
> syntax error that I couldn't expect anyone but my self to find, which i
> have in 99.9% of the cases. Some times it is nice to get some
> quick help from a list and I will try to return the favor when ever
> possible to the next person looking for help that I have some answers for.
Well, I asked you for the actual (JS) code you're using (the one that
didn't work in all the intended browsers), that way someone might be
able to help you (I will if I can)
--
Atentamente / Sincerely,
J. Rafael Salazar Magaņa
attached mail follows:
On Fri, 09 Jun 2006 14:53:09 +0200, sam <php
itab.com> wrote:
>
> $str='bass "electric organ" bagpipes';
>
> $parser($str);
>
> $query="SELECT * FROM table WHERE tb_instr = "bass"
> > AND tb_instr = "electric organ" //<<quoted phrase
> > AND tb_instr = "bagpipes";
>
>
> Anybody know where I can just copy code that will do the above?
>
> thanks
I once for just the fun of it, made a regular expression to solve
this kind of problem. I haven't tried it in production enviroment,
but only on some basic examples. It should support both single and
double quotes.
$str = 'bass "electric organ" bagpipes';
preg_match_all("/(?<=('|\"))[^\\1]+(?=\\1)|[^ \"']+/",$str,$match);
/*
$match[0] Array
(
[0] => bass
[1] => electric organ
[2] => bagpipes
)
*/
foreach($match[0] as $key => $value) {
$match[0][$key] = 'tb_instr = "'.mysql_escape_string($value).'"';
}
$sql = "SELECT * FROM table WHERE ".implode(' AND ',$match[0]);
print($sql);
//SELECT * FROM table WHERE tb_instr = "bass" AND
//tb_instr = "electric organ" AND tb_instr = "bagpipes"
attached mail follows:
<xsl:template match="rdf:RDF">
<html>
<body>
<table border="1">
<xsl:for-each select="item">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="link"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I'ts been awhile, but try the above.
--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html
attached mail follows:
Chris, Richard,
Thank you for your advice.
Inserting "sleep(1)" into the script seems to have done the trick.
I will also look into the other alternatives you suggest, such as
different mail programs and the error output of mail() to see if I can
optimize the system further.
Thank you for taking the time to help.
--
Dave M G
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]