php-general Digest 26 Nov 2009 22:17:02 -0000 Issue 6462
Topics (messages 300119 through 300130):
Re: Detecting The Encoding Of A Text File
300119 by: Nitsan Bin-Nun
300121 by: ×× ××× ×× ××
300122 by: Ashley Sheridan
300124 by: Nisse Engström
300125 by: ×× ××× ×× ××
Re: Return object to client
300120 by: Manoj Singh
php htaccess logins and logouts
300123 by: Ashley Sheridan
300130 by: James McLean
Re: PHP Equivalent to Java Jar or Python Eggs
300126 by: Greg Maruszeczka
My new address
300127 by: Austin Ladd
Re: register_globals and sessions
300128 by: Brady Mitchell
Re: string concatenation with fgets
300129 by: aurfalien.gmail.com
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 ---
Someone have already suggested it but I haven't tried it yet.
The thing is that right now it contains Hebrew, but tommorrow this file will
be in German or any other accented language.
I'm trying to create a function which would detect the encoding and convert
it into UTF8.
(I don't have much experience in encoding.. :( )
2009/11/26 Nisse Engström <[email protected]>
> On Thu, 26 Nov 2009 06:55:31 +0200, Nitsan Bin-Nun wrote:
>
> > Hi,
> >
> > I have been trying for the last couple of hours to determine the
> > encoding of a text file (.txt in windowz).
> >
> > I have this code:
> >
> > $contents = file_get_contents($config['
> > txt_dir'] . $file);
> > $encoding = mb_detect_encoding($contents,
> > "UTF-8,ISO-8859-1,WINDOWS-1252"); //,Windows-1255
> >
> > echo "||encoding:".$encoding."||";
> >
> > if ($encoding == 'UTF-8')
> > {
> > $utfcontents = $contents;
> > }
> > else if ($encoding == 'ISO-8859-1')
> > {
> > $utfcontents = utf8_encode($contents);
> > }
> >
> > var_dump($utfcontents);
> >
> > The $encoding is ISO-8859-1, the text file contains Hebrew characters,
> then
> > I'm converting it to utf8.
> >
> > The above code is outputing gibbrish, it seems that it has converted it
> in
> > some way but not in the
> > proper way that it should have converted it.
>
> If you know that the file contains Hebrew, maybe you should
> try converting from ISO-8859-8?
>
>
> /Nisse
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
If windows notepad can detect encoding there must be a way to do it
yourself.
Maybe try to get the file's headers, I think it should also contain the
encoding of the file...
2009/11/26 Nitsan Bin-Nun <[email protected]>
> Someone have already suggested it but I haven't tried it yet.
>
> The thing is that right now it contains Hebrew, but tommorrow this file
> will
> be in German or any other accented language.
> I'm trying to create a function which would detect the encoding and convert
> it into UTF8.
>
> (I don't have much experience in encoding.. :( )
>
> 2009/11/26 Nisse Engström <[email protected]>
>
> > On Thu, 26 Nov 2009 06:55:31 +0200, Nitsan Bin-Nun wrote:
> >
> > > Hi,
> > >
> > > I have been trying for the last couple of hours to determine the
> > > encoding of a text file (.txt in windowz).
> > >
> > > I have this code:
> > >
> > > $contents = file_get_contents($config['
> > > txt_dir'] . $file);
> > > $encoding = mb_detect_encoding($contents,
> > > "UTF-8,ISO-8859-1,WINDOWS-1252"); //,Windows-1255
> > >
> > > echo "||encoding:".$encoding."||";
> > >
> > > if ($encoding == 'UTF-8')
> > > {
> > > $utfcontents = $contents;
> > > }
> > > else if ($encoding == 'ISO-8859-1')
> > > {
> > > $utfcontents = utf8_encode($contents);
> > > }
> > >
> > > var_dump($utfcontents);
> > >
> > > The $encoding is ISO-8859-1, the text file contains Hebrew characters,
> > then
> > > I'm converting it to utf8.
> > >
> > > The above code is outputing gibbrish, it seems that it has converted it
> > in
> > > some way but not in the
> > > proper way that it should have converted it.
> >
> > If you know that the file contains Hebrew, maybe you should
> > try converting from ISO-8859-8?
> >
> >
> > /Nisse
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
--
Use ROT26 for best security
--- End Message ---
--- Begin Message ---
On Thu, 2009-11-26 at 15:39 +0200, דניאל דנון wrote:
> If windows notepad can detect encoding there must be a way to do it
> yourself.
>
> Maybe try to get the file's headers, I think it should also contain the
> encoding of the file...
>
> 2009/11/26 Nitsan Bin-Nun <[email protected]>
>
> > Someone have already suggested it but I haven't tried it yet.
> >
> > The thing is that right now it contains Hebrew, but tommorrow this file
> > will
> > be in German or any other accented language.
> > I'm trying to create a function which would detect the encoding and convert
> > it into UTF8.
> >
> > (I don't have much experience in encoding.. :( )
> >
> > 2009/11/26 Nisse Engström <[email protected]>
> >
> > > On Thu, 26 Nov 2009 06:55:31 +0200, Nitsan Bin-Nun wrote:
> > >
> > > > Hi,
> > > >
> > > > I have been trying for the last couple of hours to determine the
> > > > encoding of a text file (.txt in windowz).
> > > >
> > > > I have this code:
> > > >
> > > > $contents = file_get_contents($config['
> > > > txt_dir'] . $file);
> > > > $encoding = mb_detect_encoding($contents,
> > > > "UTF-8,ISO-8859-1,WINDOWS-1252"); //,Windows-1255
> > > >
> > > > echo "||encoding:".$encoding."||";
> > > >
> > > > if ($encoding == 'UTF-8')
> > > > {
> > > > $utfcontents = $contents;
> > > > }
> > > > else if ($encoding == 'ISO-8859-1')
> > > > {
> > > > $utfcontents = utf8_encode($contents);
> > > > }
> > > >
> > > > var_dump($utfcontents);
> > > >
> > > > The $encoding is ISO-8859-1, the text file contains Hebrew characters,
> > > then
> > > > I'm converting it to utf8.
> > > >
> > > > The above code is outputing gibbrish, it seems that it has converted it
> > > in
> > > > some way but not in the
> > > > proper way that it should have converted it.
> > >
> > > If you know that the file contains Hebrew, maybe you should
> > > try converting from ISO-8859-8?
> > >
> > >
> > > /Nisse
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>
>
>
A plain text file wouldn't have headers like that would it? At least,
not in the sense that an image file has a header, or an office document
file has a header.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Thu, 26 Nov 2009 15:39:04 +0200, דניאל דנון wrote:
> If windows notepad can detect encoding there must be a way to do it
> yourself.
>
> Maybe try to get the file's headers, I think it should also contain the
> encoding of the file...
Plain text files don't have any headers. Perhaps they use
heuristics, eg. examine the distribution of characters to
determine a probable encoding.
[Quick Google...]
<http://blogs.msdn.com/oldnewthing/archive/2007/04/17/2158334.aspx>
/Nisse
--- End Message ---
--- Begin Message ---
I was thinking that if notepad can open it correctly it has headers - but
the link you gave clarify that, my bad.
2009/11/26 Nisse Engström <[email protected]>
> On Thu, 26 Nov 2009 15:39:04 +0200, דניאל דנון wrote:
>
> > If windows notepad can detect encoding there must be a way to do it
> > yourself.
> >
> > Maybe try to get the file's headers, I think it should also contain the
> > encoding of the file...
>
> Plain text files don't have any headers. Perhaps they use
> heuristics, eg. examine the distribution of characters to
> determine a probable encoding.
>
> [Quick Google...]
>
> <http://blogs.msdn.com/oldnewthing/archive/2007/04/17/2158334.aspx>
>
>
> /Nisse
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Use ROT26 for best security
--- End Message ---
--- Begin Message ---
Hi All,
I am implementing the web service through PHP SOAP library.
Actually I want to return the object to the client through web service so
that client can call all the methods of that object.
Please help me out.
Regards,
Manoj
--- End Message ---
--- Begin Message ---
Hi all,
I've got a site set up that is using an htaccess file to provide secure
access to a directory. That is working fine. What I wondered was, is
there a way to log out via PHP. As I understand it, the login mechanism
is part of Apache, so I guess what I'm really asking is, is there a way
that I can get Apache to end the 'session' that Apache has set up, using
PHP?
I'm sure I've seen cPanel do it, so I was wondering how easy this would
be to do myself.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Fri, Nov 27, 2009 at 12:12 AM, Ashley Sheridan
<[email protected]> wrote:
> Hi all,
>
> I've got a site set up that is using an htaccess file to provide secure
> access to a directory. That is working fine. What I wondered was, is
> there a way to log out via PHP. As I understand it, the login mechanism
> is part of Apache, so I guess what I'm really asking is, is there a way
> that I can get Apache to end the 'session' that Apache has set up, using
> PHP?
>
> I'm sure I've seen cPanel do it, so I was wondering how easy this would
> be to do myself.
IIRC if you unset $_SERVER['PHP_AUTH_USER'] and
$_SERVER['PHP_AUTH_PW'] it will log you out.
Cheers.
--- End Message ---
--- Begin Message ---
On Thu, 26 Nov 2009 13:09:48 +1030
James McLean <[email protected]> wrote:
> On Thu, Nov 26, 2009 at 11:50 AM, <[email protected]> wrote:
> >
> > Has anyone done any work towards packaging of PHP in a manner
> > similar to jar or eggs? I was working on a project the other day
> > with a lot of class files and thought this would be a cool, simple
> > way to deploy the app.
>
> Yes; Greg Beaver has done a lot of work with PHAR, which is very
> similar. See http://au2.php.net/phar
>
> Cheers
>
...it's even bundled with PHP 5.3+
GM
--- End Message ---
--- Begin Message ---
Acce dot ssRx pro ap vides Men’s He gbh alth prod ak ucts to tr vr eat ere zee
ctile dysf ltm unction (ED). Cho ge ose from all three FD xpq A-appr cz oved ED
pres uq crip ac tion medi gd cations: Via ff gra, Cia iad lis and Lev ja itra.
Only a small per id cent og age of men seek help for ED, alth is ough a lar khi
ge num zl ber of men expe wyp rience it in var gds ying deg nq rees. All three
F iq DA-app dpj roved dru pxc gs are pro pt ven to be eff nky ective in most
hea cev lthy men. See Acces gaw sRx’s prod rz uct information pages for deta iz
ils about dos pm ages, dire fw ctions, side eff pg ects, pre ua cautions, freq
tj uently ask wvl ed ques dkj tions, links to manu ii facturer web jvb sites
and patie vt nt/presc tky ribing infor pp mation. You can also acc sjt ess aVia
ezt gra, Ci fmv alis, Lev cy itra compa up rison chart that sum wr marizes medi
uq cation info xy rmation for the thr bx ee ED d oig rugs in one cent rsq ral
loc oel ation. Via huj gra Silde pd nafil 50/100mg
$1.42 Per P oa ill More info
C prr ia rva lis Tada gb lafil 10/20mg
$1.66 Per P ys ill More info
Levi kj tra Vard js enafil 20mg
$1.72 Per P bk ill More info
--- End Message ---
--- Begin Message ---
On Wed, Nov 25, 2009 at 3:01 PM, Allen McCabe <[email protected]> wrote:
> *Warning*: Unknown: Your script possibly relies on a session side-effect
> which existed until PHP 4.2.3. Please be advised that the session extension
> does not consider global variables as a source of data, unless
> register_globals is enabled. You can disable this functionality and this
> warning by setting session.bug_compat_42 or session.bug_compat_warn to off,
> respectively in *Unknown* on line *0*
It sounds like you're trying to use $_SESSION without having a
session_start() call first.
> I have Googled this extensively, and the solutions other people tried
> (turning off the warning) don't work for me; I don't have permission to my
> PHP settings (currently working on a free-hosted site).
There are many settings that can be changed using the function ini_set
(http://php.net/ini_set) and display_errors is one of them.
That said, it is always best to fix stuff like this than just hiding
it. When you just hide errors/warnings/notices things don't always
work reliably.
HTH,
Brady
--- End Message ---
--- Begin Message ---
So here is my final test code, notice the check for ' ' in the if.
Since I'm on Linux, this has to do with whats between the last LF and
EOF which is nothing but this nothing will get printed out.
$file = fopen("somefile.txt", "r");
while (! feof($file))
{
$names = trim(fgets($file));
if ($names == '')
{
break;
}
print $names."sometext\n";
}
fclose($file);
- aurf
On Nov 24, 2009, at 5:52 PM, ryan wrote:
Is this what you want
$file = fopen("test.txt", "r");
while (!feof($file)) {
$line = trim(fgets($file));
print $line."sometext\n";
}
fclose($file);
outputs
asometext
bsometext
csometext
Ref to http://us3.php.net/manual/en/function.fgets.php. "Reading
ends when /length/ - 1 bytes have been read, on a newline (which is
included in the return value), or on EOF (whichever comes first). If
no length is specified, it will keep reading from the stream until
it reaches the end of the line. "
[email protected] wrote:
Hi all,
I'm trying to append some text to what I read from a file.
My code;
$file = fopen("foo.txt", "r");
while (!feof($file)) {
$line = fgets($file);
print $line."sometext";
}
fclose($file);
foo,txt;
a
b
c
d
e
f
g
And when I run the script, it looks like;
a
sometextb
sometextc
sometextd
...
Any ideas?
Thanks in advance,
- aurf
--- End Message ---