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
$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
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
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
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
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
?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
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:
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
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
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
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
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
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',
, 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
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.
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
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
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
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:
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
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
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
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
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
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
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
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?
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
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/)
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 ?
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
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
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
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
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
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
:-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,
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
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
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
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
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
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
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
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
, 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
? 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
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,
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
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
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
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
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
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:
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
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
?
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
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
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
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
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:
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
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
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
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
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
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
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
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
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
91 matches
Mail list logo