php-general Digest 27 Apr 2012 15:38:19 -0000 Issue 7792

Topics (messages 317711 through 317714):

Re: Should I check imput for bad chars in this case?
        317711 by: marco.behnke.biz

Re: Insert group by
        317712 by: Lester Caine
        317714 by: admin

Re: Serving a .dmg via readfile?
        317713 by: Matijn Woudt

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---

Simon Schick <simonsimc...@googlemail.com> hat am 27. April 2012 um 00:47
geschrieben:

> On Thu, Apr 26, 2012 at 3:59 PM, mirrys.net <mirrys....@gmail.com> wrote:
> > Thank you for your help Marco & Simon. No doubt, your code is much
> > cleaner and better.
> >
> > One more question, without any filter or something could be my
> > original code somehow compromised (mean some security bug)? Or rather
> > was a major problem in the possibility of a script crash?
> >
>
> Hi, Mirrys
>
> I personally can not see a security-hole at the first view ...
> Stuff in the global server-variable should only be set by the
> webserver and therefore it should be kind-of save (depending on the
> quality of the configuration of the webserver ;))

No, that is not correct. The Forwarded IP for example is generated by the
requesting Proxy Server and can therefor be manipulated.

But as far as your code simply writes this data into some textfile which is
never read inside you application or executed on your shell , there should
be no security reason.

>
> That was also the main reason why I would do a validation-check for this.
> Talking about a script-crash ... I don't know ... I just found this
> line in a comment for the function gethostbyaddress()
>
> > If you use gethostbyaddr() with a bad IP address then it will send an
error message to the error log.
>
> Bye
> Simon
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

--- End Message ---
--- Begin Message ---
Rick Dwyer wrote:
This is more of a MySQL question, but I'm hoping it can be answered here.
On one of my pages, I issue a SQL command to group data as such:

$sql='select count(*) as count, searchkeywords from searchkeywords group by 
searchkeywords order by count desc'

Works well... but I would like it to groups plurals with singular words as well.  So 
"hats" are grouped with "hat".

Since I'm doing a "group by" column name, I don't know that this can be done.

Any help is appreciated.

This IS a more appropriate question for ANY of the other database lists ;)

Normal practice is to create a search field that has your preferred search style, so add 'filtered_searchwords' and populate it with say a lower case copy of searchkeywords with any "s" or "'s" text removed. That is unless you want Hat's counted separately?

Expecting the database to process this type of filtering with any speed is being a bit hopeful. What any database does is processes raw fields fast, so providing extra data at insert or edit time is much more efficient than trying to do that process on every row of data later.

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
$sql='select count(*) as count, searchkeywords 
from searchkeywords 
group by searchkeywords 
having searchkeywords LIKE searchkeywords
order by count desc'


Ir this does not work for you explore the HAVING CLAUSE





-----Original Message-----
From: Rick Dwyer [mailto:rpdw...@earthlink.net] 
Sent: Thursday, April 26, 2012 8:23 PM
To: PHP-General
Subject: [PHP] Insert group by

Hello all.

This is more of a MySQL question, but I'm hoping it can be answered here.
On one of my pages, I issue a SQL command to group data as such:

$sql='select count(*) as count, searchkeywords from searchkeywords group by
searchkeywords order by count desc'

Works well... but I would like it to groups plurals with singular words as
well.  So "hats" are grouped with "hat".

Since I'm doing a "group by" column name, I don't know that this can be
done.

Any help is appreciated.

Thanks,
 
 --Rick



--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
On Thu, Apr 26, 2012 at 8:20 PM, Brian Dunning <br...@briandunning.com> wrote:
> Thanks, this suggestion from Dante completely solved the problem.
>
> Replaced:
>
> readfile('/var/www/mypath/My Cool Image.dmg');
>
> With:
>
> $fd = fopen ('/var/www/mypath/My Cool Image.dmg', "r");
> while(!feof($fd)) {
>    set_time_limit(30);
>    echo fread($fd, 4096);
>    flush();
> }
> fclose ($fd);
>
> It's now serving all files properly.
>

It is indeed a better solution, but as always, you should've checked
the apache logs first and you would've noticed an PHP error probably
about not enough memory..

--- End Message ---

Reply via email to