[PHP] Re: PHP: inexplicable behaviour of pre- and post-increment operators
Mess Dne 27.2.2010 5:01, clanc...@cybec.com.au napsal(a): A week ago Dasn asked a question about converting arrays, and I quoted one possible way of achieving his task, using the operation: $i = 0; while ($i $k) { $b[$a[$i++]] = $a[$i++]; } I added the comment that I have always been wary of using statements like this because I was unsure when the incrementing would occur, so I tried it. I received several CC e-mails replying to this post, including one rather critical comment to the effect that pre-and post-increment were all quite simple, and I really ought to learn the fundamentals before I started trying to do anything elaborate. I posted a reply to these e-mails, but as neither they, nor my reply, or any follow-up discussion ever appeared in the discussion group I will repost this reply. (I did have a power failure at this time, so it is conceivable that any follow-up was lost as a result of a glitch in my mailer, but I think it is more likely that there was a glitch in the discussion group server.) Unfortunately things aren't nearly as simple as this writer believes. The rule I have always used is that if you use the same variable as an index on both sides of an assign statement it is not safe to change the value of the index within the statement. While I have achieved the result I wanted in the example above (using PHP 5.1.6 -- there is no guarantee it would work with other implementations of PHP) the results of doing this in the general case can be quite inexplicable. The particular case which prompted my comment was the one where you want to copy part of one array into the corresponding elements of another array. In accordance with my rule, I normally write: $i = 0; $j=count($a); while ($i $j) { $b[$i] = $a[$i]; ++$i; } It is tempting to try to put the increment into the assignment statement. Clearly the value of $a[$i] has to be read before it can be written to $b[$i], so the logical expression would be: while ($i $j) { $b[$i++] = $a[$i]; } A. However if you try this, you get $b[1] = $a[0], and so on. But if you try the alternative: while ($i $j) { $b[$i] = $a[$i++]; } B. You get $b[0] = $a[1], and so on (as you would expect). Out of curiosity, I then tried: $i = -1; $j=count($a) - 1; while ($i $j) { $b[$i] = $a[++$i]; }C This gave the desired result, and seemed moderately logical. However when I tried: $i = -1; $j=count($a) - 1; while ($i $j) { $b[++$i] = $a[$i]; }D This gave exactly the same result. It is quite impossible to explain the results in cases A and D from the definitions of the pre-and post-increment operator, so I think I will stick to my safe rule! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array references - how to unset() ?
$ARR = array( 'a' = array('b' = 'blah') ); function set($key) { global $ARR; foreach ($key as $i = $k) { if ($i == 0) { $sourcevar = $ARR[$k]; } else { $sourcevar = $sourcevar[$k]; } } // unset($sourcevar); // will cancel the reference - we want to unset the ['b'], but how? $sourcevar = null; // will set it NULL, but won't unset... foreach ($ARR ... // I could run a cleanup, that would go through all of the array and unset what is NULL, but I would need to use REFERENCES again!! array_walk_recursive() is also worthless... any ideas? } set( array('a', 'b') ); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array references - how to unset() ?
Robert Cummings napsal(a): Martin Zvarík wrote: $ARR = array( 'a' = array('b' = 'blah') ); function set($key) { global $ARR; foreach ($key as $i = $k) { if ($i == 0) { $sourcevar = $ARR[$k]; } else { $sourcevar = $sourcevar[$k]; } } // unset($sourcevar); // will cancel the reference - we want to unset the ['b'], but how? $sourcevar = null; // will set it NULL, but won't unset... foreach ($ARR ... // I could run a cleanup, that would go through all of the array and unset what is NULL, but I would need to use REFERENCES again!! array_walk_recursive() is also worthless... any ideas? } set( array('a', 'b') ); unset( $ARR[$k] ) Cheers, Rob. Thanks for reply, but I want to: unset($ARR['a']['b']) Imagine I have this: $KEYS = array('a', 'b', 'c'); And I want to: unset($ARR['a']['b']['c']) It's probably impossible, unless I do something dirty like this: list($rootA, $rootB, $rootC) = $KEYS; if (isset($rootC)) unset($x[$rootA][$rootB][$rootC]); elseif (isset($rootB)) unset($x[$rootA][$rootB]); elseif (isset($rootA)) unset($x[$rootA]); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array references - how to unset() ?
AHA !!! OMG... how come I did not see that!? Instead this: $array = $array[$final]; unset($array); This: unset($array[$final]); 3 AM in the morning... that must be the reason! .) Thanks. This is possible. You're just not giving enough consideration to your exit strategy :) ?php function unset_deep( $array, $keys ) { $final = array_pop( $keys ); foreach( $keys as $key ) { $array = $array[$key]; } unset( $array[$final] ); } $value = array ( 'a' = array ( 'b' = array ( 'c' = 'C', 'd' = 'D', 'e' = 'E' ), ), ); $keys = array('a', 'b', 'c'); unset_deep( $value, $keys ); print_r( $value ); ? Cheers, Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Re: Re: Design Patterns
Ralph Deffke napsal(a): NO NO NO OOP is the best ever inventet ! see my comments on this list, I will also come up with an pure oop opensource OMS very soon. I just think a dam big pattern catalog like this one is like an elephant chacing mice. I mean I can think of customers asking for a documentation of course of the page u created for them calling the next day asking wher the hell are the code for the page are documented in the 1000 pages of documentation u had to give them. I can think of two of my largest customers with their intranet application with 23000 members and more then 5 hits during working hours where I startet sweating while figting for every 1ms. I'm thinking of people with even more hits a day, they even dont start using PHP so I dont know if thats the right way to blow up with includes and thousands of classes. I deeply and completely agree. Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: file_set_contents() do several times?
David Otton napsal(a): 2009/7/20 Martin Zvarík mzva...@gmail.com: ?php $i = 0; do { $i++; $r = file_put_contents('file.txt', 'content'); } while($r === false $i 3); if ($r === false) die('error'); ? Makes sense? or is it enough to do it just once? Assuming 'content' changes, and this is the cut-down example... $r = file_put_contents('file.txt', 'content', FILE_APPEND); There's a small overhead in opening/closing the file three times instead of one, but I doubt that's going to be an issue for you. I am not appending anything, just ensuring that it will be written (and giving it max. 3 tryes). === Martin Scotta replied: In my experience file_put_contents never fails, except about file permissions, but this is not the case. --- Thanks for your replies. Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file_set_contents() do several times?
?php $i = 0; do { $i++; $r = file_put_contents('file.txt', 'content'); } while($r === false $i 3); if ($r === false) die('error'); ? Makes sense? or is it enough to do it just once? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Lookup domain in directories VS database
Imagine you are hosting 10.000 subdomains. SOLUTION #1: you create directories like: a/ b/ ... s/ s/some-subdomain.freehosting.com/ (this includes CONF.php, where you store some basic infos) Everytime visitor hits the page you do: @include('t/test-subdomain.freehosting.com/conf.php') if (!isset($CONF)) die('such a subdomain does not exist'); SOLUTION #2: Everytime visitor hits the page you connect search in a MySQL table having 10.000 rows with each domain name and a text field (export_var()) that has some parameters you need. --- What's better? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Image Type BMP @ Save Image As Dialog on IE
Nitsan Bin-Nun napsal(a): I have wrote a PHP script that serves JPEG images in smaller size, the resize is done using GD on-the-fly. I have noticed an interesting issue during the save image as... dialog on serveral internet explorer browsers, somehow, for some strange reason, the JPEG file is shown as BMP file. I don't know why this is happening, but I'm trying to make it save it as JPG file. In firefox or any other browser everything works like a charm. I have to mention that the JPG file is located in the HTML in the following format: img src='xxx.jpg' alt='aaa' style='border:0;' / I have also used mod_rewrite to serve the file with .jpg extension (I thought that the strange IE may not know how to recognize it..), the PHP file is sending the correct headers, I'm attaching an example for HTTP request response for this resized image: GET /gallery-image-dolphinim-12450163853. HTTP/1.1 Host: www.dolphinim.net User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 FirePHP/0.3 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cookie: PHPSESSID=e4542edfa5bcb7904e351d39c341fffa HTTP/1.x 200 OK Date: Fri, 26 Jun 2009 16:18:52 GMT Server: Apache/1.3.41 (Unix) PHP/5.2.6 mod_log_bytes/1.2 mod_bwlimited/1.4 mod_auth_passthrough/1.8 FrontPage/5.0.2.2635 DAV/1.0.3 mod_ssl/2.8.31 OpenSSL/0.9.8e-fips-rhel5 X-Powered-By: PHP/5.2.6 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Keep-Alive: timeout=15, max=98 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: image/jpeg Any directions will be highly appreciated! Thanks! I have noticed the same thing... although after the temporary files clean up and refresh it works OK. So, this is an IE bug - I have not found any workaround. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: XSS Preventing.
Don't htmlentiies() before DB save. In general: - mysql_real_escape_string() before DB insertion - htmlentities() before dispaly I, on the other hand, would do htmlentities() BEFORE insertion. Pros: --- The text is processed once and doesn't have to be htmlentitied() everytime you read the database - what a stupid waste of performance anyway. Cons: --- Instead you'll see amp; ... is that a problem? Not for me and I believe 80% of others who use DB to store view on web. Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: XSS Preventing.
Cons: 1. Can't easily edit information in the database True, so if you use phpmyadmin for editing - don't do what I suggested. 2. Can't display raw for the user (e.g. edit a forum post) Edit a forum? You display the data in TEXTAREA... 3. Uses more space in the DB True, although I use htmlspecialchars() which doesn't replace that many characters. 4. Isn't as easily indexed 5. Breaks il8n support of internal search engines (sphinx, lucene, etc.) Thanks for reply, I will still do it before the DB insert. * Btw. I should have mentioned I don't use htmlentities(), but htmlspecialchars()* You're NEVER supposed to santize before inserting in the DB. Ever. Regarding the performance boost, if your application is written so well that calling htmlentities() is hurting the performance, I bow to you as writing the highest performing PHP I've ever seen. I would bet money that validation and sanitization, even if overdone, wouldn't take more than 2 or 3 percent of execution time. Do NOT do this, OP, it's terrible practice.
Re: [PHP] Re: XSS Preventing.
Eddie Drapkin napsal(a): 2. Can't display raw for the user (e.g. edit a forum post) Edit a forum? You display the data in TEXTAREA... Because seeing something like: textareaquot;Yeah!quot; is what he said. /textarea Is awesome for the user experience. If you don't do html...() before putting to textarea this can happen: textarea blabla b/textarea blabla /textarea See? 3. Uses more space in the DB True, although I use htmlspecialchars() which doesn't replace that many characters. That makes it no better of a practice to pre-sanitize. You've still yet to offer any compelling reasons why you think this is a good idea. It's DEFINITELY easier to store RAW data to DB, because it won't give you any headaches in the future - when you might need to add some other functionality requiring this. But for me personally is doing - htmlspecialchars() - BEFORE the DB insertion the choice to go, because I am looking for performance. ok? respect
Re: [PHP] Re: XSS Preventing.
Philip Thompson napsal(a): On Jun 23, 2009, at 9:29 AM, Martin Zvarík wrote: Don't htmlentiies() before DB save. In general: - mysql_real_escape_string() before DB insertion - htmlentities() before dispaly I, on the other hand, would do htmlentities() BEFORE insertion. Pros: --- The text is processed once and doesn't have to be htmlentitied() everytime you read the database - what a stupid waste of performance anyway. Cons: --- Instead you'll see amp; ... is that a problem? Not for me and I believe 80% of others who use DB to store view on web. I had a problem with storing amp; into the database instead of just . When I wanted to search for something and amp; was in the value, typing would not find the result. I fixed that by not using htmlentities() before inputing data into the database. IMO, using htmlentities() or htmlspecialchars() before inserting into db is inherently wrong. Making calls to those functions should have negligible impact on the application - there are other ways to improve the performance of your application. My too scents, ~Philip Martin You could do htmlentities() at the search string... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Query stopping after 2 records?
Miller, Terion napsal(a): I need help/advice figuring out why my query dies after 2 records. Here is the query: // Build your INSERT statement here $query = INSERT into `warrants` (wid, name, age, warrant, bond, wnumber, crime) VALUES (; $query .= '$wid', '$name', '$age', '$warrant', '$bond', '$wnumber', '$crime' ); $wid = mysql_insert_id(); // run query mysql_query($query) or die (GRRR); echo $query; It inserts two records and dies half way thru the 3rd? Thanks in advance for clues to fix this. T.Miller Should be: -- $sql = ... $query = mysql_query($sql) or die(... while ($r = mysql_fetch_array($query)) { -- Notice that you need to assign the mysql_query to a $query variable! If you understand this, then there's most probably a mistake in your SQL statement. Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Query stopping after 2 records?
If the query stopped after getting 2 entries then this has nothing to do with max_execution_time. But stupid topic anyway, I don't know why are we even trying to figure what Miller meant, he most probably solved it already... Andrew Hucks napsal(a): When you say die, does it just stop, or do you get an error message? Depending on how long it's taking to perform the action, the script will stop just because it's taking a while. (by default, I think it's 30 seconds.) If so, use: ini_set(max_execution_time, time in seconds); On Mon, May 4, 2009 at 3:43 PM, Martin Zvarík mzva...@gmail.com wrote: Miller, Terion napsal(a): I need help/advice figuring out why my query dies after 2 records. Here is the query: // Build your INSERT statement here $query = INSERT into `warrants` (wid, name, age, warrant, bond, wnumber, crime) VALUES (; $query .= '$wid', '$name', '$age', '$warrant', '$bond', '$wnumber', '$crime' ); $wid = mysql_insert_id(); // run query mysql_query($query) or die (GRRR); echo $query; It inserts two records and dies half way thru the 3rd? Thanks in advance for clues to fix this. T.Miller Should be: -- $sql = ... $query = mysql_query($sql) or die(... while ($r = mysql_fetch_array($query)) { -- Notice that you need to assign the mysql_query to a $query variable! If you understand this, then there's most probably a mistake in your SQL statement. Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Resampling images -- need lock ?
I have 10 images of different sizes. If user clicks ROTATE, a script will go through all these 10 images and rotates them. If the user clicks TWICE, the first script will get aborted in the middle (so few images are already rotated) and then the second request will rotate all of them again. I probably need to write a script that would lock the first file and if this file is already locked it would just die('already working...') Is this a good approach? I know I can use javascript to disable second click, but I want it server side. Thanks for your suggestions, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Resampling images -- need lock ?
kranthi napsal(a): yeh. if u want it to be on server side that is a good approach. but i feel it'll be very easy to do it with javascript... but what i did not understand is: what should happen if the user clicks ROTATE second time(when the script completed rotating say 5 images)? Well, few images (etc. 5) got rotated +90 deg. and then the script got aborted, because of the second request, which will cause another +90 deg rotation again on all images = meaning those 5 will be again rotated +90 = 180, the others stay 90. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Resampling images -- need lock ?
I see... I will need this too: ignore_user_abort(true); kranthi napsal(a): i dont think flock will help in this case.. flock will b of help when u want to lock a particular file(to read/write) but it'll not help u to stop execution of a php script -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Resampling images -- need lock ? SOLVED
Martin Zvarík napsal(a): I have 10 images of different sizes. If user clicks ROTATE, a script will go through all these 10 images and rotates them. If the user clicks TWICE, the first script will get aborted in the middle (so few images are already rotated) and then the second request will rotate all of them again. I probably need to write a script that would lock the first file and if this file is already locked it would just die('already working...') Is this a good approach? I know I can use javascript to disable second click, but I want it server side. Thanks for your suggestions, Martin I rename the first file at the beginning of the script. Than do all rotations. -- If there's another request, it checks if the file exists - if not = it's being processed = wait. Simple. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Cygwin - compilation of PHP extension
Hi, I am totally new in compiling under cygwin. I need to compile an PHP extension, and this is what I figured so far: gcc -c extension_name.c (that's the only *.c file in that extension directory) ERROR: php.h: No such file... So, I changed the env PATH: PATH=$PATH:/usr/local/src/php-5.2.9/main (downloaded directly from PHP.net, unchanged, no make or install commands) And checked: printenv PATH OK. Ran again, but it shows still the same error: php.h not found. I appreciate your help, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cygwin - compilation of PHP extension
Martin Zvarík napsal(a): Per Jessen napsal(a): Martin Zvarík wrote: Hi, I am totally new in compiling under cygwin. I need to compile an PHP extension, and this is what I figured so far: I wouldn't expect cygwin to be that different to a real Linux environment - how about: untar the extension cd dir phpize ./configure make make install Hmm, it seemed all working, but... $ make ...created 4 files: /usr/local/src/extension/.libs/extension.a, extension.la.lnk, extension.o (280 kB, the other 3 had few bytes, *.a, *.la, *.lai) $ make install ... created: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ one file *.a (8 bytes !arch) So, I did: $ gcc -shared -o extname.dll extension.o (the 280 kB file) And it showed 100's of errors like undefined reference to '_php_printf' Can you help? I searched, but I am helpless. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cygwin - compilation of PHP extension
Per Jessen napsal(a): Martin Zvarík wrote: Hi, I am totally new in compiling under cygwin. I need to compile an PHP extension, and this is what I figured so far: I wouldn't expect cygwin to be that different to a real Linux environment - how about: untar the extension cd dir phpize ./configure make make install you're the man, phpize did the job thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] SQL for counting comments - is this smart?
Chris napsal(a): Martin Zvarík wrote: Is it smart to use all of this on one page? Or should I rather do one SQL and let PHP count it? $q = $DB-q(SELECT COUNT(*) FROM comments); $int_total = $DB-frow($q); $q = $DB-q(SELECT COUNT(*) FROM comments WHERE approved IS NULL); $int_waiting = $DB-frow($q); $q = $DB-q(SELECT COUNT(*) FROM comments WHERE approved=0); $int_deleted = $DB-frow($q); $q = $DB-q(SELECT COUNT(*) FROM comments WHERE approved=1); $int_approved = $DB-frow($q); $q = $DB-q(SELECT COUNT(*) FROM comments WHERE approved=2); $int_banned = $DB-frow($q); Each one of these probably going to scan the whole table because the approved column isn't going to be selective enough to use an index. You might be better off doing: select approved, count(*) from comments group by approved; then in php separating them out: while ($row = $DB-frow($q)) { switch ($row['approved']) { case null: $waiting = $row['count']; break; case 0: $deleted = $row['count']; break; case 1: $approved = $row['count']; break; } } $total = $waiting + $approved + $deleted; Duh, of course, thanks :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Which hashing algorithm is best to check file duplicity?
I want to store the file's hash to the database, so I can check next time to see if that file was already uploaded (even if it was renamed). What would be the best (= fastest + small chance of collision) algorithm in this case? Is crc32 a good choice? Thank you in advance, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Which hashing algorithm is best to check file duplicity?
Fastest depends mostly on the size of the file, not the algorithm used. A 2gig file will take a while using md5 as it will using sha1. Using md5 will be slightly quicker than sha1 because generates a shorter hash so the trade-off is up to you. $ ls -lh file.gz 724M 2008-07-28 10:02 file.gz $ time sha1sum file.gz 4ae7bd1e79088a3e3849e17c7be989d4a7c97450 file.gz real0m3.398s user0m3.056s sys0m0.336s $ time md5sum file.gz 16cff7b95bcb5971daf1cabee6ca4edd file.gz real0m2.091s user0m1.744s sys0m0.328s $ time sha1sum file.gz 4ae7bd1e79088a3e3849e17c7be989d4a7c97450 file.gz real0m3.332s user0m2.988s sys0m0.344s $ time md5sum file.gz 16cff7b95bcb5971daf1cabee6ca4edd file.gz real0m2.136s user0m1.776s sys0m0.348s Aha, thanks for sharing the benchmark. I'll go with MD5() -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: The PHP filter class I'm working on (securiity)
What's the point? If user puts in a search input something like scriptalert('I am super hacker');/script And the website outputs: You are searching for: script/script then what? it shows an alert(), who cares? I, as an owner of this website, don't mind AT ALL. Aha, forget to mention the XSS on MySQL or inside comments right? Isn't mysql_real_escape_string(), strip_tags() enough? Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: The PHP filter class I'm working on (securiity)
Jochem Maas napsal(a): Martin Zvarík schreef: What's the point? If user puts in a search input something like scriptalert('I am super hacker');/script And the website outputs: You are searching for: script/script then what? it shows an alert(), who cares? replace the alert() with some code that passes the cookie to a hacker controlled domain. now create a URL that includes the given javascript: echo 'http://mzvarik.com/foo?somevar='.urlencode('script type=text/javascript/*evil code here*//script'); send url to unsuspecting users of your site. anyone know clicks the URL has just had their cookies hijacked. still don't mind? AHA, I see. There's a PHP configuration that cookies are available on HTTP side only, that should provide the desired security in this case, right?
Re: [PHP] Re: The PHP filter class I'm working on (securiity)
Michael A. Peters napsal(a): Martin Zvarík wrote: What's the point? The point is detailed on the (not fully complete) description page I just put up - http://www.clfsrpm.net/xss/ Yeah, I just had a quick look... The browser will only execute script in source files from the white-listed domains and will disregard everything else, including embedded and inline scripts. wtf, can't you just take care of the INPUT and type strip_tags($_GET['my_name']) ?? This won't be implemented in any browser, can't be. Namely, a lot of people who have web sites do not have the technical capability to prevent their site from being used as an XSS vector to attack other people. By setting a simple security policy, browsers that implement CSP can see that something funny is being tried because the web site has instructed the browser it will not try to do that action from that domain. By implementing CSP server side, even users without CSP enabled browsers (just about everyone currently) will have some measure of protection. That's the point. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: The PHP filter class I'm working on (securiity)
Jan G.B. napsal(a): 2009/3/15 Martin Zvarík mzva...@gmail.com: The browser will only execute script in source files from the white-listed domains and will disregard everything else, including embedded and inline scripts. wtf, can't you just take care of the INPUT and type strip_tags($_GET['my_name']) ?? This won't be implemented in any browser, can't be. strip_tags() isn't good. it only removes correct markup, IIRC. for example b foo wouldn't be interpreted as a valid tag. Often XSS attackers split their scripts to bypass such filters, common regex patterns and alike. bypassing strip_tags() is easy. the bad thing: browsers tend to accept a lot of mad markup. take a look at this: http://ha.ckers.org/xss.html regards Forget to mention htmlspecialchars(), that should take care of everything. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP/Apache: script unexpectedly invoked multiple times in parallel every 30 secs.
Marc Venturini napsal(a): Hi all, I wrote a PHP script running in Apache which takes more than 30 seconds to complete. It uses set_time_limit() to extend the time it is allowed to run. The script generates thumbnails from a list of images. Upon completion, the script redirects the browser to another page using HTTP headers. If you die() at the end of the script and don't redirect does it continue this auto-30-seconds execution? On my local machine (Windows + EasyPHP), the script runs as expected and completes after a few minutes. I observe an unexpected behavior on my production web server: - The script runs as expected for the first 30 seconds. - After 30 seconds, the same script with the same parameters starts again in a new thread/process. The initial thread/process is *not* interrupted, so 2 threads/processes run in parallel, executing the same sequence of operations with a 30 time shift. - The same scenario happens every 30 seconds (i.e.: at 030, 100, 130, and so on), multiplying the parallel threads/processes. - The browser keeps on loading while the above happens. - After some time, the browser displays a blank page and all the threads/processes stop. I assume this is due to resources exhaustion, but I have no means to check this assumption. I deduced the above reading a text file in which I log the sequence of called functions. It all seems as a redirection / unclosed loop problem. Unfortunately I have no access *at all* to my production web server configuration (shared hosting, no documentation). I cannot even read the configuration settings. While I'm considering moving to another host, I'd be extremely pleased to have an explanation of the observed behavior. I have browsed the mailing list archives and looked for an explanation in other forums to no avail. This thread may deal with the same issue but does not include any explanation or solution: http://www.networkedmediatank.com/showthread.php?tid=17140 Thanks for reading, and please do not hesitate to ask for further explanations if what I'm trying to achieve was not clear! Why it works on your local server is probably caused by different versions/settings, but I bet there's an error somewhere in your script. Consider sending it here, I'll take a look. Cheers, Marc. Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Question about template systems
Matthew Croud napsal(a): Hello, First post here, I'm in the process of learning PHP , I'm digesting a few books as we speak. I'm working on a content heavy website that provides a lot of information, a template system would be great and so i've been looking at ways to create dynamic data with a static navigation system. So far, using the require_once(); function seems to fit the bill in order to bring in the same header html file on each page. I've also looked at Smartys template system. If you are looking for performance stick to Blitz PHP - the only true template system. Martin Thanks for any help you can provide :) Matt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax
Chris napsal(a): Terion Miller wrote: Need syntax help when it comes to using a timestamp. What I'm trying to say in my query WHERE clause is to select records if the timestamp on the record is in the past 7 days from NOW() $query .= WHERE stamp NOW()-7 ; I have no clue here on this the lay language is WHERE stamp is within the past 7 days how to php that? lol Has nothing at all to do with php. http://dev.mysql.com/doc/refman/5.0/en/datetime.html http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html $query .= WHERE stamp .(time()-7*3600*24); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax
Micah Gersten napsal(a): Martin Zvarík wrote: Chris napsal(a): Terion Miller wrote: Need syntax help when it comes to using a timestamp. What I'm trying to say in my query WHERE clause is to select records if the timestamp on the record is in the past 7 days from NOW() $query .= WHERE stamp NOW()-7 ; I have no clue here on this the lay language is WHERE stamp is within the past 7 days how to php that? lol Has nothing at all to do with php. http://dev.mysql.com/doc/refman/5.0/en/datetime.html http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html $query .= WHERE stamp .(time()-7*3600*24); Using something like that is disastrous for DST and Leap Seconds... Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com I personally wouldn't even use the timestamp type for this column, but 'datetime' instead. Anyway, I don't think he is worried about DST, which I don't think is a problem when you have the right settings - nor second precision.
Re: [PHP] Unique User Hashes
tedd napsal(a): At 1:49 AM +0100 2/19/09, Martin Zvarík wrote: Guys, I have not seen a poll where you need to input your email address - and if I would I would not vote - because it's a waste of my time... if you want me to vote you do everything you can to make it as pleasant as possible -- certainly that isn't requirement of an email validation. Okay, so you don't see the problem. It might do you well to try to figure out what we're talking about. Cheers, tedd :) What world do you live in? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unique User Hashes
tedd napsal(a): At 5:10 PM +0100 2/19/09, Martin Zvarík wrote: tedd napsal(a): At 1:49 AM +0100 2/19/09, Martin Zvarík wrote: Guys, I have not seen a poll where you need to input your email address - and if I would I would not vote - because it's a waste of my time... if you want me to vote you do everything you can to make it as pleasant as possible -- certainly that isn't requirement of an email validation. Okay, so you don't see the problem. It might do you well to try to figure out what we're talking about. Cheers, tedd :) What world do you live in? The one that tries to understand and solve the problems presented. Cheers, tedd If that is true - you wouldn't say, you would do at least one of those things. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unique User Hashes
tedd napsal(a): At 5:28 PM +0100 2/19/09, Martin Zvarík wrote: tedd napsal(a): At 5:10 PM +0100 2/19/09, Martin Zvarík wrote: tedd napsal(a): At 1:49 AM +0100 2/19/09, Martin Zvarík wrote: Guys, I have not seen a poll where you need to input your email address - and if I would I would not vote - because it's a waste of my time... if you want me to vote you do everything you can to make it as pleasant as possible -- certainly that isn't requirement of an email validation. Okay, so you don't see the problem. It might do you well to try to figure out what we're talking about. Cheers, tedd :) What world do you live in? The one that tries to understand and solve the problems presented. Cheers, tedd If that is true - you wouldn't say, you would do at least one of those things. You're trolling -- welcome to my kill file. tedd My point is: don't say to others they don't see a problem, just because YOU see it differently (you said we, but that's basically just you only :))... plus, in this case, you are in my professional opinion wrong - the few (if any) of basic polls that require an email verification is its proof. Btw. google free temporary email address to see how unique email addresses really are - in case you meant it in reference to the poll voting - where you care about uniqueness of votes = people. ALOHA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unique User Hashes
Chris napsal(a): Martin Zvarík wrote: tedd napsal(a): At 5:28 PM +0100 2/19/09, Martin Zvarík wrote: tedd napsal(a): At 5:10 PM +0100 2/19/09, Martin Zvarík wrote: tedd napsal(a): At 1:49 AM +0100 2/19/09, Martin Zvarík wrote: Guys, I have not seen a poll where you need to input your email address - and if I would I would not vote - because it's a waste of my time... if you want me to vote you do everything you can to make it as pleasant as possible -- certainly that isn't requirement of an email validation. Btw. google free temporary email address to see how unique email addresses really are - in case you meant it in reference to the poll voting - where you care about uniqueness of votes = people. So instead of trolling, offer a better suggestion. Chris, if you would read the whole thread (my first comment), I bet you would consider more wisely your patronizing comment. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unique User Hashes
Chris napsal(a): Martin Zvarík wrote: Chris napsal(a): Martin Zvarík wrote: tedd napsal(a): At 5:28 PM +0100 2/19/09, Martin Zvarík wrote: tedd napsal(a): At 5:10 PM +0100 2/19/09, Martin Zvarík wrote: tedd napsal(a): At 1:49 AM +0100 2/19/09, Martin Zvarík wrote: Guys, I have not seen a poll where you need to input your email address - and if I would I would not vote - because it's a waste of my time... if you want me to vote you do everything you can to make it as pleasant as possible -- certainly that isn't requirement of an email validation. Btw. google free temporary email address to see how unique email addresses really are - in case you meant it in reference to the poll voting - where you care about uniqueness of votes = people. So instead of trolling, offer a better suggestion. Chris, if you would read the whole thread (my first comment), I bet you would consider more wisely your patronizing comment. Use the ip - which we've all said is useless. Where's the better suggestion? Nevermind, I was wrong - thank you for making me realize I am wasting time here. This useless IP solution is used by 80% of websites. I was trying to convice you that requirement of an email validation is just, let's say, unwise. So, don't bark if you don't agree.
Re: [PHP] Unique User Hashes
Ashley Sheridan napsal(a): On Thu, 2009-02-19 at 23:34 +0100, Martin Zvarík wrote: Chris napsal(a): Martin Zvarík wrote: Chris napsal(a): Martin Zvarík wrote: tedd napsal(a): At 5:28 PM +0100 2/19/09, Martin Zvarík wrote: tedd napsal(a): At 5:10 PM +0100 2/19/09, Martin Zvarík wrote: tedd napsal(a): At 1:49 AM +0100 2/19/09, Martin Zvarík wrote: Guys, I have not seen a poll where you need to input your email address - and if I would I would not vote - because it's a waste of my time... if you want me to vote you do everything you can to make it as pleasant as possible -- certainly that isn't requirement of an email validation. Btw. google free temporary email address to see how unique email addresses really are - in case you meant it in reference to the poll voting - where you care about uniqueness of votes = people. So instead of trolling, offer a better suggestion. Chris, if you would read the whole thread (my first comment), I bet you would consider more wisely your patronizing comment. Use the ip - which we've all said is useless. Where's the better suggestion? Nevermind, I was wrong - thank you for making me realize I am wasting time here. This useless IP solution is used by 80% of websites. I was trying to convice you that requirement of an email validation is just, let's say, unwise. So, don't bark if you don't agree. So you;'e saying that unless we agree with you, not to mention anything? Ash www.ashleysheridan.co.uk I meant: You don't have to bark, if you don't agree. = We can discuss.
[PHP] Re: shell_exec - asynchronous would be cool!
German Geek napsal(a): Hi all, A while ago, i had a problem with shell_exec: I was writing some code to execute imagemagick to convert a bunch of images. This could take ages to execute and the page therefore ages to load. The solution was to get a linux box and append a at the end to do it in the background or make a ajax call to a page that does it in batches. The problem was really that i had to write a file that is then checked against to know when it was finished... Not very pretty. Anyway, would it be possible to make a new shell_exec_async function in php that just starts the process, puts it to the background and calls a callback function or another script with parameters when it finishes? I guess a callback function is not really going to work because the page needs to finish execution. It should be possible with PHP forking though. Anyway, just an idea. Regards, Tim Tim-Hinnerk Heuer http://www.ihostnz.com Emo Philips - I was the kid next door's imaginary friend. I would exec a script on linux (= multi-thread). That script would do anything what is needed (imagemagick) and then check if there are any processes running on the same session. If NOT than it would call (could be HTTP request also) a PHP script on the windows server. What's the deal? Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unique User Hashes
Guys, I have not seen a poll where you need to input your email address - and if I would I would not vote - because it's a waste of my time... if you want me to vote you do everything you can to make it as pleasant as possible -- certainly that isn't requirement of an email validation. Andrew Ballard napsal(a): On Wed, Feb 18, 2009 at 4:07 PM, tedd tedd.sperl...@gmail.com wrote: At 3:54 PM -0500 2/18/09, Andrew Ballard wrote: You're missing my point. Yes, e-mail addresses are unique delivery points. They can not, however, uniquely identify one and only one person -- which is what one would need in the OP's situation. Andrew Andrew: No -- I did not miss you point, your point is obvious. I simply said that if it were me, this is what I would do. I also added that my method ensures one vote per email address. I did not say that an email address ensures one person. I am sure we both agree. Cheers, tedd It all depends on the domain of the problem in which one is working. I agree that you could restrict it to one vote per e-mail address. Obviously, I can't speak for the OP. I've worked with applications where e-mail addresses were limited to a single domain and every user had one, and in those cases the e-mail address made an excellent key. I have also worked in situations where the correlation between people and e-mail addresses was n:m rather than 1:1 or even 1:m. In those cases, the e-mail address was totally unusable as any kind of key. Then there is a broader scope where one decides that, given the lack of a better solution, the overall population is broad enough to tolerate the imperfections since there is no better solution. To go back to what I said in my first reply on this thread, I consider that more about polling and statistics than voting. I'll be happy to let it go at that, though, since we all appear to be in agreement that there is no magic solution; only those that are close enough for government work. :-) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Unique User Hashes
I don't think there is more precise way to determine the visitor than by the IP address, and it sucks indeed. You can't rely on the cookies, can't rely on what's in 'HTTP_USER_AGENT' ... as said: registration could be a solution - but it's an annoyance for the visitors - although you can try OpenID service. NOTE: The HTTP_X_FORWARDED_FOR can contain more IPs, so this is what I use: function getIP() { static $clientIP; if (isset($clientIP)) return $clientIP; if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $forwarded = $_SERVER['HTTP_X_FORWARDED_FOR']; $ipaddr = $forwarded; $i = 0; while (($pos = strrpos($forwarded, ',', $i)) !== false) { // nekdy jich muze byt vice $ipaddr = substr($forwarded, $pos+1); if (!$ipaddr) { $forwarded = substr($forwarded, 0, $pos); } elseif (preg_match('/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/', $ipaddr)) { return $clientIP = $ipaddr; } } } return $clientIP = $_SERVER['REMOTE_ADDR']; } I doubt you find better solution than what you use now, but let me know if so, Martin Ian napsal(a): Hi, I am busy building an application that requires one time voting and to get around the user deleting a cookie that I set im keeping a hash on my side which I then try match before allowing anything. This is how I currently generate my hash: /* Get vars */ $browser = $_SERVER['HTTP_USER_AGENT']; $ip = $_SERVER['REMOTE_ADDR']; $real_client_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; if(!empty($real_client_ip)) $name = gethostbyaddr($real_client_ip); else $name = gethostbyaddr($ip); /* Return generated hash */ return md5($browser.$ip.$real_client_ip.$name); Now thats not ideal because you can just change your user agent and vote again - but IP isnt good enough either because in South Africa due to the poor internet we all connect to international sites via a series of Transparent proxies which makes everyone seem to come from one IP. Anyone had to deal with this in the past and does anyone have any suggestions/ideas as to how I could better this setup? Many thanks in advance, Ian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Files redirect - using PHP and .htaccess
Hi, there are two choices (example): 1) file_redirect.php?src=file/root.jpg --- shows an image 2) .htaccess --- if is requested file/root.jpg than redirect to xyzfile/root.jpg In both cases I can restrict the access to some files only. If we talk about PHP, the file/image.jpg can be directed to xyzfile/image.jpg - and the client won't know. BUT if we talk about .htaccess - can the client find out where it really points out? For example file/image.jpg will be directed to xyzfile/image.jpg --- I suppose it sends a response to the browser and tells him the new path which it should request, am I right? If so, than it's not really secure, since the user will be able to test and try all other filenames and get somewhere I don't want him to go - I know I might be too careful, BUT I am interested how PROs do this. Your comments will be appreciated, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Files redirect - using PHP and .htaccess
Martin Zvarík napsal(a): Hi, there are two choices (example): 1) file_redirect.php?src=file/root.jpg --- shows an image 2) .htaccess --- if is requested file/root.jpg than redirect to xyzfile/root.jpg In both cases I can restrict the access to some files only. If we talk about PHP, the file/image.jpg can be directed to xyzfile/image.jpg - and the client won't know. BUT if we talk about .htaccess - can the client find out where it really points out? For example file/image.jpg will be directed to xyzfile/image.jpg --- I suppose it sends a response to the browser and tells him the new path which it should request, am I right? If so, than it's not really secure, since the user will be able to test and try all other filenames and get somewhere I don't want him to go - I know I might be too careful, BUT I am interested how PROs do this. Your comments will be appreciated, Martin AHA, from what I've just read, the .htaccess is server-side, so the client won't know the real directory. Can somebody confirm? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Speed Opinion
Nathan Rixham napsal(a): Ashley Sheridan wrote: On Thu, 2009-02-05 at 09:44 +1100, Chris wrote: PHP wrote: Hi all, I am seeking some knowledge, hopefully I explain this right. I am wondering what you think is faster. Say you have 1000 records from 2 different tables that you need to get from a MySQL database. A simple table will be displayed for each record, the second table contains related info for each record in table 1. Is if faster to just read all the records from both tables into two arrays, then use php to go through the array for table 1 and figure out what records from table 2 are related. Or, you dump all the data in table 1 into an array, then as you go through each record you make a database query to table 2. Make the db do it. PS: I know I can use a join, but I find anytime I use a join, the database query is extremely slow, I have tried it for each version of mysql and php for the last few years. The delay difference is in the order of 100x slower or more. Then you're missing indexes or something, I've joined tables with hundreds of thousands of records and it's very fast. -- Postgresql php tutorials http://www.designmagick.com/ I've used joins on tables with millions of rows, and it's still not been too slow to use. Admittedly it was an MSSQL database, which I've always found to be slower, but MySQL was built to be a relational database, and can handle many many millions of records quite happily. The slowdown you experienced is either not using indexes on tables, or the way you were displaying/manipulating those results from within PHP. Ash www.ashleysheridan.co.uk and if you use spatial indexes and points instead of integers you can join on the biggest of databases with literally no perfomance hit, same speed regardless of table size :p (plus cos a point has two values you can use one for id and the other for timestamp ;) regards ps: i've said this many times before, but not for like 6 months so time for another reminder MySQL supports spatial extensions to allow the generation, storage, and analysis of geographic features. So, I use spatial indexes when creating a geographic map? Is it good for anything else? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cgi vs php
Thodoris napsal(a): Y In cgi i can use perl ,c etc suppose i use perl now how efficiency differs? How cgi written in perl and php is differ in working in context of web service? other difference?. but their differ. On Thu, Feb 5, 2009 at 6:45 PM, Jay Blanchard jblanch...@pocket.com wrote: [snip] can anybody tell me the benefits of php over cgi or vice versa? i need to compare both? [/snip] CGI is a gateway to be used by languages PHP is a language First of all try not to top post this is what we usually do here. Well CGI is a standard protocol implemented by many programming languages. You may start googling to find about it but this is a start: http://en.wikipedia.org/wiki/Common_Gateway_Interface Both Perl and PHP can work with CGI but working with Perl-CGI is not something that we should discuss in this list since this is a *PHP* list. IMHO you should start reading some aspects of web development to make some things clear before start asking questions in the lsit. This will improve your understanding and it help us to make suggestions. I admire your calmness. Such a descriptive reply for someone who doesn't think before asking. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Make New-Age Money Online with Google
Ashley Sheridan napsal(a): On Sat, 2009-01-24 at 10:14 +0200, Dora Elless wrote: That's why I am sending this email only to people I know and care about. And they send to a mailing list. Come again? Ash www.ashleysheridan.co.uk The sad thing though is that there will be always people who believe this shit and pays... Like my dad bought a little book Take off your glasses for $10 and he received 2 papers saying: sun is our best friend, look right into it and it will heal your eyes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP webhosting - USA
Hi, I currently host my site by Powweb, and I am WANT to change it - can you guys recommend me something good? Powweb's website looks awesome and it's the best marketing I think I had saw! After a minute it makes you think there is NO better hosting - and it's a LIE. What happened to me? - database connection were exceeded, I read many people had problems with their phorums not working etc., the solution: I put a message to the visitor that he has to wait (it was not frequent so I didn't care much) - my client stopped receiving orders, he called me after a week something is wrong. I found out that Powweb changed a MySQL settings, which nobody informed me about - they restricted a JOIN limit max to 3, the mysql_query SQL thus did not work and orders were not storing for 7 days! - the suport is HORRIBLE - they don't give you email, but they have this ONLINE support, meaning: you wait 10-20 minutes on queue, and then they talk to you like a robots and usually tell you something you already know. - now they automatically changed all my passwords so they can keep me secure! what's cool is that I cannot change it back to what I have! Hey, the chance of getting me hit by bus is higher than someone cracking my 15 letter password with numbers! Thank you powweb for keeping me secure. Thanks for reading my story, now, does someone know a better hosting alternative? Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP webhosting - USA
That's an awful looking website, but thanks for reply. I am looking for rather a US hosting company. Andrew Williams napsal(a): go to www.willandy.co.uk http://www.willandy.co.uk best value for money On Sat, Jan 24, 2009 at 3:03 PM, Martin Zvarík mzva...@gmail.com mailto:mzva...@gmail.com wrote: Hi, I currently host my site by Powweb, and I am WANT to change it - can you guys recommend me something good? Powweb's website looks awesome and it's the best marketing I think I had saw! After a minute it makes you think there is NO better hosting - and it's a LIE. What happened to me? - database connection were exceeded, I read many people had problems with their phorums not working etc., the solution: I put a message to the visitor that he has to wait (it was not frequent so I didn't care much) - my client stopped receiving orders, he called me after a week something is wrong. I found out that Powweb changed a MySQL settings, which nobody informed me about - they restricted a JOIN limit max to 3, the mysql_query SQL thus did not work and orders were not storing for 7 days! - the suport is HORRIBLE - they don't give you email, but they have this ONLINE support, meaning: you wait 10-20 minutes on queue, and then they talk to you like a robots and usually tell you something you already know. - now they automatically changed all my passwords so they can keep me secure! what's cool is that I cannot change it back to what I have! Hey, the chance of getting me hit by bus is higher than someone cracking my 15 letter password with numbers! Thank you powweb for keeping me secure. Thanks for reading my story, now, does someone know a better hosting alternative? Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP webhosting - USA - conclusion
I should have said in the beginning it's a small website and I am not looking for a dedicated server. Howewer, I decided to move to Lypha.com Thanks for all your fruitful* comments :) Martin PS: PHP mailgroup rulz *) that was in dictionary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: =.='' what wrong ? just simple code, however error.
It works as expected on my PHP 5.2.4 LKSunny napsal(a): ? $credithold = 100; for($i=1;$i=1000;$i++){ $credithold -= 0.1; echo $creditholdbr /; } //i don't know why, when run this code, on 91.3 after expect is 91.2, however..91.2001 //who can help me ? and tell me why ? //Thank You. ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] get_browser() too slow
Hello, anyone has a good function for getting a user's browser, OS and crawler detection ? I have looked at google etc, but I ran only into long list of ineffective ereg()s functions or not checking if it's crawler... Is it possible to make an array list and just check using strpos() each one? The basic browsers for Win, Mac, and Linux - others would be unknown. And then only to check for OS. I tryed get_browser() but that thing is way too slow for my needs: 0.09 sec. Thanks in advance, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: get_browser() too slow
Martin Zvarík napsal(a): Hello, anyone has a good function for getting a user's browser, OS and crawler detection ? I have looked at google etc, but I ran only into long list of ineffective ereg()s functions or not checking if it's crawler... Is it possible to make an array list and just check using strpos() each one? The basic browsers for Win, Mac, and Linux - others would be unknown. And then only to check for OS. I tryed get_browser() but that thing is way too slow for my needs: 0.09 sec. Thanks in advance, Martin Hmm... This one is decent: http://techpatterns.com/downloads/scripts/browser_detection_php_ar.txt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] IP and gethostbyaddr() --- difference?
Hello, I am doing a view stats for my website. I've seen that many of such statistic scripts store two values to identify the visitor: IP and getHostByAddr(IP) I've been searching..., but I don't get why the IP address isn't enough by itself?! What is the getHostByAddr() = Internet host name for? When IP changes the hostname does too and vice-versa? What's the difference between these two values? And why do I need both of them? Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: operators as callbacks?
Joe napsal(a): Is it possible to use a PHP operator as a callback? Suppose I want to add two arrays elementwise, I want to be able to do something like this: array_map('+', $array1, $array2) but this doesn't work as + is an operator and not a function. I can use the BC library's math functions instead: array_map('bcadd', $array1, $array2) but that is an ugly hack that might break if the library is not available. I can create an anonymous function: array_map(create_function('$a, $b', 'return $a + $b;'), $array1, $array2) but that seems really unnecessarily verbose. Is there any simple clean way to do it? Thanks, array_sum() ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Secure redirection?
I might have not read your post thorougly, but it's important to know, that Header sends a HTTP request to the browser - you are not hiding the destination URL. So, calling header(location: in PHP is basically same as redirect using JS. Martin Zoran Bogdanov napsal(a): Hi, I'm building a login system with AJAX/PHP/MySQL. I have worked everything out... AJAX is sending request to a php login script (login.php) who if authentication passes initializes the session and sends the header using header(Location : registered_user_area.php); The whole system works great without AJAX, but when I put AJAX in the story I ahve one problem: 1.When the user is successfully authenticated the login.php sends the header, but the AJAX XMLHttpRequest call is still in progress waiting for a PHP response. So when PHP using the header function redirects to another page that page is outputed to the login form... My PHP login snippet is: if ($res_hash == $u_pass) { $logged_user = $sql_execution-last_query_result-user; $sql_execution-exec_query(DELETE FROM seeds,false); $sql_execution-db_disconnect(); session_start(); $_SESSION['user'] = $logged_user; $host = $_SERVER['HTTP_HOST']; $url = rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . '/mpls/index.php'; header(Location: http://$host$url;);//--That page ($host$url) is outputed in the login form... exit(); } else { $sql_execution-exec_query(DELETE FROM seeds WHERE id=$row-id,false); $sql_execution-db_disconnect(); echo 'BLS';//--This is sent when the password/username is wrong exit(); } ??? Any help greatly appreciated Thank you! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to kill a session by closing window or tab clicking on X?
Afan Pasalic napsal(a): hi. I'm sorry for posting this more javascript then php question, but it's somehow php related. here is the issue: very often people close the window/tab without logging out. I need solution how to recognize when [x] is clicked (or File Close) and kill the session before the window/tab is closed. few years ago, before firefox and tabs, I solved this by javascript and onClose() as a part of body tag. now, it doesn't work anymore. any suggestion/opinion/experience? thanks afan You might wanna check this out: http://cz2.php.net/ignore_user_abort -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamically creating multi-array field
:-D :-D :-D :-D :-D :-D :-D :-D ok :) Robert Cummings napsal(a): On Mon, 2008-10-27 at 02:09 -0400, Robert Cummings wrote: On Sun, 2008-10-26 at 22:39 -0700, Jim Lucas wrote: Even slimmer ?php $node = '[5][1][]'; $text = 'some text'; preg_match_all('|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER); $recursive = $matches[1]; $recursive = array_reverse($recursive); foreach ( $recursive AS $index ) { $out = array(); $out[(int)$index] = $text; $text = $out; } print_r($out); ? It's buggy... you need to test for an blank string to properly handle the append to array case when the index is blank []. ?php $node = '[5][1][]'; $text = 'some text'; preg_match_all( '|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER ); $recursive = $matches[1]; $recursive = array_reverse($recursive); foreach( $recursive AS $index ) { $out = array(); if( trim( $index ) === '' ) I probably shouldn't trim... since we're not supporting quotes in any way, it might be desirable to have a key that is one or more spaces... for whatever reason :) Personally, I have a similar implementation I use all the time, but I use forward slashes to separate keys. ?php hashPathSet( $hash, 'this/is/the/hash/path', $value ) ? Cheers, Rob. { $out[] = $text; } else { $out[$index] = $text; } $text = $out; } print_r( $out ); ? I also removed the (int) cast since integer keys will be cast automatically by PHP and then it will have support for text keys also. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create/write to psd file
What I know is that you can control GIMP over the command line = you can use PHP to do this. Though I guess GIMP doesn't support PSD files, I had to express myself anyways. vuthecuong napsal(a): Hi all Is there a way to create/read/write to psd file? (photoshop format) I would like to hear opinion form you: Do you recommend gd2 or imageMagick to perform this task? and why thanks in advanced -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamically creating multi-array field
2008/10/26 Martin Zvarík [EMAIL PROTECTED]: PHP Version 5.2.4 ? $node = '[5][1][]'; ${'tpl'.$node} = 'some text'; print_r($tpl); // null ? I really don't like to use the EVAL function, but do I have choice?? This sucks. Hi there, While this question can spur some neat solutions, it raises a red flag in that if you need to do this, you probably need to rethink things a bit. In cases like this it is easier for people to help if you describe the actual problem you are trying to solve, not how you think it needs to be solved. It could be that you don't really need weird (but beautiful, like Jim's idea) solutions. If you explain why you believe that you need to do this in the first place, maybe someone can suggest something else which doesn't require a weird solution (however beautiful). Torben Hi, I am aware of this, but explaining my problem in this case would take me an hour --- and eventually would lead to a) misunderstanding, b) weird solution, c) no solution... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamically creating multi-array field
PHP Version 5.2.4 ? $node = '[5][1][]'; ${'tpl'.$node} = 'some text'; print_r($tpl); // null ? I really don't like to use the EVAL function, but do I have choice?? This sucks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamically creating multi-array field
No offense, but I thought it's obvious what I want to print. print_r() shows null, and it should print what you just wrote = array field. It works when first defining with eval(): eval('$tpl'.$node.'=array();'); I guess that's the only way. Anyway, I appreciate your quick reply, Martin Jim Lucas napsal(a): Martin Zvarík wrote: PHP Version 5.2.4 ? $node = '[5][1][]'; ${'tpl'.$node} = 'some text'; print_r($tpl); // null ? I really don't like to use the EVAL function, but do I have choice?? This sucks. You should print the results that you are looking for! Are you looking for something like this? Array ( [5] = Array ( [1] = Array ( [0] = some text ) ) ) how is the $node string being created? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamically creating multi-array field
Nope, you have to use the eval() everytime for read/write. Martin Zvarík napsal(a): No offense, but I thought it's obvious what I want to print. print_r() shows null, and it should print what you just wrote = array field. It works when first defining with eval(): eval('$tpl'.$node.'=array();'); I guess that's the only way. Anyway, I appreciate your quick reply, Martin Jim Lucas napsal(a): Martin Zvarík wrote: PHP Version 5.2.4 ? $node = '[5][1][]'; ${'tpl'.$node} = 'some text'; print_r($tpl); // null ? I really don't like to use the EVAL function, but do I have choice?? This sucks. You should print the results that you are looking for! Are you looking for something like this? Array ( [5] = Array ( [1] = Array ( [0] = some text ) ) ) how is the $node string being created? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XCache, APC, Memcached... confused
Hi, I became confused after an hour trying to understand the PHP cache solutions. XCache, APC, eAccelerator and others are opcode cache systems... is memcache in the same category? or is it completely different? If I install for example XCache, set it for certain directory... it will automatically cache the website into the memory. What happens if the memory will get full? Thanks for explanation, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: XCache, APC, Memcached... confused
I guess the XCache everybody talks about is the open-source here: http://xcache.lighttpd.net/ But what about this: http://www.xcache.com/ ... is it the same author? :-O Martin Zvarík napsal(a): Hi, I became confused after an hour trying to understand the PHP cache solutions. XCache, APC, eAccelerator and others are opcode cache systems... is memcache in the same category? or is it completely different? If I install for example XCache, set it for certain directory... it will automatically cache the website into the memory. What happens if the memory will get full? Thanks for explanation, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: ZendOptimizer + APC
Jochem Maas napsal(a): anyone know whether running ZendOptimizer + APC simultaneously still causes allsorts of problems ... I know it did in the past but I can't find any very recent stuff about the issues online. I believe you should look up eAccelerator or XCache, which should work with ZendOptimizer. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XCache, APC, Memcached... confused
Thanks for reply Stut. So, the APC, XCache etc. doesn't work as FileCache and also doesn't decrease the number of database queries, since it is not caching the content... I see now, it is obvious that it would be very hard to run out of memory. -- Martin Stut napsal(a): On 22 Oct 2008, at 22:19, Martin Zvarík wrote: I became confused after an hour trying to understand the PHP cache solutions. XCache, APC, eAccelerator and others are opcode cache systems... is memcache in the same category? or is it completely different? Memcache is completely different in that it's not an opcode cache, it's an in-memory volatile cache for arbitrary key = value data with a client-server API. If I install for example XCache, set it for certain directory... it will automatically cache the website into the memory. What happens if the memory will get full? First of all you need to get it clear in your head what an opcode cache is actually doing. It does not cache the website, it caches the compiled version of the PHP scripts such that PHP doesn't need to recompile each file every time it's included which is the default way PHP works. Secondly, if you run out of memory you buy more!! But seriously, you'd need a very very very big site to have this problem. An opcode cache of a PHP script will generally take less space than the script itself. So if you're worried about it simply get the total size of all the PHP scripts in your site and you'll see that even on modest hardware you'll have a lot of headroom. Obviously you need to take other users of the server into account, especially if you're on a shared hosting account, but in most cases you won't have a problem. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XCache, APC, Memcached... confused
I am looking at the eAccelerator's website and I realize what got me confused: there is a function for OUTPUT CACHE, so it actually could cache the whole website and then run out of memory I guess... that means I would be able to store anything into the memory and reference it by a variable? are the variables accessible across the whole server? I still don't really understand, but I am trying... Stut napsal(a): On 22 Oct 2008, at 22:19, Martin Zvarík wrote: I became confused after an hour trying to understand the PHP cache solutions. XCache, APC, eAccelerator and others are opcode cache systems... is memcache in the same category? or is it completely different? Memcache is completely different in that it's not an opcode cache, it's an in-memory volatile cache for arbitrary key = value data with a client-server API. If I install for example XCache, set it for certain directory... it will automatically cache the website into the memory. What happens if the memory will get full? First of all you need to get it clear in your head what an opcode cache is actually doing. It does not cache the website, it caches the compiled version of the PHP scripts such that PHP doesn't need to recompile each file every time it's included which is the default way PHP works. Secondly, if you run out of memory you buy more!! But seriously, you'd need a very very very big site to have this problem. An opcode cache of a PHP script will generally take less space than the script itself. So if you're worried about it simply get the total size of all the PHP scripts in your site and you'll see that even on modest hardware you'll have a lot of headroom. Obviously you need to take other users of the server into account, especially if you're on a shared hosting account, but in most cases you won't have a problem. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: searching by tags....
Ryan S napsal(a): Hey, this the first time I am actually working with tags but it seems quite popular and am adding it on a clients requests. By tags I mean something like wordpress' implementation of it, for example when an author writes an article on babies the tags might be baby,babies, new borns, cribs, nappies or a picture of a baby can have the tags baby,babies, new born, cute kid, nappies the tags are comma separated above of course. The way i am doing it right now is i have sa an article or a pic saved in the db as article_or_pic_address text the_tags varchar(240) My question is, when someone clicks on any one of the tags, do i do a LIKE %search_term% search or...??? quite a few sites seem to have a very neat way of implementing this with (url rewriting?) something like http://sitename/blog/tags/tag-comes-here/ Any help in the form of advise, code or links would be appreciated. TIA. Cheers! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) The main point here is WHAT SHOULD BE THE BEST DB STRUCTURE. I got this feeling, from what I've read, that everybody wants to express themselves so much, that they talk about something they know at least a little about = SEO. To the TOPIC: I think normalization would be a killer. Imagine joining 3 tables (I really don't see more functionality here) OR just selecting from 1. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP tags - any reasons to close ?
Hi, I have seen some projects where people start with opening tag ?php but they DON'T close it with ? This is especially the case of CONFIG.php files... 1) What's the reason of that? 2) What if you would not close any 100% PHP files? 3) What's the reason of making an empty space after ? I've also seen this in some projects. Thanks for ideas, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] CMS-Blog system
Thank you for all the comments. Thanks for the WP tip: I don't know much about wordpress (it looks good), but I have tryed enough of open-source CMS to say that they are based on messy solutions (one for all = joomla) + it won't be free blog system, so I don't think using this free system would be fair. So, I will stick with separate databases for each user + central databases used for searches etc. I am pretty sure I am up for this wheel reinventing ;-) The only thing I am not strong in is the MySQL, but with you guys there is nothing impossible! Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] CMS-Blog system
Hi, I am working on CMS-Blog system, which will be using approx. 10 000 users. I have a basic question - I believe there are only two options - which one is better? 1) having separate databases for each blog = fast (problem: what if I will need to do search in all of the blogs for some article?) 2) having all blogs in one database - that might be 10 000 * 100 articles = too many rows, but easy to search and maintain, hmm? --- I am thinking of having some file etc. cms-core.php in some base directory and every subdirectory (= users subdomains) would include this cms-core file with some individual settings. Is there better idea? I appreciate your discussion on this topic. Martin Zvarik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Installing php_pgsql.dll to Apache - this is unreal
Hi, I am trying now for almost 2 hours to get this working: I had Apache and PHP with modules installed as CGI (also tryed as module). Now I added extension (in php.ini) php_pgsql.dll and also installed postgreSQL. And it shows me error when starting apache: module could not be found. The path is 100% ok, I also tryed 3 different php_pgsql.dll and one shown different error dialog with that i need to change some settings in postgre (but that was probably caused because that DLL file was for PHP 4, and I have PHP 5 - the newest version). Please help! Maritn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MIME email = Content-ID in CSS not supported
Hello, I am trying to send MIME type email with in message image attachments. It works OK when doing img src=cid:specialcode ...but it does not work in this div style=background:url(cid:specialcode) I am trying to have fading background, is there any way I can achieve this without using IMG tag? Thank you, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Something you can do with AJAX + PHP as well
lame... you can use javascript (which is faster) for this kind of stuff Mark napsal(a): Hey, I've made a nice video where you see ajax in combination with php. and it works really well although really is misspelled realy. Here is the video: http://magedb.mageprojects.com/videos/MageDB%202nd%20WIP%20demonstration%20with%20AJAX.mpeg Cool huh? Mark. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sending lots of emails - 2 choices - choose the best one
Hello-- I want to send email to 100+ recipients. Two choices I thought of: 1) once call mail() and use BCC, but the negative of this method is that every recipient in BCC has header To same (so I used to put my email in here - not email of one of the recipients). 2) several calls to mail() function with each recipient's emal Thanks for ideas, --Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Extract printable text from web page using preg_match
I believe it is better to use strpos() in this case because it's faster. ?php $start = strpos(strtolower($website_code), 'body'); // not necessary $end = strpos(strtolower($website_code), '/body'); $code = substr($website_code, $start, $end-$start); echo strip_tags($code); // clean text ? This is very simple, but there are many HTML parsers out there if you want to do more complex stuff. Martin --- M5 napsal(a): I am trying to write a regex function to extract the readable (visible, screen-rendered) portion of any web page. Specifically, I only want the text between the body tags, excluding any script or style tags within the document, also excluding comments. Has anyone here seen such a regex? Is it possible to do in one expression? ...Rene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP+MySQL website cache ? Yes/No
Hi, I am making an eshop and I am thinking about caching system. You understand, that it cannot be entirely cached because visitor has it's own shopping cart etc. So, my thought is to cache only few blocks like Categories, Navigation menu etc. by storing it to an HTML file. The advantages are that it doesn't have to query database and generate the HTML code again, but my question is: Is it good approach? Shouldn't we optimize database instead of restoring the data on harddrive? Thank you for ideas, Martin Zvarik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP+MySQL website cache ? Yes/No
I did a benchmark with and without caching to HTML file and it's like: 0.0031 sec (with) and 0.0160 sec (with database) I know these miliseconds don't matter, but it will have significant contribution in high-traffic website, won't it? Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP+MySQL website cache ? Yes/No
This benchmark is not very accurate, but you are right the database connection took most of the time. Shopping cart is stored in session - not in database. I am half-way doing the eshop I bet it will took much more than 0.01 sec to generate the final version. I was going to make this file cache system, but I relies that for each page like (?page=News, ?page=Products etc.) these HTML blocks (Navigation, Recommended) changes and that would mean I would have eventually like 50+ cached files. One way or another I will always need to connect do database (I cannot cache 300 products in 300 files, can I?). So I decided to put the cache in database table - For each URL Name (news/, products/ etc) a Cache (which will be an array of all HTML blocks). Martin [EMAIL PROTECTED] napsal(a): Quoting Martin Zvarík [EMAIL PROTECTED]: I did a benchmark with and without caching to HTML file and it's like: 0.0031 sec (with) and 0.0160 sec (with database) I know these miliseconds don't matter, but it will have significant contribution in high-traffic website, won't it? Martin --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Yes it will. And the 0.0129 seconds extra most of it is maybe to create the DB connection. Or are you using a persistent connection and reuseing it? This benchmark was that together with all other content of the page? I mean including your dynamic shopping cart etc? /Peter --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] read file local not remote
Difference: You don't call file as http://www.myweb.com/ but instead you use the path like c:\some.txt or ../some.txt etc. PHP 5 = echo file_get_contents(some.txt); PHP 4 = $fp = fopen(some.txt, r); echo fread($fp, filesize (some.txt)); fclose($fp); Another solution foreach(readfile(some.txt) as $line) echo $line; - Joker7 napsal(a): $url =www.mysite.ru/some.txt; $fa = fopen($url,r); /* $fa = fsockopen(http://mysite.ru;, 80, $num_error, $str_error, 30); if(!$fa) { print Weather is not available: $str_error ($num_error)\n; } else { fputs($fa,GET /some.txt HTTP/1.0\n\n); $answer=fgets($fa,128); I use the above code to read a file on remote server but now I need to read it on local server,question is how. Cheers Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL - HEAP table type
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? Thanks, Martin Zvarik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session - when they expirate ?
Hi, I was looking all over the internet and I don't understand when and how does the PHP session expirate. I suppose that it happens when the user is inactive. On my website I don't use cookies for session and it has standard php.ini configuration: session.gc_maxlifetime = 1440 session.gc_divisor = 100 session.gc_probability = 1 session.cache_expire = 180 So, does this mean, that if the visitor is 180 minutes inactive it automatically deletes the session ?? Thanks, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and dynamic creation and unique field names
Jason Gerfen wrote: I have come upon a problem and am not sure how to go about resolving it. I have an web form which is generated dynamically from an imported file and I am not sure how I can loop over the resulting post variables within the global $_POST array due to the array keys not being numeric. Any pointers are appreciated. You will never be ready for me. ~ Me Hahah... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Standard style of writing your code
Hi, I see everyone has its own way of writing the code. If there is 10 programmers working on same thing, it would be good if they would have same style of writing the PHP code. So, my question is: Is there anything what would define standard style of writing PHP code? Thanks, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: double lines
Barry wrote: clive wrote: Does the html textarea add in \r. Normally not. But the mailing function might do. Replace every \n with linbreak and every \r with linefeed with str_replace And probably you see where the problem is It's because of the operation system. Win32 and Linux works different. Linux adds extra line. Martin [Zend Certified] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL close connection, what's the purpose?
Hi, I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? MZ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
Richard Lynch wrote: On Fri, March 31, 2006 2:30 pm, Martin Zvarík wrote: I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? Yes, but... Suppose you write a script to read data from one MySQL server, and then insert it into 200 other MySQL servers, as a sort of home-brew replication (which would be really dumb to do, mind you)... In that case, you REALLY don't want the overhead of all 200 connections open, so after you finish each one, you would close it. There are also cases where you finish your MySQL work, but have a TON of other stuff to do in the script, which will not require MySQL. Close the connection to free up the resource, like a good little boy. :-) There also COULD be cases where your PHP script is not ending properly, and you'd be better off to mysql_close() yourself. So, does the connection close automatically at the end of the script ? My situation is following: I have a e-shop with a ridiculously small amount of max approved connections, so it gives an error to about 10% of my visitors a day, that the mysql connections were exceeded. Now, if I will delete the mysql_close() line, will that help me or not? My webhosting does not allow perminent connections either. Thanks, MZ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Upload with process meter
Hi, is it possible to upload a file and see the process of uploading (before the file is uploaded, there is something showing from 0% to 100%) using PHP and Javascript ? I saw some applications in Perl and mostly in JAVA, but I also found out something about some extension for PHP, but i think it wasn't complete at that time. Thanks for sharing your knowledge about this... :) Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Script Multitasking
Hi, I have a file, which I run using command line. The file I am running, runs several files using passthru(). What I realise is, that it runs each file in sequence and waits for its result. I need to run all files at once and they don't have to return the result to the main file. How do I do this? Any help appreciated! Martin Zvarik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Themes, pictures directory
Hi, I have a website, which uses themes. The web tree looks like this: * webroot o *themes* + default # images + red design # images o *index.php* Let's say I choose red design theme. All the pictures the theme is using will have URL like www.site.com/themes/default/images/bla.jpg. Is there a way how I can change it? So noone can see I have themes in that directory? I was thinking about: ShowImage.php?blah.jpg, but that is too slow... :-/ Any help appreciated. Martin