php-general Digest 5 Nov 2006 06:08:49 -0000 Issue 4441
Topics (messages 244210 through 244222):
Re: setlocale madness... please help!
244210 by: Jochem Maas
Re: Finding user's timezone
244211 by: Dotan Cohen
244212 by: Jochem Maas
Re: str_replace on words with an array
244213 by: Dotan Cohen
Pear
244214 by: Alain Roger
244215 by: Rory Browne
phpPgAdmin
244216 by: Alain Roger
244219 by: Nirmalya Lahiri
Issue when inserting Slovak characters in database via PHP code
244217 by: Alain Roger
Re: postgreSQl and images
244218 by: Børge Holen
Trying to create an encryption method
244220 by: John Meyer
244221 by: Stut
Re: Protecting Streaming Audio
244222 by: Adam Gittins
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Roman Neuhauser wrote:
> # [EMAIL PROTECTED] / 2006-11-03 22:18:03 +0100:
>> Roman Neuhauser wrote:
>>> # [EMAIL PROTECTED] / 2006-11-03 16:16:11 +0100:
>>>> Roman Neuhauser wrote:
>>>>> # [EMAIL PROTECTED] / 2006-11-03 14:51:39 +0100:
>>>>>> 1. running the command 'locale -a' returns the following [shortened]
>>>>>> list:
>>>>>>
>> ...
>>
>>>>>> in fact I can set any installed locale I want on the commandline BUT
>>>>>> trying to set any other than the originally installed "[EMAIL
>>>>>> PROTECTED]" in
>>>>>> code running via Apache results in FALSE being returned and the locale
>>>>>> not being set.
>>>>>>
>>>>>> has anybody got a clue for me?
>>>>> You don't mention what warning(s) the failing setlocale() call
>>>>> produces.
>>>> it just returns false, telling me that the chosen locale(s) was/were not
>>>> set - there
>>>> is no PHP error at all.
>>> I just checked the setlocale() code (in HEAD), and surely it can
>>> return false without a warning, it can even be an almost empty (and
>>> just as quiet) stub that just returns false, depending on the value
>>> of HAVE_SETLOCALE during compilation.
>> thank you for doing this ... turns out that indeed the locale is being set
>> but the return value is false, I've settled for not checking the return
>> value and
>> just assuming (blindly hoping) the setlocale worked - I don't really know
>> what
>> else there is to do, besides ik works :-)
>
> How did you confirmed that the locale got set?
there is no simple way to determine if the locale was set because setlocale()
is returning
false even when a locale has been successfully set, given that for each
langauge I have a list
of locales (to be able to handle different server/OS setups) I can never be
sure which locale
in the list was actually set - now I suppose you could check the output of a
locale aware function
to see if the output is in the desired locale BUT this would mean having to
have some know output
to check against for each locale - that sounds like a recipe for messy,
horrible (and quite
likely brittle if not unreliable) code.
>
>>> Try a simple CGI script, does
>>> locale manipulation succeed there?
>> I'd have to look up how to setup a php-cgi ...
>
> It doesn't have to be written in PHP.
>
> Compile the following program and try it from the command line:
ok, wow - I'm definitely going to have a play with this when I have a
quite moment! nice one Roman! thank you.
>
> #include <errno.h>
> #include <string.h>
> #include <stdio.h>
> #include <locale.h>
>
> int
> main(int argc, char **argv)
> {
> if (2 > argc) {
> return printf("usage: %s <locale>\n", *argv);
> }
> char *old = setlocale(LC_ALL, NULL);
> printf("old: %p \"%s\"\n", old, old);
> char *loc = setlocale(LC_ALL, argv[1]);
> char *check = setlocale(LC_ALL, NULL);
> printf("check: %p \"%s\"\n", check, check);
> if (0 == loc) {
> printf("setlocale: \"%s\"\n", strerror(errno));
> return 1;
> }
> return printf("new: %p \"%s\"\n", loc, loc);
> }
>
> Put "AddHandler cgi-script .cgi" in your apache config
> and call the above from the script below, does the output differ?
>
> foo.cgi:
>
> #!/bin/sh
> printf "Content-Type: text/plain\r\n\r\n"
> /path/to/the-above-program en_GB
>
--- End Message ---
--- Begin Message ---
On 03/11/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
On Fri, November 3, 2006 6:09 am, Dotan Cohen wrote:
> How does php decide what timezone a user is in? Although I am in
> Haifa, Israel (GMT+2), when I go to a page with date("e") I get
> "America/New_York" displayed.
I could be wrong, but I think date('e') tells us where your SERVER is.
Or, more accurately, what time zone your server was configured to tell
us it lived in, no matter where it really lives in the physical world.
Yes, this seems to be the case.
> To confirm, could some users tell me what output they get on:
> http://what-is-what.com/what_time_is_it.php
>
> Let me know where you are in the world, and what timezone you are in
> to confirm/ deny the correctness of the php date function. Any advise
> on how to get the correct user's timezone would be most appreciated.
The function is correct. Your understanding of its purpose is incorrect.
Figures. Just like calculus :)
date('e') is there so that the server can know what time zone *IT*
lives in, not what time zone *I* live in.
There is a reason why all those web forums let you set your time zone
in your preferences... :-)
Actually, there are those who have it already filled it. Take for example:
http://extremetracking.com/?reg
> Note: I have considered matching the users' IP against a database, but
> I'd prefer a simpler method, without the overhead of such a database.
> Thanks in advance.
Put it this way:
If the info you want about me and my computer isn't in this output:
<?php phpinfo();?>
then you probably cannot get it.
I figured that, and that was the first place I went looking.
If you *do* use the IP->country db, please allow a manual override for
those users whose IP is wrong in the db, or who are using some kind of
proxy for whatever reason.
Of course. That was in the original plan.
Dotan Cohen
http://what-is-what.com/what_is/love.html
--- End Message ---
--- Begin Message ---
Dotan Cohen wrote:
> On 03/11/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
>> On Fri, November 3, 2006 6:09 am, Dotan Cohen wrote:
>> > How does php decide what timezone a user is in? Although I am in
>> > Haifa, Israel (GMT+2), when I go to a page with date("e") I get
>> > "America/New_York" displayed.
>>
>> I could be wrong, but I think date('e') tells us where your SERVER is.
>>
>> Or, more accurately, what time zone your server was configured to tell
>> us it lived in, no matter where it really lives in the physical world.
>
> Yes, this seems to be the case.
>
>> > To confirm, could some users tell me what output they get on:
>> > http://what-is-what.com/what_time_is_it.php
>> >
>> > Let me know where you are in the world, and what timezone you are in
>> > to confirm/ deny the correctness of the php date function. Any advise
>> > on how to get the correct user's timezone would be most appreciated.
>>
>> The function is correct. Your understanding of its purpose is incorrect.
>
> Figures. Just like calculus :)
>
>> date('e') is there so that the server can know what time zone *IT*
>> lives in, not what time zone *I* live in.
>>
>> There is a reason why all those web forums let you set your time zone
>> in your preferences... :-)
>
> Actually, there are those who have it already filled it. Take for example:
> http://extremetracking.com/?reg
that server seems to be in holland (so am I) and it's not even giving me the
correct
selection. my guess is they either set the TZ to the servers TZ or take some
kind of guess (ip database?).
I would use javascript to determine the user's local TZ by comparing a timestamp
written into the javascript output with the current time given by the
javascript Date object ...
you can then offer a pre-selected TZ value in a selectbox.
just a thought
>
--- End Message ---
--- Begin Message ---
On 03/11/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
On Fri, November 3, 2006 5:30 am, Dotan Cohen wrote:
> To all others who took part in this thread: I was unclear on another
> point as well, the issue of sql-injection. As I'm removing the
> symbols, signs, and other non-alpha characters from the query, I
> expect it to be sql-injection proof. As I wrong? ie, could an attacker
> successful inject sql if he has nothing but alpha characters at his
> disposal? I think not, but I'd like to hear it from someone with more
> experience than i.
In Latin1, ISO-8891-1 or whatever, plain old not-quite-ASCII, yeah,
you should be safe, I think...
I'm making *no* promises if your DB is configured to accept some
*other* character set, or the Bad Guy manages to trick it into
thinking it should be using that charset.
Yep, configured to accept UTF-8. Us Hebrew-speakers and our funny letters :)
Why the big deal about just calling mysql_real_escape_string() on your
data?
No biggie- I'm doing that too.
Or using prepared statements and that ilk?
Then you'd be 100% sure, and not worrying about it, eh?
Well, abstinence is not an option! I can't use prepared statements on
a full-text search.
Thanks, Richard. When is that Uranus office opening???? I've been
waiting almost five years!!
Dotan Cohen
nirot.com
http://what-is-what.com/what_is/ubuntu.html
--- End Message ---
--- Begin Message ---
Hi,
I would like to know if a lot of people use the PEAR system (packages +
core) to their web sites ?
One of my colleague uses it for company internal usage, but i wonder if my
web hoster will allow me to use and install it...because i have only a
webftp access to my business web site...
thanks a lot for your feedback.
Al.
--- End Message ---
--- Begin Message ---
I don't know about the command line pear app, but I don't see how they
either (a) could, or (b) would want to, stop you from using the individual
pear libraries. Unless they scan all the files you ftp to your site.
Just upload the ones that you require.
Some downloadables that use the Pear libraries include the ones that they
require.
You do however have to remember to set the include_path before you include
any pear libs - preferably in a config file, but if your host is not being
nice, you can http://www.php.net/manual/en/function.set-include-path.php
WebFtp sounds sucky. I can't imagine it integrating well with any apps.
On 11/4/06, Alain Roger <[EMAIL PROTECTED]> wrote:
Hi,
I would like to know if a lot of people use the PEAR system (packages +
core) to their web sites ?
One of my colleague uses it for company internal usage, but i wonder if my
web hoster will allow me to use and install it...because i have only a
webftp access to my business web site...
thanks a lot for your feedback.
Al.
--- End Message ---
--- Begin Message ---
Hi,
Is there a way via PhpPgAdmin to export/import the whole database info
(structure, schema, tables, index, sequences, data...) ?
Because i developed my database on local server and now i want to import to
my web hoster server...
and i do not want to recreate everything manually :-(
thx,
Al.
--- End Message ---
--- Begin Message ---
--- Alain Roger <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Is there a way via PhpPgAdmin to export/import the whole database
> info
> (structure, schema, tables, index, sequences, data...) ?
>
> Because i developed my database on local server and now i want to
> import to
> my web hoster server...
>
> and i do not want to recreate everything manually :-(
>
> thx,
>
> Al.
>
Alain,
Why are you not using pg_dump command from the shell prompt of
postgresql administrative user account for doing backup? If you do
so, then you can restore backuped data in any postgresql server.
Nirmalya Lahiri
(+91-94331-13536)
____________________________________________________________________________________
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates
(http://voice.yahoo.com)
--- End Message ---
--- Begin Message ---
Hi,
Sorry to cross post this mail but i'm not able to know from where comes my
issue.
I have a postgreSQL database in UNICODE (UTF-8 in v8.1.4 and UNICODE in
v8.0.1).
Via my web application i type a sentence in Slovak language and it is stored
into DB without any slovak characters. Instead of that, all particular
characters are replace with \303\251 or \303\206 or \304\314 and so on...
I was thinking that issue was coming from DB encryption but on 2 different
versions of DB (see above) i get the same result.
after, i was thinking that it was coming from my web browser, but even if i
setup character mode in central europe and Slovak language as default
coding...nothing change...i tried on IE and Firefox.
Last step, i tried to type directly from my PhpPgAdmin (direct typing
sentence there to DB), and i realize that when i click on save...the changes
appear in DB aswritten above (e.g. : \303\251,...)
My latest test was to write via PhpPgAdmin (directly to DB) the UNICODE of
slovak character contained within my sentence...so i used ý, í and
so on...
if i do that, those code are correctly saved into DB and when my PHP code
show web pages, all sentences are correct.
I can not imagine to write a special interface to convert slovak characters
to unicode everytime that user would like to type something new.
Something else must be badly setup...
Please, could you tell me where to search because i'm confused now...
thx.
Alain
--- End Message ---
--- Begin Message ---
On Saturday 04 November 2006 18:26, Alain Roger wrote:
> Hi,
>
> I create a table with some large object (ref: OID) to store some images.
> When my PHP will display some data, it will also display the images stored
> as OID.
>
> However, i've read that before i must restore the image by exporting them
> to local (on server) file.
No you don't.
>
> isn't it easier in this case, to simply store the path and file name of
> file to DB and just read the data to display image on PHP pages ?
depends.
> what is the purpose in this case to store image a bytea / large object ?
Keeping track af thousands of small images... in my case anyway.
makes it very easy to keep track of what you got'n not.
> moreover, how my php code will load image from DB and stored there as OID ?
the usual way?
> isn't it too much complex in comparison with just storing path and name of
> image ?
depends again. You wouldn't be in my shoes storing all those small images on
the fs and then keep track of them.
either you end up with a had as method of grouping them together,
moreover you can have thousands of small files inside one dir with an id name
to it, and yes the last one, thousands of directories with one file inside...
no, no and nono
>
> thanks a lot
>
> Al.
--
---
Børge
Kennel Arivene
http://www.arivene.net
---
--- End Message ---
--- Begin Message ---
I'm trying to create this encryption method for puzzles (nothing super
secret, just those cryptograms), but this seems to time out, can anybody
point out what I'm doing wrong here:
for ($i=1;$i<=26;$i++) {
$normalAlphabet[$i] = chr($i);
}
//now, to shuffle
for ($j=1;$j<=26;$j++) {
do {
$k = rand(1,26);
} while ($k == $j || (strlen(trim($normalAlphabet[$k])) === 0));
$arEncryptedAlphabet[$j] = $normalAlphabet[$k];
$normalAlphabet[$k] = "";
}
$arNormalString = str_split($normalzedString);
$encryptedString = "";
for ($i=0;$i<count($arNormalString);$i++) {
if (ord($arNormalString[$i])>=65 &&
ord($arNormalString[$i])<=90) {
$encryptedString = $encryptedString .
$arEncryptedAlphabet[ord($arNormalString[$i]) - 64];
} else {
$encryptedString = $encryptedString . $arNormalString[$i];
}
}
return $encryptedString;
}
--- End Message ---
--- Begin Message ---
John Meyer wrote:
for ($i=1;$i<=26;$i++) {
$normalAlphabet[$i] = chr($i);
}
//now, to shuffle
for ($j=1;$j<=26;$j++) {
do {
$k = rand(1,26);
} while ($k == $j || (strlen(trim($normalAlphabet[$k])) === 0));
$arEncryptedAlphabet[$j] = $normalAlphabet[$k];
$normalAlphabet[$k] = "";
}
$arNormalString = str_split($normalzedString);
$encryptedString = "";
for ($i=0;$i<count($arNormalString);$i++) {
if (ord($arNormalString[$i])>=65 &&
ord($arNormalString[$i])<=90) {
$encryptedString = $encryptedString .
$arEncryptedAlphabet[ord($arNormalString[$i]) - 64];
} else {
$encryptedString = $encryptedString . $arNormalString[$i];
}
}
return $encryptedString;
}
Both the inner loop and the outer loop are using $i, meaning the outer
loop will never end since it gets reset in the inner loop.
-Stut
--- End Message ---
--- Begin Message ---
Thanks. :)
That's an idea... Few questions. Grab the file and sendt it to someone, that
would work with a download but would it work with a streaming audio file,
because that has to be opened in realOne player or windows media player? I
was searching PHP.net documentation for a way of grabbing a file - what
function would be used?? Sorry about the silly questions..
Sincerely,
Adam
On 11/4/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
You put the data in a directory outside of the webspace and use PHP
to grab the file and send it to someone. That way you're able to
control access to the file.
By webspace, I'm referring to the directories outside of the ones
used to store and serve your webpages. This directory structure
would serve as an example for where you store your webpages and where
you store your data separately from the webpages:
/www/www.somesite.com/htdocs
/www/www.somesite.com/data
On Nov 3, 2006, at 9:29 PM, Adam Gittins wrote:
> Dear List,
>
> I have had a question that has been bugging me for a while now.
> Say
> that I need to have a members website. Which I want to protect
> streaming
> audio (Real, or Windows Media), now all the pages I can protect
> with a MYSQL
> DB and PHP. But when it comes to protecting a url of a file or
> audio feed it
> becomes tricky. What is the procedure? Would I have to use the
> htaccess
> file? But then when I open a realaudio file it will ask for a
> username and
> passworld again..
>
> How does one protect an url - or do I have to copy the file to a
> temp dir
> and then after a set time delete it?
>
> Help, there must be a way..
>
> Thanks for any ideas..
>
> Sincerely,
> Adam
--- End Message ---