|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 14 Oct 2005 15:58:46 -0000 Issue 3737
php-general-digest-help
lists.php.net
Date: Fri Oct 14 2005 - 10:58:46 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 14 Oct 2005 15:58:46 -0000 Issue 3737
Topics (messages 224101 through 224136):
Re: prevent user from getting scripts outside the web folder [this better?]
224101 by: David Robley
224108 by: Marcus Bointon
224122 by: John Nichel
224124 by: John Nichel
224128 by: David Robley
Volunteers Wanted for How-To testing / contribution
224102 by: Brian Fioca
Re: 404 ErrorDocument in safe mode
224103 by: darren kirby
224109 by: Petr Kodytek
How to know?
224104 by: gustav.varupiraten.se
Re: Login is not working. Please help....
224105 by: Jochem Maas
test
224106 by: Alan Lord
224107 by: Alan Lord
224118 by: Dan McCullough
224127 by: Alan Lord
224133 by: Oliver Grätz
Problem with special chars.
224110 by: Erfan Shirazi
224111 by: Jochem Maas
224112 by: Erfan Shirazi
224113 by: Jochem Maas
224117 by: Erfan Shirazi
OPTIMIZING - The fastest way to open and show a file
224114 by: Ruben Rubio Rey
224115 by: Richard Davey
224116 by: Jochem Maas
224119 by: Marcus Bointon
224136 by: ac
Re: Setting up Linux and SendMail for SMTP
224120 by: Brent Baisley
224131 by: ac
Re: Trouble moving directory
224121 by: Brent Baisley
224125 by: Miles Thompson
224130 by: Brent Baisley
224134 by: ac
Question about including files and server load
224123 by: Jay Paulson
224126 by: Richard Davey
224129 by: Edward Vermillion
224132 by: Oliver Grätz
Re: include file to global scope
224135 by: Oliver Grätz
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Ben wrote:
> Graham Anderson said the following on 10/13/05 15:31:
>> Is this a bit better ?
>> As directed, I 'sanitized' all user input variables with trim and
>> mysql_real_escape_string.
>>
>> thanks for everyone's patience as I am starting at ground zero
>> concerning security.
>>
>>
>> if( isset($_REQUEST['cmd']) OR isset($_REQUEST['path'] ))
>> {
>> // decrypt and santize variables
>> $cmd = isset($_REQUEST['cmd']) ? cleanser(decrypt($_REQUEST
>> ['cmd'])) : $cmd="null";
>> $path = isset($_REQUEST['path']) ? cleanser(decrypt($_REQUEST
>> ['path'])) : $path="null";
>> .
>> .
>> .
>>
>> the cleanser script:
>> function cleanser( $value )
>> {
>> return mysql_real_escape_string( trim( $value ) ) ;
>> }
>>
>> the 'decrypt' function uses MCRYPT_RIJNDAEL_256 with a $key stored
>> outside the web folder.
>>
>> many thanks :)
>
> My understanding is that mysql_real_escape_string will only work while
> you are connected to mysql. Not sure if that is the case in your
> situation.
That is incorrect. mysql_real_escape_string is a php function, not mysql.
Cheers
--
David Robley
Computer programmers do it byte by byte.
attached mail follows:
On 14 Oct 2005, at 04:48, David Robley wrote:
> That is incorrect. mysql_real_escape_string is a php function, not
> mysql.
Mostly true: mysql_real_escape_string is a php function, but it's
provided by the mysql extension as part of the mysql client libraries
(which explains the name). It doesn't do anything significantly
different to addslashes(), which is purely a PHP internal function.
If you are writing database independent code, you should probably
prefer addslashes (or things like adodb::qstr).
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcus
synchromedia.co.uk | http://www.synchromedia.co.uk
attached mail follows:
David Robley wrote:
> Ben wrote:
<snip>
>>My understanding is that mysql_real_escape_string will only work while
>>you are connected to mysql. Not sure if that is the case in your
>>situation.
>
>
> That is incorrect. mysql_real_escape_string is a php function, not mysql.
Actually, it's both. And yes, you *do* have to be connected to the
mysql server.
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john
kegworks.com
attached mail follows:
Marcus Bointon wrote:
> On 14 Oct 2005, at 04:48, David Robley wrote:
>
>> That is incorrect. mysql_real_escape_string is a php function, not
>> mysql.
>
>
> Mostly true: mysql_real_escape_string is a php function, but it's
> provided by the mysql extension as part of the mysql client libraries
> (which explains the name). It doesn't do anything significantly
> different to addslashes(), which is purely a PHP internal function. If
> you are writing database independent code, you should probably prefer
> addslashes (or things like adodb::qstr).
mysql_real_escape_string() takes into account the current characterset
of the database. addslashes() does not.
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john
kegworks.com
attached mail follows:
John Nichel wrote:
> David Robley wrote:
>> Ben wrote:
> <snip>
>>>My understanding is that mysql_real_escape_string will only work while
>>>you are connected to mysql. Not sure if that is the case in your
>>>situation.
>>
>>
>> That is incorrect. mysql_real_escape_string is a php function, not mysql.
>
> Actually, it's both. And yes, you *do* have to be connected to the
> mysql server.
>
<Blush> Note to self - engage brain before typing.
Cheers
--
David Robley
Hummingbirds never remember the words to songs.
attached mail follows:
I've recently released version 1.0 of the WASP framework for PHP 5.
http://wasp.sourceforge.net
And I'm in the final draft stages of a How-To article:
http://fioca.com/brian/wiki/index.php/How-To_Write_a_Simple_Blog_in_WASP
WASP is a lightweight but powerful framework written in the spirit of
(but rather different than) Ruby on Rails. The purpose, really, is
to utilize all of the enhancements made to PHP in version 5 to build
a reusable framework for large applications.
I'm looking for volunteers to try out the How-To to see if it works,
makes sense, and is easy to follow and complete. Any contributions
will be properly credited in the final version.
I'm also looking for contributors to the framework, especially in the
areas of Windows support, and ensuring it works on many database
platforms.
Check it out and send me an email if you'd like to contribute, or
join the mailing list and send contributions there.
Thanks!
Brian
/**
* Brian Fioca
* Chief Scientist / Sr. Technical Consultant
* PangoMedia - http://pangomedia.com
*/
attached mail follows:
quoth the Petr Kodytek:
> Hallo,
>
> I've problem with 404 ErrorDocument in safe mode on version 5.1.0RC1. I'm
> using error script to redirect nonexisting URLs to pages with content from
> database (something like mod_rewrite). After when my webhosting provider
> upgrades to 5.1.0RC1 my pages returns this error message :
>
> ===========================================================================
>===================== *Warning*: Unknown: SAFE MODE Restriction in effect.
> The script
> whose uid is 46790 is not allowed to access
> /path/to/404.phtml owned by uid 23708 in *Unknown* on line *0*
>
> *Warning*: Unknown: failed to open stream: No such file or directory in
> *Unknown* on line *0*
>
> *Warning*: Unknown: Failed opening '/path/to/404.phtml' for inclusion
> (include_path='.') in *Unknown* on line *0
> *==========================================================================
>====================== Note : /path/to/404.phtml is not real path, I'm
> changed it only for illustration
>
> *
> *When I'm trying to open 404.phtml script directly from browser everything
> gone OK. Have anyone idea to fix this. Sorry for my English.
>
> --
> Kody
First thing to check is that your server has permissions to read the script,
as there seems to be a permissions problem here. More details about your
server setup might help to diagnose this further...
-d
--
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQBDT1G7wPD5Cr/3CJgRAm/MAKDgKNtWctvZSNnuAXX+T6EcRi2mbwCeJadR
/VVxkbPMQlDV7F/a7j12Kjg=
=TtNb
-----END PGP SIGNATURE-----
attached mail follows:
darren kirby wrote:
>quoth the Petr Kodytek:
>
>
>>Hallo,
>>
>>I've problem with 404 ErrorDocument in safe mode on version 5.1.0RC1. I'm
>>using error script to redirect nonexisting URLs to pages with content from
>>database (something like mod_rewrite). After when my webhosting provider
>>upgrades to 5.1.0RC1 my pages returns this error message :
>>
>>===========================================================================
>>===================== *Warning*: Unknown: SAFE MODE Restriction in effect.
>>The script
>>whose uid is 46790 is not allowed to access
>>/path/to/404.phtml owned by uid 23708 in *Unknown* on line *0*
>>
>>*Warning*: Unknown: failed to open stream: No such file or directory in
>>*Unknown* on line *0*
>>
>>*Warning*: Unknown: Failed opening '/path/to/404.phtml' for inclusion
>>(include_path='.') in *Unknown* on line *0
>>*==========================================================================
>>====================== Note : /path/to/404.phtml is not real path, I'm
>>changed it only for illustration
>>
>>*
>>*When I'm trying to open 404.phtml script directly from browser everything
>>gone OK. Have anyone idea to fix this. Sorry for my English.
>>
>>--
>>Kody
>>
>>
>
>First thing to check is that your server has permissions to read the script,
>as there seems to be a permissions problem here. More details about your
>server setup might help to diagnose this further...
>
>-d
>
>
When I open 404.phtml directly from browser ererything gone OK, no error
message displayed.
It looks like a different access method to the script on 404 error.
I've tryed to create 404 script by
other php script (to get server process uid on file), but it's still not
working.
--
kody
attached mail follows:
Hi there!
I have a string like this... (envorinment string)
HOSTfriggAUDIODEV/tmp/SUNWut/dev/utaudio/8dtstart_sessionlogfile/dev/nullDTSCREENSAVERLISTStartDtscreenBlankXMBINDDIR/usr/dt/lib/bindingsUTAUDIODEV/tmp/SUNWut/dev/utaudio/8AB_CARDCATALOG/usr/dt/share/answerbooks/C/ab_cardcatalogLC_ALLCDTLOGINDISPLAYCLASSSunRayOSTYPEsolarisPWD/home/student/2003/a03guswi/ht05USERa03guswiSESSION_SVRfriggLANGCLOGNAMEa03guswiGROUPstudentGNOME_DESKTOP_SESSION_IDDefaultG_BROKEN_FILENAMESyesSHLVL2XMICONBMSEARCHPATH/home/student/2003/a03guswi/.dt/icons/%B%M.bm:/home/student/2003/a03guswi/.dt/icons/%B%M.pm:/home/student/2003/a03guswi/.dt/icons/%B:/usr/dt/appconfig/icons/%L/%B%M.bm:/usr/dt/appconfig/icons/%L/%B%M.pm:/usr/dt/appconfig/icons/%L/%B:/usr/dt/appconfig/icons/C/%B%M.bm:/usr/dt/appconfig/icons/C/%B%M.pm:/usr/dt/appconfig/icons/C/%BPATH/usr/local/bin/system:/usr/bin:/usr/openwin/bin:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/ucb:/opt/SUNWut/bin:/usr/sfw/bin:/opt/sfw/bin:/usr/local/bin:/openpkg/bin:/usr/dt/bin:.WINDOWID9437227DTXSERVERLOCATIONlocalCOLORTERMgnome-terminalHELPPATH/usr/op
enwin/lib/locale:/usr/openwin/lib/helpHOSTTYPEsun4DTDEVROOT/tmp/SUNWut/sessions/34TERMxtermHOME/home/student/2003/a03guswiCORONA_TOKENpseudo.080020b9346fXFILESEARCHPATH/usr/openwin/lib/locale/%L/%T/%N%S:/usr/openwin/lib/%T/%N%SMANPATH/usr/man:/usr/openwin/man:/usr/dt/man:/usr/local/man:/opt/SUNWspro/man:/openpkg/man:/opt/SUNWut/man:/usr/sfw/man:/opt/sfw/manDISPLAYfrigg:34DTHELPSEARCHPATH/home/student/2003/a03guswi/.dt/help/a03guswi-frigg-34/%H:/home/student/2003/a03guswi/.dt/help/a03guswi-frigg-34/%H.sdl:/home/student/2003/a03guswi/.dt/help/a03guswi-frigg-34/%H.hv:/home/student/2003/a03guswi/.dt/help/%H:/home/student/2003/a03guswi/.dt/help/%H.sdl:/home/student/2003/a03guswi/.dt/help/%H.hv:/usr/dt/appconfig/help/%L/%H:/usr/dt/appconfig/help/%L/%H.sdl:/usr/dt/appconfig/help/%L/%H.hv:/usr/dt/appconfig/help/C/%H:/usr/dt/appconfig/help/C/%H.sdl:/usr/dt/appconfig/help/C/%H.hvGTK_RC_FILES/etc/gtk/gtkrc:/home/student/2003/a03guswi/.gtkrc-1.2-gnome2EDITOR/usr/dt/bin/dtpadMAIL/var/mail/a03guswiTZMETSDT_NO_DTDBCACHE1DT
DATABASESEARCHPATH/home/student/2003/a03guswi/.dt/types,/etc/dt/appconfig/types/%L,/etc/dt/appconfig/types/C,/usr/dt/appconfig/types/%L,/usr/dt/appconfig/types/CVENDORsunXMICONSEARCHPATH/home/student/2003/a03guswi/.dt/icons/%B%M.pm:/home/student/2003/a03guswi/.dt/icons/%B%M.bm:/home/student/2003/a03guswi/.dt/icons/%B:/usr/dt/appconfig/icons/%L/%B%M.pm:/usr/dt/appconfig/icons/%L/%B%M.bm:/usr/dt/appconfig/icons/%L/%B:/usr/dt/appconfig/icons/C/%B%M.pm:/usr/dt/appconfig/icons/C/%B%M.bm:/usr/dt/appconfig/icons/C/%BLC_CTYPECGNOME_KEYRING_SOCKET/var/tmp/keyring-6VSyxE/socketUTDEVROOT/tmp/SUNWut/sessions/34/unitSTART_SPECKEYSDnoSESSIONTYPEaltDtDTAPPSEARCHPATH/home/student/2003/a03guswi/.dt/appmanager:/etc/dt/appconfig/appmanager/%L:/etc/dt/appconfig/appmanager/C:/usr/dt/appconfig/appmanager/%L:/usr/dt/appconfig/appmanager/CDTUSERSESSIONa03guswi-frigg-34OPENWINHOME/usr/openwin_/usr/bin/gnome-sessionDESKTOP_STARTUP_IDSDT_NO_TOOLTALK1MACHTYPEsparcSHELL/bin/tcshSESSION_MANAGERlocal/frigg:/tmp/.ICE-unix/22161,inet6/frigg
:38974,inet/frigg:38975G_FILENAME_ENCODING
locale,UTF-8SUN_SUNRAY_TOKENpseudo.080020b9346f
I want to divide it into something like
HOST=frigg
AUDIODEV=HOSTfriggAUDIODEV/tmp/SUNWut/dev/utaudio/8dtstart_sessionlogfile/dev/null
DTSCREENSAVERLISTS=tartDtscreenBlank
XMBINDDIR=/usr/dt/lib/bindings
UTAUDIODEV=/tmp/SUNWut/dev/utaudio/
8AB_CARDCATALOG=/usr/dt/share/answerbooks/C/ab_cardcatalog
LC_ALLCDTLOGINDISPLAYCLASS=SunRay
OSTYPEsolarisPWD/home/student/2003/a03guswi/ht05USERa03guswiSESSION_SVRfriggLANGCLOGNAMEa03guswiGROUPstudentGNOME_DESKTOP_SESSION_IDDefaultG_BROKEN_FILENAMESyesSHLVL2XMICONBMSEARCHPATH/home/student/2003/a03guswi/.dt/icons/%B%M.bm:/home/student/2003/a03guswi/.dt/icons/%B%M.pm:/home/student/2003/a03guswi/.dt/icons/%B:/usr/dt/appconfig/icons/%L/%B%M.bm:/usr/dt/appconfig/icons/%L/%B%M.pm:/usr/dt/appconfig/icons/%L/%B:/usr/dt/appconfig/icons/C/%B%M.bm:/usr/dt/appconfig/icons/C/%B%M.pm:/usr/dt/appconfig/icons/C/%BPATH/usr/local/bin/system:/usr/bin:/usr/openwin/bin:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/ucb:/opt/SUNWut/bin:/usr/sfw/bin:/opt/sfw/bin:/usr/local/bin:/openpkg/bin:/usr/dt/bin:.WINDOWID9437227DTXSERVERLOCATIONlocalCOLORTERMgnome-terminalHELPPATH/usr/openwin/lib/locale:/usr/openwin/lib/helpHOSTTYPEsun4DTDEVROOT/tmp/SUNWut/sessions/34TERMxtermHOME/home/student/2003/a03guswiCORONA_TOKENpseudo.080020b9346fXFILESEARCHPATH/usr/openwin/lib/locale/%L/%T/%N%S:/usr/openwin/lib/%T/%N%SMANPATH/usr/man:/usr/openwin/man:
/usr/dt/man:/usr/local/man:/opt/SUNWspro/man:/openpkg/man:/opt/SUNWut/man:/usr/sfw/man:/opt/sfw/manDISPLAYfrigg:34DTHELPSEARCHPATH/home/student/2003/a03guswi/.dt/help/a03guswi-frigg-34/%H:/home/student/2003/a03guswi/.dt/help/a03guswi-frigg-34/%H.sdl:/home/student/2003/a03guswi/.dt/help/a03guswi-frigg-34/%H.hv:/home/student/2003/a03guswi/.dt/help/%H:/home/student/2003/a03guswi/.dt/help/%H.sdl:/home/student/2003/a03guswi/.dt/help/%H.hv:/usr/dt/appconfig/help/%L/%H:/usr/dt/appconfig/help/%L/%H.sdl:/usr/dt/appconfig/help/%L/%H.hv:/usr/dt/appconfig/help/C/%H:/usr/dt/appconfig/help/C/%H.sdl:/usr/dt/appconfig/help/C/%H.hvGTK_RC_FILES/etc/gtk/gtkrc:/home/student/2003/a03guswi/.gtkrc-1.2-gnome2EDITOR/usr/dt/bin/dtpadMAIL/var/mail/a03guswiTZMETSDT_NO_DTDBCACHE1DTDATABASESEARCHPATH/home/student/2003/a03guswi/.dt/types,/etc/dt/appconfig/types/%L,/etc/dt/appconfig/types/C,/usr/dt/appconfig/types/%L,/usr/dt/appconfig/types/CVENDORsunXMICONSEARCHPATH/home/student/2003/a03guswi/.dt/icons/%B%M.pm:/home/student/2003/a03guswi/
.dt/icons/%B%M.bm:/home/student/2003/a03guswi/.dt/icons/%B:/usr/dt/appconfig/icons/%L/%B%M.pm:/usr/dt/appconfig/icons/%L/%B%M.bm:/usr/dt/appconfig/icons/%L/%B:/usr/dt/appconfig/icons/C/%B%M.pm:/usr/dt/appconfig/icons/C/%B%M.bm:/usr/dt/appconfig/icons/C/%BLC_CTYPECGNOME_KEYRING_SOCKET/var/tmp/keyring-6VSyxE/socketUTDEVROOT/tmp/SUNWut/sessions/34/unitSTART_SPECKEYSDnoSESSIONTYPEaltDtDTAPPSEARCHPATH/home/student/2003/a03guswi/.dt/appmanager:/etc/dt/appconfig/appmanager/%L:/etc/dt/appconfig/appmanager/C:/usr/dt/appconfig/appmanager/%L:/usr/dt/appconfig/appmanager/CDTUSERSESSIONa03guswi-frigg-34OPENWINHOME/usr/openwin_/usr/bin/gnome-sessionDESKTOP_STARTUP_IDSDT_NO_TOOLTALK1MACHTYPEsparcSHELL/bin/tcshSESSION_MANAGERlocal/frigg:/tmp/.ICE-unix/22161,inet6/frigg:38974,inet/frigg:38975G_FILENAME_ENCODING
locale,UTF-8SUN_SUNRAY_TOKENpseudo.080020b9346f
and so on...
I want to insert an "=" between capitalized letters and none capitalized
letters. That maybe isn't a problem, but how would you know for sure where
to end att for example bindings and but a "\n" between bindings and
UTAUDIODEV ?
/G
http://www.varupiraten.se/
attached mail follows:
try some code indentation to make it more readable.
someone else pointed you to the 'user' 'name' mismatch already I see.
twistednetadmin wrote:
...
>
> session_start();
> switch (
$_GET['action']) // Gets set by the form action
> {
> case "login":
> $sql = "SELECT name FROM DB
> WHERE name='$_POST[user]'";
> $result = mysql_query($sql) or die("Couldn't execute query.");
> $num = mysql_num_rows($result);
> if ($num ==1) // loginname found
> {
> $sql = "SELECT name FROM DB
> WHERE name='$_POST[user]'
> AND pass=password('$_POST[pass]')";
> $result2 = mysql_query($sql) or die("Couldn't execute query 2.");
> $num2 = mysql_num_rows($result2);
> if ($num2 > 0) // password is correct
> {
> $_SESSION['auth']="yes";
> $logname=$_POST['user'];
> $_SESSION['logname'] = $logname;
> header("Location: page1.php");
> }
> else // password is not correct
> {
> unset($action);
> header("Location: loginerror.php");
> }
> }
> elseif ($num == 0) // Wrong name. Name not in db
> {
> unset($action);
> header("Location: loginerror.php");
> }
>
> }
>
...
attached mail follows:
please ignore. Sorry for the noise.
attached mail follows:
please ignore
attached mail follows:
did it work ;)
On 10/14/05, Alan Lord <lord_alan
hotmail.com> wrote:
> please ignore
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Amazingly Yes!
Dan McCullough wrote:
> did it work ;)
>
> On 10/14/05, Alan Lord <lord_alan
hotmail.com> wrote:
>
>>please ignore
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
attached mail follows:
Ignored.
attached mail follows:
Hi all
I have some problems when I make a string containing the following
"Malmö, Asunción" to capital letters and then save it to a file.
I use the following to make it to capital letters:
$msg = mb_strtoupper($msg, "HTML-ENTITIES");
And this works just fine, everything looks as it should, but when I save
it to a file, this is how it looks:
"MALMÖ, ASUNCIÓN
It seems it has problems with "ó" and "Ö", does anybody know how this
can be solved? I have tried some different encodings but nothing helps,
I'm using PHP 4.3.2.
Thx in advance for all help.
/Erfan
attached mail follows:
Erfan Shirazi wrote:
> Hi all
>
>
> I have some problems when I make a string containing the following
> "Malmö, Asunción" to capital letters and then save it to a file.
>
> I use the following to make it to capital letters:
> $msg = mb_strtoupper($msg, "HTML-ENTITIES");
^- you are telling mb_strtoupper to
encode your 'funky' chars into html entities.
>
> And this works just fine, everything looks as it should, but when I save
> it to a file, this is how it looks:
> "MALMÖ, ASUNCIÓN
^\
\---------------------- notice the names: 'Ouml' meaning. 'O umlaut'
>
> It seems it has problems with "ó" and "Ö", does anybody know how this
it has no problems AFAICT, the characters you mention have been turned
into html entities... these entities (in the form '&' + xyz + ';') are
shown in the browser as the relevant char.
> can be solved? I have tried some different encodings but nothing helps,
the solution is to not convert to html entities, or (if its required) only
converting to html entities when you want to output something to the browser
> I'm using PHP 4.3.2.
>
> Thx in advance for all help.
>
> /Erfan
>
attached mail follows:
The problem is if I don't specify and encoding even an echo() on the
string shows strange chars when I have made a mb_strtoupper() on the
string. With HTML-ENTITIES at least it looked ok when you made an echo()
but when saved in file it looks bad.
Does anybody now what I can do in order to make the string into capital
letters, be able to save it to a file and looking as it should look,
that is: Asunción and not ASUNCIÓN?
/Erfan
Jochem Maas wrote:
> Erfan Shirazi wrote:
>
>> Hi all
>>
>>
>> I have some problems when I make a string containing the following
>> "Malmö, Asunción" to capital letters and then save it to a file.
>>
>> I use the following to make it to capital letters:
>> $msg = mb_strtoupper($msg, "HTML-ENTITIES");
>
> ^- you are telling mb_strtoupper to
> encode your 'funky' chars into html entities.
>
>>
>> And this works just fine, everything looks as it should, but when I
>> save it to a file, this is how it looks:
>> "MALMÖ, ASUNCIÓN
>
> ^\
> \---------------------- notice the names: 'Ouml' meaning. 'O umlaut'
>
>>
>> It seems it has problems with "ó" and "Ö", does anybody know how this
>
>
> it has no problems AFAICT, the characters you mention have been turned
> into html entities... these entities (in the form '&' + xyz + ';') are
> shown in the browser as the relevant char.
>
>> can be solved? I have tried some different encodings but nothing helps,
>
>
> the solution is to not convert to html entities, or (if its required) only
> converting to html entities when you want to output something to the
> browser
>
>> I'm using PHP 4.3.2.
>>
>> Thx in advance for all help.
>>
>> /Erfan
>>
attached mail follows:
Erfan Shirazi wrote:
> The problem is if I don't specify and encoding even an echo() on the
specify a different encoding if you don't want html entities.
> string shows strange chars when I have made a mb_strtoupper() on the
> string. With HTML-ENTITIES at least it looked ok when you made an echo()
of course it looks ok - the browser is showing you the characters that the
html entities represent.
this string: 'Ó'
...is an html entity.
> but when saved in file it looks bad.
time for you to find out (STFW) about html entities and encoding in general
>
> Does anybody now what I can do in order to make the string into capital
try setting your encoding to 'UTF-8' or some such, your mileage may vary.
> letters, be able to save it to a file and looking as it should look,
> that is: Asunción and not ASUNCIÓN?
>
> /Erfan
>
>
> Jochem Maas wrote:
>
>> Erfan Shirazi wrote:
>
>
>
>>
>>> Hi all
>>>
>>>
>>> I have some problems when I make a string containing the following
>>> "Malmö, Asunción" to capital letters and then save it to a file.
>>>
>>> I use the following to make it to capital letters:
>>> $msg = mb_strtoupper($msg, "HTML-ENTITIES");
>>
>>
>> ^- you are telling mb_strtoupper to
>> encode your 'funky' chars into html entities.
>>
>>>
>>> And this works just fine, everything looks as it should, but when I
>>> save it to a file, this is how it looks:
>>> "MALMÖ, ASUNCIÓN
>>
>>
>> ^\ \---------------------- notice the names: 'Ouml'
>> meaning. 'O umlaut'
>>
>>>
>>> It seems it has problems with "ó" and "Ö", does anybody know how this
>>
>>
>>
>> it has no problems AFAICT, the characters you mention have been turned
>> into html entities... these entities (in the form '&' + xyz + ';') are
>> shown in the browser as the relevant char.
>>
>>> can be solved? I have tried some different encodings but nothing helps,
>>
>>
>>
>> the solution is to not convert to html entities, or (if its required)
>> only
>> converting to html entities when you want to output something to the
>> browser
>>
>>> I'm using PHP 4.3.2.
>>>
>>> Thx in advance for all help.
>>>
>>> /Erfan
>>>
>
attached mail follows:
I have tried every encoding which could be found in:
http://www.php.net/manual/en/ref.mbstring.php
But nothing seems to work, I don't have any problems displaying the
funny chars in the browsers, there are some encodings which works fine
for that, the problem is when I save it to a file using fwrite().
Jochem Maas wrote:
> Erfan Shirazi wrote:
>
>> The problem is if I don't specify and encoding even an echo() on the
>
>
> specify a different encoding if you don't want html entities.
>
>> string shows strange chars when I have made a mb_strtoupper() on the
>> string. With HTML-ENTITIES at least it looked ok when you made an echo()
>
>
> of course it looks ok - the browser is showing you the characters that the
> html entities represent.
>
> this string: 'Ó'
> ...is an html entity.
>
>> but when saved in file it looks bad.
>
>
> time for you to find out (STFW) about html entities and encoding in general
>
>>
>> Does anybody now what I can do in order to make the string into capital
>
>
> try setting your encoding to 'UTF-8' or some such, your mileage may vary.
>
>> letters, be able to save it to a file and looking as it should look,
>> that is: Asunción and not ASUNCIÓN?
>>
>> /Erfan
attached mail follows:
Hi,
I m creating a cache system, and i have a problem: PHP takes a lot of
time opening the file. (Im using 2.6.9-1.667smp and XFS)
* For files less or equal 6 Kb, takes arround 0.02-0.03 miliseconds - its ok
* For files arround 35 Kb takes arround 0.2-0.4 miliseconds - too much.
What can I do to make faster opening files?
**************************************************************
Source code:
if(file_exists($filename)){
$modified_date=filemtime($filename);
if(time()<($modified_date+1 * 24 * 60 * 60)){
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
echo $contents;
}
}
**************************************************************
Thinks that I have tried:
* fopen is *much* faster than include
* filemtime is faster than filectime
* Pear Cache its too much slower (0.5-0.7 milsecond per file)
Thanks in advance
Tk421
attached mail follows:
Hi Ruben,
Friday, October 14, 2005, 12:29:09 PM, you wrote:
> What can I do to make faster opening files?
> **************************************************************
> Source code:
> if(file_exists($filename)){
> $modified_date=filemtime($filename);
> if(time()<($modified_date+1 * 24 * 60 * 60)){
> $handle = fopen($filename, "r");
> $contents = fread($handle, filesize($filename));
> fclose($handle);
> echo $contents;
> }
> }
> **************************************************************
You could try using file_get_contents instead of fopen/fread/fclose
and see if that makes any difference.
Also possibly try stat instead of filemtime? It would at least cache
the file stats on the 2nd run through, etc.
At the end of the day though any hard drive operation is going to be
relatively slow. Perhaps there is another way to do what you need that
avoids opening all the files? At the moment you appear to be checking
every files modified time then opening it. Perhaps you could get back
a directory listing instead and parse the modified time from this,
rather than check every single file?
Cheers,
Rich
--
Zend Certified Engineer
http://www.launchcode.co.uk
attached mail follows:
Ruben Rubio Rey wrote:
>
> Hi,
>
> I m creating a cache system, and i have a problem: PHP takes a lot of
> time opening the file. (Im using 2.6.9-1.667smp and XFS)
>
> * For files less or equal 6 Kb, takes arround 0.02-0.03 miliseconds -
> its ok
> * For files arround 35 Kb takes arround 0.2-0.4 miliseconds - too much.
>
> What can I do to make faster opening files?
faster disks.
alternatively if you have RAM to spare you can mount a RAM partition
and write and read all your cache files from there (I do it on
some machine with session files too)
there is also file_get_contents()
>
> **************************************************************
> Source code:
> if(file_exists($filename)){
> $modified_date=filemtime($filename);
> if(time()<($modified_date+1 * 24 * 60 * 60)){
> $handle = fopen($filename, "r");
> $contents = fread($handle, filesize($filename));
> fclose($handle);
> echo $contents;
> }
> }
> **************************************************************
>
> Thinks that I have tried:
> * fopen is *much* faster than include
> * filemtime is faster than filectime
> * Pear Cache its too much slower (0.5-0.7 milsecond per file)
>
> Thanks in advance
> Tk421
>
attached mail follows:
On 14 Oct 2005, at 12:29, Ruben Rubio Rey wrote:
> * For files less or equal 6 Kb, takes arround 0.02-0.03 miliseconds
> - its ok
> * For files arround 35 Kb takes arround 0.2-0.4 miliseconds - too
> much.
Bearing in mind that average access time on a 7200rpm HD is around
8ms, those numbers sound too good to be true anyway. You could
configure some kind of software disk cache on your system, or ideally
a hardware caching RAID controller and it could improve things
dramatically, but not down to that kind of level (which represents
about 200x what a single disk system might be expected to deliver).
Otherwise as Jochem says, use RAM for your cache in the first place.
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcus
synchromedia.co.uk | http://www.synchromedia.co.uk
attached mail follows:
where did these time measured?
on a heavily loaded server or on your own almost idle desktop machine ?
On 10/14/05, Ruben Rubio Rey <ruben
rentalia.com> wrote:
>
> Hi,
>
> I m creating a cache system, and i have a problem: PHP takes a lot of
> time opening the file. (Im using 2.6.9-1.667smp and XFS)
>
> * For files less or equal 6 Kb, takes arround 0.02-0.03 miliseconds - its
> ok
> * For files arround 35 Kb takes arround 0.2-0.4 miliseconds - too much.
>
> What can I do to make faster opening files?
>
> **************************************************************
> Source code:
> if(file_exists($filename)){
> $modified_date=filemtime($filename);
> if(time()<($modified_date+1 * 24 * 60 * 60)){
> $handle = fopen($filename, "r");
> $contents = fread($handle, filesize($filename));
> fclose($handle);
> echo $contents;
> }
> }
> **************************************************************
>
> Thinks that I have tried:
> * fopen is *much* faster than include
> * filemtime is faster than filectime
> * Pear Cache its too much slower (0.5-0.7 milsecond per file)
>
> Thanks in advance
> Tk421
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
all born, to be dying
attached mail follows:
Just about any mail server will accept mail from anywhere for local
delivery. But if you are not sending email to a user account local to
that mail server, the mail server is going to want you to
authenticate. Without authentication, the mail server would be an
open relay (no security), which is how spam gets around.
Some mail servers are setup to allow any email to go out as long as
it originates locally, like PHP running on the mail server or the
local network. This is still a limited open relay (weak security),
since it can be compromised by spoofing. The built-in PHP mail()
function does not currently support authentication, so you would not
be able to use a mail server that hasn't been setup for your computer
to send email without authenticating.
What you should look into is the PHPMailer class, which supports SMTP
authentication.
http://phpmailer.sourceforge.net/
I probably should have just said this first instead of giving a
tutorial.
On Oct 13, 2005, at 7:52 PM, Todd Cary wrote:
> I have a Linux server on my network, however my main mail is
> handled by Thunderbird on my PC which uses my ISP's SMTP server
> (UserName and PW). Can I configure SendMail to send mail to my
> ISP's SMTP server using the built in mail() function of PHP?
>
> If I use one of the Mail Classes, I can do it and on my client's
> Linux server, mail() works (but they are not using an outside SMTP
> server).
>
> Many thanks...
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
attached mail follows:
On 10/14/05, Todd Cary <todd
aristesoftware.com> wrote:
> Can I configure SendMail to send mail to my ISP's SMTP server using
> the built in mail() function of PHP?
>
i think you can, may be you would like to read the manual of your
sendmail program,
about how to configure it as a smart host.
and if neccessary, tell it the un and pw you used to authenticate
yourself to your smtp server.
attached mail follows:
In your example, the problem is that the name has spaces, which the
shell uses as a delimiter. So "That Won't Move/" is kind of being
considered parameters instead of part of the dir. Using the command
line (i.e. shell/terminal) will give you more feedback as to what is
happening (/some/dir/Dir: No such Directory).
You need to either escape the characters or enclose it in quotes. For
me, I always find it easier to just enclose directory names in quotes.
$source_dir = '"/some/dir/Dir That Won't Move/"';
On Oct 12, 2005, at 10:11 PM, -k. wrote:
> I'm having trouble moving some directories. My script works fine on
> some directories but doesn't
> move others. It seems to have trouble with directories with non
> alphanumeric charters. I'm running
> Red Hat FC2. I'm trying to move the directory basically like this...
>
> <?Php
>
> $source_dir = '/some/dir/Dir That Won't Move/';
> $dest_dir = '/some/other/dir/'
>
> $cmd = escapeshellcmd("mv ".$source_dir." ".$dest_dir);
> $result = shell_exec($cmd);
>
> ?>
>
> Is there some way to escape the characters in the directories? For
> example if i put a "\" in front
> of blank spaces it takes care of those (same for "'","(" etc.) but
> that obviously doesn't take
> care of everything. I'm hoping there is something easy i'm
> overlooking here that will escape all
> the characters.
>
>
>
>
> -k.
>
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
attached mail follows:
One of the "nice" things MSFT did was to allow spaces in directory and file
names. It created more work for programmers.
One of the LOUSIEST things MSFT did was allowing spaces in directory and
file names, because of the needless, tedious parsing and checking it requires.
So much simpler to train users that computers are dumb and trip over
spaces, so just use an underscore where you want to separate words. Funny
thing, users accept that.
Glad I got that off my chest - Miles
At 10:11 AM 10/14/2005, Brent Baisley wrote:
>In your example, the problem is that the name has spaces, which the
>shell uses as a delimiter. So "That Won't Move/" is kind of being
>considered parameters instead of part of the dir. Using the command
>line (i.e. shell/terminal) will give you more feedback as to what is
>happening (/some/dir/Dir: No such Directory).
>
>You need to either escape the characters or enclose it in quotes. For
>me, I always find it easier to just enclose directory names in quotes.
>
>$source_dir = '"/some/dir/Dir That Won't Move/"';
>
>
>On Oct 12, 2005, at 10:11 PM, -k. wrote:
>
>>I'm having trouble moving some directories. My script works fine on
>>some directories but doesn't
>>move others. It seems to have trouble with directories with non
>>alphanumeric charters. I'm running
>>Red Hat FC2. I'm trying to move the directory basically like this...
>>
>><?Php
>>
>>$source_dir = '/some/dir/Dir That Won't Move/';
>>$dest_dir = '/some/other/dir/'
>>
>>$cmd = escapeshellcmd("mv ".$source_dir." ".$dest_dir);
>>$result = shell_exec($cmd);
>>
>>?>
>>
>>Is there some way to escape the characters in the directories? For
>>example if i put a "\" in front
>>of blank spaces it takes care of those (same for "'","(" etc.) but
>>that obviously doesn't take
>>care of everything. I'm hoping there is something easy i'm
>>overlooking here that will escape all
>>the characters.
>>
>>
>>
>>
>>-k.
>>
>>
>>
>>
>>__________________________________
>>Yahoo! Mail - PC Magazine Editors' Choice 2005
>>http://mail.yahoo.com
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>--
>Brent Baisley
>Systems Architect
>Landover Associates, Inc.
>Search & Advisory Services for Advanced Technology Environments
>p: 212.759.6400/800.759.0577
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
MSFT allowed spaces? They were behind in allowing spaces (and long
file names) Apple allowed them far before MS, and Unix allowed spaces
far before Apple. Unix just assumes a space is a command/parameter
delimiter first and part of the name second. Just like multiplication
takes precedence over addition unless you use parenthesis, a space
takes precedence as a delimiter unless you use quotes.
Spaces are permitted, underscores just means you don't have to use
quotes to explain what you mean. It's like saying Unix doesn't allow
you to use capitals in the file name because it won't find "filename"
it you type "FileName". It's a feature of a case sensitive file
system available in most forms of Unix. It also caused a lot of
confusion and frustration to people developing web sites under
Windows and posting to a Unix host.
Telling users to use underscores is a work around that works as long
and everyone uses underscores all the time. It's still better to have
knowledge of what's going on and why so when one does encounter a
file name with a space they know how to reference it.
I would say one of the lousiest things MSFT did was reversing the /
to reference paths in DOS.
On Oct 14, 2005, at 9:28 AM, Miles Thompson wrote:
>
> One of the "nice" things MSFT did was to allow spaces in directory
> and file names. It created more work for programmers.
>
> One of the LOUSIEST things MSFT did was allowing spaces in
> directory and file names, because of the needless, tedious parsing
> and checking it requires.
>
> So much simpler to train users that computers are dumb and trip
> over spaces, so just use an underscore where you want to separate
> words. Funny thing, users accept that.
>
> Glad I got that off my chest - Miles
>
> At 10:11 AM 10/14/2005, Brent Baisley wrote:
>
>> In your example, the problem is that the name has spaces, which the
>> shell uses as a delimiter. So "That Won't Move/" is kind of being
>> considered parameters instead of part of the dir. Using the command
>> line (i.e. shell/terminal) will give you more feedback as to what is
>> happening (/some/dir/Dir: No such Directory).
>>
>> You need to either escape the characters or enclose it in quotes. For
>> me, I always find it easier to just enclose directory names in
>> quotes.
>>
>> $source_dir = '"/some/dir/Dir That Won't Move/"';
>>
>>
>> On Oct 12, 2005, at 10:11 PM, -k. wrote:
>>
>>
>>> I'm having trouble moving some directories. My script works fine on
>>> some directories but doesn't
>>> move others. It seems to have trouble with directories with non
>>> alphanumeric charters. I'm running
>>> Red Hat FC2. I'm trying to move the directory basically like this...
>>>
>>> <?Php
>>>
>>> $source_dir = '/some/dir/Dir That Won't Move/';
>>> $dest_dir = '/some/other/dir/'
>>>
>>> $cmd = escapeshellcmd("mv ".$source_dir." ".$dest_dir);
>>> $result = shell_exec($cmd);
>>>
>>> ?>
>>>
>>> Is there some way to escape the characters in the directories? For
>>> example if i put a "\" in front
>>> of blank spaces it takes care of those (same for "'","(" etc.) but
>>> that obviously doesn't take
>>> care of everything. I'm hoping there is something easy i'm
>>> overlooking here that will escape all
>>> the characters.
>>>
>>>
>>>
>>>
>>> -k.
>>>
>>>
>>>
>>>
>>> __________________________________
>>> Yahoo! Mail - PC Magazine Editors' Choice 2005
>>> http://mail.yahoo.com
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>>
>> --
>> Brent Baisley
>> Systems Architect
>> Landover Associates, Inc.
>> Search & Advisory Services for Advanced Technology Environments
>> p: 212.759.6400/800.759.0577
>>
>> --
>> 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
>
>
>
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
attached mail follows:
escapeshellarg() works quite well, why you say its still failed? did u try?
do a
<?php echo escapeshellarg('Dir That (Won't Move)/'); ?>
will produce
'Dir That (Won'\''t Move)'
and this does fit into shell, even `(' and `)' is not escaped,
for in bash, all thing quoted in single quote will be treated as one
whole string and any meta character wont be interpreted by the shell.
so , please first try, then post your problem.
On 10/13/05, -k. <telirum
yahoo.com> wrote:
> --- Jasper Bryant-Greene <jasper
bryant-greene.name> wrote:
> > $source_dir = escapeshellarg( '/some/dir/Dir That Won't Move/' );
>
>
> Unfortunately escapeshellarg doesn't work for all cases, it will escape the " ' " in that example
> but it doesn't escape other characters such as " ) ". So...
>
> $source_dir = escapeshellarg( '/some/dir/Dir That (Won't Move)/' );
>
> ...fails as well. Any other ideas?
>
>
>
>
> -k.
>
>
>
> __________________________________
> Yahoo! Music Unlimited
> Access over 1 million songs. Try it free.
> http://music.yahoo.com/unlimited/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
all born, to be dead
attached mail follows:
I just started working with a new company and they handed me some of their
php code for me to look over. I noticed that they have a TON of include
files being called into their scripts. For example, instead of having one
file called functions.php and then having all their functions in that one
file they have put each function into it's separate file and then have a
define_functions.php file that creates each function. However, within the
function itself it declared something like this:
function xyz($abc) { return include(xyz_func.php); }
function abc($xyz) { return include(abc_func.php); }
I was wondering isn't this putting a bigger load on a server by including
so many files for each function? Also, I was wondering what everyone's
opinion was on this approach in terms of maintenance. Do you think it's
better practice to put all your functions in one file or do it in this
manner?
thanks for any input!
jay
attached mail follows:
Hi Jay,
Friday, October 14, 2005, 2:21:57 PM, you wrote:
> I was wondering isn't this putting a bigger load on a server by
> including so many files for each function? Also, I was wondering
> what everyone's opinion was on this approach in terms of
> maintenance. Do you think it's better practice to put all your
> functions in one file or do it in this manner?
How many are there? I don't use functions in that way, but I do a
similar thing for class files (minus that "definedfucntions" part of
course).
You could of course combine them all together, and yes it *would* be
faster for the script to execute as there is far less drive activity
going on. But then it's a trade-off between maintaining that single
massive file, as opposed to updating smaller chunks. If it's a real
issue looking at something like Zend Encoder would help.
Cheers,
Rich
--
Zend Certified Engineer
http://www.launchcode.co.uk
attached mail follows:
Richard Davey wrote:
> Hi Jay,
>
> Friday, October 14, 2005, 2:21:57 PM, you wrote:
>
>
>>I was wondering isn't this putting a bigger load on a server by
>>including so many files for each function? Also, I was wondering
>>what everyone's opinion was on this approach in terms of
>>maintenance. Do you think it's better practice to put all your
>>functions in one file or do it in this manner?
>
>
> How many are there? I don't use functions in that way, but I do a
> similar thing for class files (minus that "definedfucntions" part of
> course).
>
> You could of course combine them all together, and yes it *would* be
> faster for the script to execute as there is far less drive activity
> going on. But then it's a trade-off between maintaining that single
> massive file, as opposed to updating smaller chunks. If it's a real
> issue looking at something like Zend Encoder would help.
>
> Cheers,
>
> Rich
Isn't it more work for PHP, or rather the Zend engine, to keep track of
a bunch of functions that aren't being used, not to mention the memory
it takes to load in one huge file. I agree that putting each function in
it's own file is going a bit too far in the other direction.
I tend to group functions together by purpose into seperate files. Kind
of a happy medium. You don't have a bunch of includes in the code and
you don't have a bunch of functions in memory that aren't being used.
attached mail follows:
Jay Paulson schrieb:
> function xyz($abc) { return include(xyz_func.php); }
> function abc($xyz) { return include(abc_func.php); }
Oh. My. God. Is this ugly. OK, it works, but that's not the way how one
should abuse include().
> I was wondering isn't this putting a bigger load on a server by including
> so many files for each function? Also, I was wondering what everyone's
> opinion was on this approach in terms of maintenance. Do you think it's
> better practice to put all your functions in one file or do it in this
> manner?
First of all: Yes, it increases the load, but not as much as one might
think. Modern filesystems are pretty good at caching so after the first
access to your scripts after some pause (caches cleared) there is a big
overhead but for subsequent page requests the overhead will be almost
negligible. So: Favor well organised file collections over big bloated
single-file function libraries!
But: Don't do it this way! Group the functions into similar ones (e.g
all functions regarding mail into functions/mail.php) and put each group
in one file. Rule of thumb: Starting at over 500 lines you begin to get
more problems at maintaining your script files. Then it makes sense not
only grouping the functions into one file per function group but into
directories containing one to many files (e.g. functions/mail/send.php
and functions/mail/receive.php).
Following this you should of course start to not include your whole
function library in each request but to implement some library loader.
You could do this in your pages:
// your index.php (if using this for all pages) or something
// you include in each file
// this is a page sending html mails so I need this:
$used_libs=array('mail/send','html/create');
foreach ($used_libs as $lib)
{
include('functions/'.$lib.'.php');
}
You could extend this concept to check if the requested files exist and
you could add some array with libraries that you want always to be
included. You could also create a mail/all mechanism that includes all
of the files in one directory.
And with PHP5 you have even more choices. You could use classes instead
of functions. Even if you don't want to instantiate objects you could
use them as "namespace simulators" in a static way. Instead of
function mail_send() {}
you could write
class Mail
{
public static function send() {}
}
This would then be called via Mail::send(). What's the advantage? Well,
you can cretae an autoloader for classes with PHP5. If you write it so
that the class Mail is in the file classes/Mail.php then you can
autoload the class on access so you can
Mail::send()
without having to explicitly include anything! Youd wouldn't have to
configure your scripts since only those classes you use will be
included. This of course reduces your server load.
So, long enough a response ? ;-)
AllOLLi
____________
6: "Dr. Amrak gave the disc to me before he died."
B: "What? As opposed to after he died?"
[Battlestar Galactica 107]
attached mail follows:
Claudio schrieb:
> I'm using PHP 5. I have a class operation that includes php files.
> Is there a way to include this files to global scope? So that difined vars
> and functions are global accesseble?
I know this problem from my early PHP days. If your problem is that you
want to include some class or function libraries then the simple
solution is: Do not include inside the function or class but let the
class or function just return the path name!
So instead of
function include_lib($name)
{
$path='functions/'.$name.'.php'; // or more werid stuff
include($path);
}
include_lib('test');
do
function lib_path($name)
{
$path='functions/'.$name.'.php'; // or more werid stuff
return $path;
}
include(lib_path('test'));
Perhaps your problem is exactly of this type or similar.
AllOLLi
____________
Inara: "It sounds like the sort of thing this crew can handle. I can't
guarantee they'll handle it particularly well, but..."
Nandi: "If they got guns, and brains at all..."
Inara: "They've got guns."
[firefly 113]
- application/pkcs7-signature attachment: smime.p7s
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]