php-general Digest 14 May 2006 13:30:31 -0000 Issue 4127
Topics (messages 236131 through 236147):
Re: MySQL - HEAP table type
236131 by: chris smith
236137 by: John Nichel
Re: Failing FastCGI PHP
236132 by: chris smith
Re: METHOD=POST not worikng
236133 by: chris smith
236136 by: IraqiGeek
236139 by: chris smith
236141 by: Rabin Vincent
236145 by: David Dorward
Re: Security Concerns with Uploaded Images:
236134 by: chris smith
236140 by: Nick Wilson
Re: Uploading large files
236135 by: chris smith
236142 by: php . net mines
236144 by: chris smith
Re: Wierd ass code...
236138 by: Gonzalo Monzón
strategies for multilanguage sites
236143 by: D_C
236146 by: Jochem Maas
Re: Is it a bug ?
236147 by: Fourat Zouari
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:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On 5/14/06, Martin Zvarík <[EMAIL PROTECTED]> wrote:
Hi,
I am sorry for this not being really a PHP question, anyway I use
MySQL database, I have a table, which is HEAP (memory) type and I found
out I can store only about 22000 entries in it, then when I want to
insert new entry it gives me an error that the table is full.
The question is: How can I increase this limit?
Only the mysql documention or lists will be able to answer that.
http://dev.mysql.com
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Martin Zvarík wrote:
Hi,
I am sorry for this not being really a PHP question
So you know it's off topic, yet you're going to ask anyway.
MySQL database, I have a table, which is HEAP (memory) type and I found
out I can store only about 22000 entries in it, then when I want to
insert new entry it gives me an error that the table is full.
The question is: How can I increase this limit?
Well, you could read the *MySQL* manual. You could search Google. You
could search the archives for the *MySQL* mailing lists. If none of
that bears fruit, you could post this question on the *MySQL* mailing list.
<being good boy>
In an ongoing effort to provide better answers, I didn't use RTFM, STFW
or STFA.
</being good boy>
--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
On 5/14/06, Frank de Bot <[EMAIL PROTECTED]> wrote:
I'll start by compiling php with --enable-debug
At the moment I get backtrace results like this:
#0 0x48c7d95b in memcpy () from /usr/lib/libc_r.so.4
#1 0x8977280 in ?? ()
#2 0x10 in ?? ()
#3 0x894e500 in ?? ()
#4 0x894dc00 in ?? ()
#5 0x8962000 in ?? ()
#6 0x8960200 in ?? ()
#7 0x894e4e0 in ?? ()
#8 0x894e4c0 in ?? ()
etc etc etc...
Thus useless :P
Unfortunately yes, rather useless :(
Might get better help on the internals list (I don't know what else to
suggest, was hoping someone else might jump in and help you!).
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On 5/14/06, IraqiGeek <[EMAIL PROTECTED]> wrote:
On Saturday, May 13, 2006 4:59 PM GMT,
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> AFAIK it should be working just fine. I'm not aware of POST not
> working in any circumstance other than PHP not working at all.
>
> Can you post your test script? We could better judge what's happening
> based off that. Just make sure you're referencing the variables with
> $_POST or $_REQUEST, not $_GET.
>
> Slightly off topic. If you're not already, always make sure to
> verify/escape your input from POST/GET/RSS/etc. That will help make
> your pages more secure. It might seem like you don't need to do it
> right now at the beginning, but it's a good habit to get into... One
> that I need to follow better (especially when I have a really short
> deadline).
>
> Ray
>
PHP is indeed working. If I use METHOD=GET instead of POST, the script works
without any issues. Here is the test script I'm using:
<html>
<title>test script</title>
<body>
<?php
//If the user wants to add a joke
if(isset($_GET['addtext'])):
You're checking for a get string here, not a post string. So it will
never get into this part of the code.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On Sunday, May 14, 2006 2:01 AM GMT,
chris smith <[EMAIL PROTECTED]> wrote:
On 5/14/06, IraqiGeek <[EMAIL PROTECTED]> wrote:
On Saturday, May 13, 2006 4:59 PM GMT,
[EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
AFAIK it should be working just fine. I'm not aware of POST not
working in any circumstance other than PHP not working at all.
Can you post your test script? We could better judge what's
happening based off that. Just make sure you're referencing the
variables with $_POST or $_REQUEST, not $_GET.
Slightly off topic. If you're not already, always make sure to
verify/escape your input from POST/GET/RSS/etc. That will help make
your pages more secure. It might seem like you don't need to do it
right now at the beginning, but it's a good habit to get into... One
that I need to follow better (especially when I have a really short
deadline).
Ray
PHP is indeed working. If I use METHOD=GET instead of POST, the
script works without any issues. Here is the test script I'm using:
<html>
<title>test script</title>
<body>
<?php
//If the user wants to add a joke
if(isset($_GET['addtext'])):
You're checking for a get string here, not a post string. So it will
never get into this part of the code.
I have tried _POST here, and when its then that I won't be able to get into
the part of the code that I want to get into. $addtext is passed through an
HREF tag, not through the form.
I think I have reached the limit where I need to use a debugger to get any
further. I just installed Gubed, and currently reading the documentation.
Once I can start debugging the script, I will be able to know what and where
exactly are things going wrong.
Regards,
IraqiGeek
www.iraqigeek.com
I am at two with nature.
Woody Allen
--- End Message ---
--- Begin Message ---
IraqiGeek wrote:
On Sunday, May 14, 2006 2:01 AM GMT,
chris smith <[EMAIL PROTECTED]> wrote:
On 5/14/06, IraqiGeek <[EMAIL PROTECTED]> wrote:
On Saturday, May 13, 2006 4:59 PM GMT,
[EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
AFAIK it should be working just fine. I'm not aware of POST not
working in any circumstance other than PHP not working at all.
Can you post your test script? We could better judge what's
happening based off that. Just make sure you're referencing the
variables with $_POST or $_REQUEST, not $_GET.
Slightly off topic. If you're not already, always make sure to
verify/escape your input from POST/GET/RSS/etc. That will help make
your pages more secure. It might seem like you don't need to do it
right now at the beginning, but it's a good habit to get into... One
that I need to follow better (especially when I have a really short
deadline).
Ray
PHP is indeed working. If I use METHOD=GET instead of POST, the
script works without any issues. Here is the test script I'm using:
<html>
<title>test script</title>
<body>
<?php
//If the user wants to add a joke
if(isset($_GET['addtext'])):
You're checking for a get string here, not a post string. So it will
never get into this part of the code.
I have tried _POST here, and when its then that I won't be able to get into
the part of the code that I want to get into. $addtext is passed through an
HREF tag, not through the form.
Sorry, missed that bit.
First step before using a debugger, add:
echo "<pre>"; var_dump($_POST); echo "</pre>";
somewhere in your code and go from there.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On 5/13/06, IraqiGeek <[EMAIL PROTECTED]> wrote:
[snip]
<html>
<title>test script</title>
<body>
<?php
//If the user wants to add a joke
if(isset($_GET['addtext'])):
?>//If I use METHOD=GET here, the script works flawlessly
<form action="<?php echo($_SERVER['php_self']);?>" METHOD=POST>
[/snip]
The form action should be $_SERVER['PHP_SELF']. Here case
matters, since this is a string and not a variable name.
If action is empty, I believe browsers simply send the request
to whatever URL the page was accessed at. Since you're already
at a GET (with ?addtext), the POST request actually includes
both the GET and the POST, so the the form is shown again.
Just var_dump $_GET and $_POST and you'll see what's happening.
Rabin
--- End Message ---
--- Begin Message ---
IraqiGeek wrote:
> I'm learning PHP on a Debian Etch with Apache 2.0.54 and PHP 4.3.10, and
> using Firefox 1.5.3 on a Windows XP box to browse the sample site. I wrote
> a small form to get user input. If I use METHOD=GET, then the form works
> fine, without any glitches. However, if I use METHOD=POST in the form, I
> don't get the data back to the script.
The most likely explanation is that there is something wrong with your
script or with your form. It would help if you showed the code (a minimal
test case by preference) you are trying to use.
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
--- End Message ---
--- Begin Message ---
On 5/14/06, Nick Wilson <[EMAIL PROTECTED]> wrote:
Hi all,
are there any security concerns with uploaded images?
My thought is that it wouldnt be too hard to have some kind of script
masquerade as a gif file, and perhaps cause damage.
I cant find anyway to check a file really is a gif/png/jpg (i assume the
mimetype available in $_FILES could be spoofed).
I'd welcome any thoughts in general on this, but specifically if anyone
has experience/knowledge in this area and can point me in the right
direction.
Check the file extension and the mimetype, make sure they are both
valid.. or as someone else suggested, use getimagesize on it - if that
returns false or empty then it's not an image.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
* and then chris smith declared....
> Check the file extension and the mimetype, make sure they are both
> valid.. or as someone else suggested, use getimagesize on it - if that
> returns false or empty then it's not an image.
Ok thanks guys. I'll do extension and mime and getimagesize() before
saving/using them.
Much thanks!
--
Nick Wilson
Tel: +45 3311 2250
--- End Message ---
--- Begin Message ---
is there a way to upload large files (e.g. 15mb) without changing the
default settings in php.ini***?
According to this page:
http://www.php.net/manual/en/ini.php#ini.list
You can do it with a htaccess file. See comments at the bottom.
Preferably by using php, but if not is there another web tech (e.g. Java
applets) that will allow me to do this?
Sure. Python, ruby, java, perl, whatever you like.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
I'm building a site which will be hosted on a shared server (hosting company
won't change any php.ini settings), and the client wants to upload his
clients' data (let's say a zip) so they can loggin and download it from the
site.
----- Original Message -----
From: "Rory Browne" <[EMAIL PROTECTED]>
To: "php @ net mines" <[EMAIL PROTECTED]>
Cc: "PHP-General" <php-general@lists.php.net>
Sent: Saturday, May 13, 2006 8:27 PM
Subject: Re: [PHP] Uploading large files
possibly by using CGI/php, and changing the relevent vaules, on the command
line.
Why don't you want to change the php.ini values if you legitimately want to
upload these files?
On 5/13/06, php @ net mines <[EMAIL PROTECTED]> wrote:
Hi all
is there a way to upload large files (e.g. 15mb) without changing the
default settings in php.ini***?
Preferably by using php, but if not is there another web tech (e.g. Java
applets) that will allow me to do this?
Thanks in advance
Mario
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On 5/14/06, php @ net mines <[EMAIL PROTECTED]> wrote:
I'm building a site which will be hosted on a shared server (hosting company
won't change any php.ini settings), and the client wants to upload his
clients' data (let's say a zip) so they can loggin and download it from the
site.
Depends on the size of the file. If it's 10M, php will be able to
handle it. If it's 100M, teach them to use ftp - it'll save you so
many headaches.
You can write a java applet if you like but how you do that? Don't
know - you'll have to find a java list :)
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Satyam escribió:
----- Original Message ----- From: "Satyam" <[EMAIL PROTECTED]>
To: "Ryan A" <[EMAIL PROTECTED]>; "php php" <php-general@lists.php.net>
Sent: Saturday, May 13, 2006 9:53 PM
Subject: Re: [PHP] Wierd ass code...
----- Original Message ----- From: "Ryan A" <[EMAIL PROTECTED]>
To: "php php" <php-general@lists.php.net>
Sent: Saturday, May 13, 2006 9:20 PM
Subject: [PHP] Wierd ass code...
Hey,
Been reading some other code that I got from the net,
and have come across some wierd looking code, would
appreciate it if someone could explain it to me:
$hits = array();
$bytes = array();
$blocked = array();
$baps = array();
$bapm = array();
So far so good.... then further down:
// Add to the running totals
@$hits["$username|$subnet"]++;
@$bytes["$username|$subnet"]+=$byte;
@$baps["$username|$subnet|$this_second"]++;
@$bapm["$username|$subnet|$this_minute"]++;
What kind of arrays are the above? I have never seen
nor worked with arrays like them before.
If you can point me to a particular place in the
manual or a few URLs too would be appreciated.
Thanks,
Ryan
I don't think there is nothing special with the arrays, he is just
coding some information into strings, with the vertical bar as
separator, and using this as the keys to several arrays where he is
collecting some statistical information, such as (it would seem to me)
- number of hits by user and subnet
- number of bytes by user and subnet
- number of hits per user and subnet per second
- number of hits per user and subnet per minute
I would assume that the variables $this_second and $this_minute are
absolute numbers counted from a particular time, not seconds from 0
to 60 within the minute. Likewise for the minutes.
I assume that the @ in front is to avoid the error of trying to
increment a value that is not yet set.
I guess that this same thing could have been achieved with
multidimensional arrays but either concatenating the variables into a
single string is faster or some other reason that makes sense for the
application, such as being able to sort by keys in just one operation.
Satyam
Of course, another possibility is that the author does not know how to
handle multidimensional arrays (just to say it before anyone else
points an obvious alternative)
Satyam
Hi!
I don't think the author does not know how to handle multidimensional
arrays. I thought the author was more concerned about performance than
other issues people like as coding "beautifuly"... Maybe author's
approach is weird, but its twice faster in the worst case!!
Sure the author only needs to loop the whole array and doesn't need
multi-dimensional approach... 'cause its a lot faster to iterate once
the array is filled!!
Look at the test I've done (below) its seems filling multi-dimensional
arrays is n/2 faster than single dimension, but then when you need to
read the array data, a multi-dimensional approach is always worse than
n*6!! so the total time for setting & getting the data is about n*2 in
the worse case... Repeating the same operation multiple times, the
multi-dimensional approach always gets worse performance ??, but
single-dimension stays performing in a linear way. I think that's really
interesting!!
Perhaps there are better approaches for iterating over multidimensional
arrays, but that's what I got in 5 minutes coding. I'd like to hear your
suggestions about if the author code really worth the pain when
performance makes sense.
Attached results and code. (tested on PHP 4.3.4)
--------------------------------------------------------------
Testing bidimensional and single dimension array manipulation
Fill style A, bidimensional array: 2,1603
Iteration style A, bidimensional array: 9,9071
Total time style A: 12,0681
Fill style B, single-dimension array: 4,2362
Iteration style B, single-dimension array: 1,5452
Total time style B: 5,7821
Fill style A, bidimensional array: 2,3548
Iteration style A, bidimensional array: 13,1935
Total time style A: 15,5489
Fill style B, single-dimension array: 4,2891
Iteration style B, single-dimension array: 1,5413
Total time style B: 5,8312
Fill style A, bidimensional array: 2,36
Iteration style A, bidimensional array: 17,8439
Total time style A: 20,2046
Fill style B, single-dimension array: 4,2982
Iteration style B, single-dimension array: 1,5554
Total time style B: 5,8544
Fill style A, bidimensional array: 2,3756
Iteration style A, bidimensional array: 17,8817
Total time style A: 20,2579
Fill style B, single-dimension array: 4,3203
Iteration style B, single-dimension array: 1,5332
Total time style B: 5,8543
Fill style A, bidimensional array: 2,3554
Iteration style A, bidimensional array: 19,2986
Total time style A: 21,6547
Fill style B, single-dimension array: 4,3013
Iteration style B, single-dimension array: 1,5508
Total time style B: 5,8528
<?php
function TimeMS() {
$ms = substr(microtime(),2,4);
return (time()*10000)+$ms;
}
function Test_a() {
global $testA;
for ($a=1;$a<999;$a++) {
for ($b=1;$b<999;$b++) {
$testA[$a][$b] = "$a$b";
}
}
}
function Test_b() {
global $testB;
for ($a=1;$a<999;$a++) {
for ($b=1;$b<999;$b++) {
$testB["$a|$b"] = "$a$b";
}
}
}
function Test_a2() {
global $testA;
do {
$k=key($testA);
$v=$testA[$k];
do {
$k2=key($v);
$v2=$v[$k2];
} while(next($v));
} while(next($testA));
}
function Test_b2() {
global $testB;
do {
$k=key($testB);
$v=$testB[$k];
} while(next($testB));
}
print "Testing bidimensional and single dimension array manipulation\n\n";
$a = true;
$b = true;
for ($n=1;$n<=5;$n++) {
if ($a) {
$testA = array();
print "Fill style A, bidimensional array: ";
$start_time = TimeMS();
Test_a();
print ((TimeMS() - $start_time)/10000)."\n";
print "Iteration style A, bidimensional array: ";
$start_time2 = TimeMS();
Test_a2();
print ((TimeMS() - $start_time2)/10000)."\n";
print "Total time style A: ".((TimeMS() -
$start_time)/10000)."\n\n";
unset($testA);
}
if ($b) {
$testB = array();
print "Fill style B, single-dimension array: ";
$start_time = TimeMS();
Test_b();
print ((TimeMS() - $start_time)/10000)."\n";
print "Iteration style B, single-dimension array: ";
$start_time2 = TimeMS();
Test_b2();
print ((TimeMS() - $start_time2)/10000)."\n";
print "Total time style B: ".((TimeMS() -
$start_time)/10000)."\n\n";
unset($testB);
}
}
?>
--- End Message ---
--- Begin Message ---
hi list -
am wondering what approaches people take for multilanguage sites? were
working on a CMS system and need to have the UI / links show up in
many languages and be easily localizable by people.
we're using smarty, so one approach is to use smarty config files and
then smarty tags for all the items.
_TOP_MENU_BTN= "return to top menu";
is there a big performance hit to this? this means replacing a lot of
items in each page, each pass.
the other way is to just localize inline in the template files
themselves, but this means if a design changes all the lang templates
for each lang have to be updated... :(
another way is to have a huge define file
define("_TOP_MENU_BTN", "return to top menu" );
is this a LOT faster?
Also i am looking for some way to manage the strings during
translation, to make sure as things get added to say the english UI
that its easy to track whats missing from the translations. i guess
well have to build a simple spreadsheet like GUI but i was wondering
if anything is already available.
I guess there is also a gnu gettext extension, but it doesnt seem
widely supported or avail for windoze.
tx for any other suggestions!!
/dc
--
_______________________________________________
David "DC" Collier
[EMAIL PROTECTED]
skype: callto://d3ntaku
http://www.pikkle.com
+81 (0)80 6521 9559
http://charajam.com 【★キャラ♪ジャム★】
人気キャラとJ-POP最新ヒット曲を自分で組み合わせて
待受Flashや着Flashを作っちゃおう!
_______________________________________________
--- End Message ---
--- Begin Message ---
D_C wrote:
> hi list -
>
> am wondering what approaches people take for multilanguage sites? were
> working on a CMS system and need to have the UI / links show up in
> many languages and be easily localizable by people.
>
> we're using smarty, so one approach is to use smarty config files and
> then smarty tags for all the items.
>
> _TOP_MENU_BTN= "return to top menu";
>
> is there a big performance hit to this? this means replacing a lot of
> items in each page, each pass.
suitable caching/compiling should be used to avoid translation on each pass -
maybe using a precompiler plugin - I haven't figured out a decent way of doing
this
myself yet.
>
> the other way is to just localize inline in the template files
> themselves, but this means if a design changes all the lang templates
> for each lang have to be updated... :(
>
> another way is to have a huge define file
> define("_TOP_MENU_BTN", "return to top menu" );
> is this a LOT faster?
creating constants is SLOW. using the apc extension constant related
functions is a great way of speeding this up. outputting the
constants is comparative fast.
>
> Also i am looking for some way to manage the strings during
> translation, to make sure as things get added to say the english UI
> that its easy to track whats missing from the translations. i guess
> well have to build a simple spreadsheet like GUI but i was wondering
> if anything is already available.
>
> I guess there is also a gnu gettext extension, but it doesnt seem
> widely supported or avail for windoze.
I have no idea about gettext on windows - personally I would never
use windows for a production webserver anyway.
I'm currently working on a stand alone 'plugin' type application using gettext
that can scan (using tokenize) & manage a projects files, retrieve all
translatable
strings dump them in a DB (with an editing interface for translators) and
finally
generate the binary .mo files for the project ... it requires that all strings
in
the project are translated via the 'gettext()' function (or it's alias '_()').
in the longterm gettext is the superior method and a solution that allows you
to use
it AND manage the translations is the way to go IMHO.
>
> tx for any other suggestions!!
>
> /dc
--- End Message ---
--- Begin Message ---
ok
this is returning the retrived data from open sockets :
http://pastebin.com/716768
this is returning an empty string :
http://pastebin.com/716767
On 5/14/06, chris smith <[EMAIL PROTECTED]> wrote:
On 5/14/06, Fourat Zouari <[EMAIL PROTECTED]> wrote:
> Code 1 :
> -------------------------
> var_dump(stream_get_contents($rr));
> -------------------------
> Output 1
> -------------------------
> string(185) "HTTP/1.1 202 Accepted
> Server: Apache2
> Content-Length: 24
> Connection: close
> Content-type: text/html
> Pragma: no-cache
> Cache-Control: no-cache
>
> 0: Accepted for delivery"
> -------------------------
>
>
> Code 2 :
> -------------------------
> $x = stream_get_contents($rr);
> var_dump($x);
> -------------------------
> Output 2
> -------------------------
> string(0) ""
> -------------------------
>
> Am i wrong ?
Without seeing all of the code, we can't tell anything from that.
Post it in http://pastebin.com and send us a url.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---