php-general Digest 29 May 2006 23:08:43 -0000 Issue 4155
Topics (messages 237021 through 237047):
Re: MMS Gateway + PHP
237021 by: Rabin Vincent
237022 by: Jochem Maas
Re: Best way to save reports, comments and suggestions welcome
237023 by: Ryan A
237025 by: Robert Cummings
237026 by: Ryan A
Re: [NOT PHP] good javascript list?
237024 by: João Cândido de Souza Neto
Re: problems with regex
237027 by: Adam Zey
pager problem again
237028 by: Ross
pop-up window in php???
237029 by: siavash1979.telus.net
237030 by: Adam Zey
237031 by: Andrei
237033 by: siavash1979.telus.net
237034 by: Adam Zey
237035 by: Lester Caine
237036 by: siavash1979.telus.net
237039 by: Paul Novitski
Metric Conversion Library
237032 by: Tod Thomas
Better method than stristr
237037 by: Steven Osborn
237038 by: Jochem Maas
237044 by: Adam Zey
237045 by: Adam Zey
237047 by: Robert Cummings
Re: Generating thumbnails from tiff images
237040 by: mbneto
number_format
237041 by: João Cândido de Souza Neto
Code check
237042 by: Paul Goepfert
237043 by: D. Dante Lorenso
Blacklisted using mail()
237046 by: Peter Lauri
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 ---
On 5/29/06, kartikay malhotra <[EMAIL PROTECTED]> wrote:
I've a typical problem. I'm using Mbuni MMS gateway. This gateaway provides
a method of forwarding an incoming MMS file to a HTTP Server, where it could
be uploaded.
I run a PHP script on the server, to dump the MMS into a database.
Now I do not have a typical HTML form to upload the MMS. Only 2 fields in
the configuration file :
post-url = http://localhost/one.php/
http-post-parameters = userfile=%z
where %z signifies all parts of the MM.
I'm used to seeing PHP code for uploading files which resembles:
if($_FILES['userfile']['size'] > 0 )
{
$fileName = $_FILES['userfile']['name'];
}
Unfortunately, the condition $_FILES['userfile']['size'] is never satisfied.
Can anyone help me determine that my file is properly reaching the HTTP
server in the first place?
Try var_dump()ing $_POST and $_FILES and see what you get.
Rabin
--- End Message ---
--- Begin Message ---
kartikay malhotra wrote:
Hi All,
I've a typical problem. I'm using Mbuni MMS gateway. This gateaway provides
a method of forwarding an incoming MMS file to a HTTP Server, where it
could
be uploaded.
I run a PHP script on the server, to dump the MMS into a database.
Now I do not have a typical HTML form to upload the MMS. Only 2 fields in
the configuration file :
post-url = http://localhost/one.php/
http-post-parameters = userfile=%z
where %z signifies all parts of the MM.
I'm used to seeing PHP code for uploading files which resembles:
if($_FILES['userfile']['size'] > 0 )
{
$fileName = $_FILES['userfile']['name'];
}
Unfortunately, the condition $_FILES['userfile']['size'] is never
satisfied.
Can anyone help me determine that my file is properly reaching the HTTP
server in the first place?
If the problem statement isn't clear, all fault is mine :)
its not clear to me - but I'll take a guess and say that the relevant
content encoding headers were not set therefore php doesn't not recognise
the incoming post as a file upload.
// generating the relevant header via php
header('Content-Type: multipart/form-data')
// or specifying the enctype in a form tag declaraction:
<form action="" method="post" enctype="multipart/form-data">
it maybe that the header is not named 'Content-Type' - I was just guessing.
Thanx
KM
--- End Message ---
--- Begin Message ---
Hey Robert,
> > I have to write a kind of logging script which
> will keep records of how long a person used the site
> and its functions, so far this is what I have come
up
> > with:
...
> Presuming you know when they logged out or can
> calculate it:
>
> user_id
> login_time timestamp
> logout_time timestamp
> Your username values are probably nice and unique
> but a great big waste
> of space as a criteria by which to relate data. You
> should associate a
> unique integer value for each username.
Theres an idea I didnt think about, thanks!
> Regardless of how you determine the end of the
> logged in time, you
> shouldn't track all the different sums in every
> entry since that's
> redundant. You don't even need the extra data since
> the database will
> happily allow you to perform the SUMs via queries.
I have done very little SUM queries with time, can you
give me a quick example or any site where i can find a
few sample queries?
Thanks!
Ryan
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
On Mon, 2006-05-29 at 08:55, Ryan A wrote:
> > Regardless of how you determine the end of the
> > logged in time, you
> > shouldn't track all the different sums in every
> > entry since that's
> > redundant. You don't even need the extra data since
> > the database will
> > happily allow you to perform the SUMs via queries.
>
> I have done very little SUM queries with time, can you
> give me a quick example or any site where i can find a
> few sample queries?
This is basic MySQL so you should RTFM, and generally should be asking
on a MySQL list :)
SELECT SUM( UNIX_TIMESTAMP( logout_time ) - UNIX_TIMESTAMP( login_time )
) AS seconds FROM some_table WHERE user_id = 1;
If you have MySQL >= 4.1.1 then you should probably use the TIMEDIFF()
function.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Hey Rob,
> > I have done very little SUM queries with time, can
> you
> > give me a quick example or any site where i can
> find a
> > few sample queries?
>
> This is basic MySQL so you should RTFM, and
> generally should be asking
> on a MySQL list :)
Hehehe, true...
Dont really like the MySql manual...its so much more
complicated compared to the php manual. And dont
really fancy joining a high traffic list like the
mysql one just for a simple q like the above when
there are so many experts here like you who take a
moment to help guys like me out. I usually dont ask
such basic q's anyway, although I admit the defination
of a "basic q" is very different to many ppl here...
> SELECT SUM( UNIX_TIMESTAMP( logout_time ) -
> UNIX_TIMESTAMP( login_time )
> ) AS seconds FROM some_table WHERE user_id = 1;
>
> If you have MySQL >= 4.1.1 then you should probably
> use the TIMEDIFF()
> function.
Got it, Thanks!
Ryan
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
Hi Paul.
I subscribe myself in this javascript list but i cant´t access the list by
Outlook Express. Could you told me wath can i do?
Thanks.
"Paul Novitski" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
> At 11:37 AM 5/27/2006, tedd wrote:
>>I'm looking for a recommendation for a good javascript list like this list
>>is for php -- does anyone have any recommendations?
>
>
> I've been on the LA Tech javascript list the last few years and find the
> quality of discussion usually high (and with much less irrelevant noise
> than, say, this list suffers):
>
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
> Paul
--- End Message ---
--- Begin Message ---
Merlin wrote:
thank you, that worked excellent!
Merlin
Dave Goodchild schrieb:
On 27/05/06, Merlin <[EMAIL PROTECTED]> wrote:
Hi there,
I am somehow lost when it comes to regex. I am trying to remove ! and ?
characters from a string. Could somebody please help me to get a working
regex running for that?
I tried: $str = preg_replace('/\!\?\./', ' ', $str);
How about $str = preg_replace('/(\!|\?)+/', $str);
**NEVER** use regular expressions for simple search/replace
operations!!! They are MUCH slower than a simple string replace, and
should be avoided if at all possible. What you are doing is a very
simple string replace, and you should not use regular expressions for that.
I am assuming you want to remove the ! and ? and not replace them with a
space. In this case:
$str = str_replace(array("!". "?"), "", $str);
Or if you did want to replace them with a space:
$str = str_replace(array("!". "?"), " ", $str);
This is especially important if you're doing the string replace in a
loop, but even if you aren't, it is very bad style to use regular
expressions for such a simple replacement.
Regards, Adam Zey.
--- End Message ---
--- Begin Message ---
http://scottishsocialnetworks.org/editor.phps
http://scottishsocialnetworks.org/editor.php
I am using this pager class and I cannot seem to get the syntax right for
adding the search string, area and service types to the url.
http://www.firepages.com.au/php_pagination_class.htm
Here is the full query...
SELECT * from contacts WHERE sname LIKE \'%%\' AND area LIKE \'%%\'AND
p_service LIKE \'%%\' AND s_service LIKE \'%%\' AND t_service LIKE \'%%\'
ORDER BY sname LIMIT 0 , 10
The search is a combination of surname, area and the three services it was
suggested something like this would work
echo $pager->get_prev('<a href="{LINK_HREF}&area='$area '&sname='$sname"
etc.
but I cannot get the syntax right and because the values are not 'resent' to
browser the paged va;ue on pages 2, 3 4 etc are lost.
R.
--- End Message ---
--- Begin Message ---
Hi all,
Is there anyway to have a pop-up window to ask "are you sure? yes / no" in php?
I know you can do it in Javascript, but I'm not sure what's the best way to
implement it in php. I want the page to do nothing if "no" is pressed.
any help would be appreciated.
thanks,
Siavash
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
Hi all,
Is there anyway to have a pop-up window to ask "are you sure? yes / no" in php?
I know you can do it in Javascript, but I'm not sure what's the best way to
implement it in php. I want the page to do nothing if "no" is pressed.
any help would be appreciated.
thanks,
Siavash
This has nothing to do with PHP, this is a javascript matter. You PHP
script merely prints out the javascript code.
Regards, Adam Zey.
--- End Message ---
--- Begin Message ---
Not related to PHP, but u hava javascript confirm function or prompt
(if you need input also).
Andy
[EMAIL PROTECTED] wrote:
Hi all,
Is there anyway to have a pop-up window to ask "are you sure? yes / no" in php?
I know you can do it in Javascript, but I'm not sure what's the best way to
implement it in php. I want the page to do nothing if "no" is pressed.
any help would be appreciated.
thanks,
Siavash
--- End Message ---
--- Begin Message ---
ok, maybe I didn't make my question too clear. I was mostly wondering if there
is a way to do it in PHP rather than Javascript. I would prefer only using php.
and from the answers I got, I take it that there is no way of doing it in PHP.
thanks,
Siavash
Quoting Andrei <[EMAIL PROTECTED]>:
>
> Not related to PHP, but u hava javascript confirm function or prompt
> (if you need input also).
>
> Andy
>
> [EMAIL PROTECTED] wrote:
> > Hi all,
> >
> > Is there anyway to have a pop-up window to ask "are you sure? yes / no" in
> php?
> > I know you can do it in Javascript, but I'm not sure what's the best way
> to
> > implement it in php. I want the page to do nothing if "no" is pressed.
> >
> > any help would be appreciated.
> >
> > thanks,
> > Siavash
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
ok, maybe I didn't make my question too clear. I was mostly wondering if there
is a way to do it in PHP rather than Javascript. I would prefer only using php.
and from the answers I got, I take it that there is no way of doing it in PHP.
thanks,
Siavash
Quoting Andrei <[EMAIL PROTECTED]>:
Not related to PHP, but u hava javascript confirm function or prompt
(if you need input also).
Andy
[EMAIL PROTECTED] wrote:
Hi all,
Is there anyway to have a pop-up window to ask "are you sure? yes / no" in
php?
I know you can do it in Javascript, but I'm not sure what's the best way
to
implement it in php. I want the page to do nothing if "no" is pressed.
any help would be appreciated.
thanks,
Siavash
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
PHP is a server-side language. It cannot directly influence anything on
the client-side. That is why you need to have your PHP script output a
client-side scripting language such as JavaScript. You are still only
executing PHP code on the server.
Regards, Adam Zey.
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
ok, maybe I didn't make my question too clear. I was mostly wondering if there
is a way to do it in PHP rather than Javascript. I would prefer only using php.
and from the answers I got, I take it that there is no way of doing it in PHP.
All that PHP can do is generate the text for the page that goes to the
browser. It is the browser that does any displaying, and it is browser
end tools you need to use to get a pop-up window.
--
Lester Caine - G8HFL
-----------------------------
L.S.Caine Electronic Services - http://home.lsces.co.uk
Model Engineers Digital Workshop -
http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php
--- End Message ---
--- Begin Message ---
Quoting Lester Caine <[EMAIL PROTECTED]>:
> [EMAIL PROTECTED] wrote:
>
> > ok, maybe I didn't make my question too clear. I was mostly wondering if
> there
> > is a way to do it in PHP rather than Javascript. I would prefer only using
> php.
> >
> > and from the answers I got, I take it that there is no way of doing it in
> PHP.
>
> All that PHP can do is generate the text for the page that goes to the
> browser. It is the browser that does any displaying, and it is browser
> end tools you need to use to get a pop-up window.
>
> --
> Lester Caine - G8HFL
> -----------------------------
> L.S.Caine Electronic Services - http://home.lsces.co.uk
> Model Engineers Digital Workshop -
> http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
> Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Thank you all very much.
Siavash
--- End Message ---
--- Begin Message ---
At 11:03 AM 5/29/2006, [EMAIL PROTECTED] wrote:
Is there anyway to have a pop-up window to ask "are you sure? yes /
no" in php?
I know you can do it in Javascript, but I'm not sure what's the best way to
implement it in php. I want the page to do nothing if "no" is pressed.
With all due respect to my learned colleagues, my answer to your
question is yes, you can accomplish your goal using just PHP.
I assume that you understand that PHP is not a client-side language
and therefore cannot, by itself, produce a real-time,
operating-system-generated pop-up dialog box in the same way that
JavaScript can.
However, PHP can download a page with input fields disabled that
includes a div styled to look like a dialog box with a couple of
submit buttons labeled YES & NO. Submitting YES will request the
same page from PHP but without the dialog div and with user interface
fields enabled; NO will request the same page but without the dialog
div and with UI fields disabled.
From the user's point of view, the main difference between doing
this with PHP and doing it with JavaScript is that the PHP solution
will take at least a few seconds for the round-trip to the server
whereas JavaScript's response to a confirm() dialog will seem instantaneous.
Regards,
Paul
--- End Message ---
--- Begin Message ---
Before I write my own, is there a php math library that will perform US
to metric conversions and the like?
Thanks - Tod
--- End Message ---
--- Begin Message ---
Can someone please advise a faster solution to do what I'm doing
below? All I need to be able to do is determine if any of the
strings in the array are contained in $q. The method I have works,
but I'm sure its not the most efficient way to do it.
$dirtyWord = array("UNION","LOAD_FILE","LOAD DATA INFILE","LOAD
FILE","BENCHMARK","INTO OUTFILE");
foreach($dirtyWord as $injection)
{
if(stristr($q,$injection))
{
//Do Something to remove injection and log it
}
}
Thank you.
--Steven
--- End Message ---
--- Begin Message ---
Steven Osborn wrote:
Can someone please advise a faster solution to do what I'm
doing below? All I need to be able to do is determine if any of the
strings in the array are contained in $q. The method I have works, but
I'm sure its not the most efficient way to do it.
$dirtyWord = array("UNION","LOAD_FILE","LOAD DATA INFILE","LOAD
FILE","BENCHMARK","INTO OUTFILE");
foreach($dirtyWord as $injection)
{
I don't see a way to avoid the foreach loop, but...
if(stristr($q,$injection))
rather than stristr() it's faster (MARGINALLY!) to use stripos()
and test for a boolean false return value because your not interested in
the returned string (so why make php bother with grabbing and returning it)
{
//Do Something to remove injection and log it
if you get here I would suggest logging it and then stopping further processing
rather than trying to clean up the attempt to perform an sql injection.
}
}
Thank you.
--Steven
--- End Message ---
--- Begin Message ---
Steven Osborn wrote:
Can someone please advise a faster solution to do what I'm doing
below? All I need to be able to do is determine if any of the strings
in the array are contained in $q. The method I have works, but I'm sure
its not the most efficient way to do it.
$dirtyWord = array("UNION","LOAD_FILE","LOAD DATA INFILE","LOAD
FILE","BENCHMARK","INTO OUTFILE");
foreach($dirtyWord as $injection)
{
if(stristr($q,$injection))
{
//Do Something to remove injection and log it
}
}
Thank you.
--Steven
Would it not a much safer and WAY faster method simply be to use
mysql_escape_string()? What are you doing that allows users to give raw
SQL to the server that you need to deny certain things? It seems like
you're on very dangerous ground, letting users throw arbitrary SQL at
your script.
Regards, Adam Zey.
--- End Message ---
--- Begin Message ---
Steven Osborn wrote:
Can someone please advise a faster solution to do what I'm doing
below? All I need to be able to do is determine if any of the strings
in the array are contained in $q. The method I have works, but I'm sure
its not the most efficient way to do it.
$dirtyWord = array("UNION","LOAD_FILE","LOAD DATA INFILE","LOAD
FILE","BENCHMARK","INTO OUTFILE");
foreach($dirtyWord as $injection)
{
if(stristr($q,$injection))
{
//Do Something to remove injection and log it
}
}
Thank you.
--Steven
Would it not a much safer and WAY faster method simply be to use
mysql_escape_string()? What are you doing that allows users to give raw
SQL to the server that you need to deny certain things? It seems like
you're on very dangerous ground, letting users throw arbitrary SQL at
your script.
Regards, Adam Zey.
--- End Message ---
--- Begin Message ---
On Mon, 2006-05-29 at 15:48, Jochem Maas wrote:
> Steven Osborn wrote:
> > Can someone please advise a faster solution to do what I'm
> > doing below? All I need to be able to do is determine if any of the
> > strings in the array are contained in $q. The method I have works, but
> > I'm sure its not the most efficient way to do it.
> >
> > $dirtyWord = array("UNION","LOAD_FILE","LOAD DATA INFILE","LOAD
> > FILE","BENCHMARK","INTO OUTFILE");
> > foreach($dirtyWord as $injection)
> > {
>
> I don't see a way to avoid the foreach loop, but...
I saw a post one day by Richard Lynch using the following interesting
approach:
<?php
if( ereg( implode( '|', $dirtyWord ), $q ) )
{
//Do Something to remove injection and log it
}
?>
This may ultimately be faster because it makes fewer function calls thus
bypassing function call overhead incurred for each word. And it's
probably even faster with PCRE.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
by package I mean an external program (outside apache).
On 5/25/06, Jay Blanchard <[EMAIL PROTECTED]> wrote:
[snip]
I'd like to use GD instead of ImageMagick beacuse I would not want to
install extra packages if I can.
[/snip]
GD is an extra package.
--- End Message ---
--- Begin Message ---
Hi.
I´m having some troubles with the number_format function.
When i run a number_format("3000",2,",",".") if returns correctly, but when
i try to run number_format("300",2,",",".") it returns the value formatted
but with two spaces before.
Anyone knows how can i avoid this?
Thanks.
--- End Message ---
--- Begin Message ---
Hi all,
I wrote a php script that creates options for select boxes. What this
script does is selects tomorrows date. However I have tested the code
when the day is the last day of the month and the script blows up.
Instead of displaying June it displays January and repeats the months
12 times I think. I didn't count I just noiced thart that the months
of the year were repeated multiple times.
I think my problem is with the mktime function. I don't think it
likes $i+1 too well. I also want to be sure that this code takes care
of all date contitions like leap year, end of the year and any other
condition that would give a wrong date.
So here is my code:
<select name="month">
<?php
foreach(range(1,12) as $i)
{
if (date('t') == date('j'))
{
echo "<option value=$i+1 selected=\"true\">" . date('F',
mktime(12,0,0,$i+1,1)) . "</option>\n";
}
if (date('n') == $i)
{
echo "<option value=$i selected=\"true\">" . date('F',
mktime(12,0,0,$i,1)) . "</option>\n";
}
else
{
echo "<option value=$i>" . date('F', mktime(12,0,0,$i,1)) . "
</option>\n";
}
}
?>
</select>
<br />
<br />
<select name="day">
<?php
foreach (range (1,31) as $i)
{
if (date('j')+1 == $i)
{
echo "<option value=$i selected=\"true\">" . date('j',
mktime(12,0,0,0,$i,date('Y'))) . "</option>\n";
}
else
{
echo "<option value=$i>" . date('j',
mktime(12,0,0,0,$i,date('Y')))
. "</option>\n";
}
}
?>
</select>
<br />
<br />
<select name="year">
<?php
if (date('n') == 12 && date('j') == 31 )
{
echo "<option value=" . date('Y')+1 . " selected=\"true\">" .
date('Y')+1 . "</option>\n";
}
else
{
echo "<option value=" . date('Y') . " selected=\"true\">" . date('Y')
. "</option>\n";
}
?>
</select>
Any help will be appreciated
Paul
--- End Message ---
--- Begin Message ---
Paul Goepfert wrote:
... What this script does is selects tomorrows date...
Here is a one-line way to find the month and day of tomorrow:
<?php
list($tomorrow_month, $tomorrow_day) = split(':', date('m:d',
time()+86400));
?>
Test that ... I just wrote it off the top of my head. Maybe that will
simplify your code.
Dante
--- End Message ---
--- Begin Message ---
Hi,
I have been having problems that I am being classed as spam server if I use
the mail() function to send out mail to people who are using my system
(notifications etc). How can I avoid this? Anyone with experience?
Best regards,
Peter Lauri
--- End Message ---