php-general Digest 6 Sep 2005 08:07:30 -0000 Issue 3666

Topics (messages 221873 through 221889):

Re: FTP Chmod problem
        221873 by: Raj Shekhar
        221875 by: Matt Palermo

Re: how to divide string
        221874 by: Jordan Miller

Re: PHP/MySQL offline
        221876 by: viraj

preg_match and $ sign in PHP5
        221877 by: Cabbar Duzayak
        221878 by: Jasper Bryant-Greene
        221887 by: Robin Vickery

Re: AND OR NOT
        221879 by: John Taylor-Johnston
        221880 by: John Taylor-Johnston
        221881 by: Jasper Bryant-Greene

[suspicious - maybe spam] $BIwB/5U1g6f3ZIt(B
        221882 by: info.zasxwe.com

suggestions needed to use "session"
        221883 by: Nahalingam Kanakavel
        221884 by: Robert Graham

Getting current page name without path
        221885 by: Bushra
        221886 by: George Pitcher
        221888 by: Robin Vickery

302 Responses (Was: session cookies)
        221889 by: Chris Shiflett

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
"Matt Palermo" <[EMAIL PROTECTED]> writes:


> ftp_chmod($connId, 0777, $folder);
> 
> The function almost works, but when I check the permission of the folder 
> after it's run, the folder has 410 for permissions instead of 777.  So, it 
> is changing the permissions, but not to the correct value.  Now when I use 
> the following code, it seems to work fine:
> 
> $chmodCmd = "CHMOD 0777 ".$file;
> ftp_site($connId, $chmodCmd);
> 
> This properly changes the folder permissions to 777.  Does anyone know why 
> the ftp_chmod() function doesn't work correctly?  As a side note, the 
> ftp_chmod() function works correctly on a file, but not a directory.  Any 
> help is appreciated.

Some ftp server (like vsftpd) can be configure to change the mode of all
uploaded files .  There is a possibility that your server is configure
to chmod your files (in vsftpd it is controlled by the file_open_mode
option in the config file)

-- 
Raj Shekhar
blog : http://rajshekhar.net/blog  home : http://rajshekhar.net
Disclaimer : http://rajshekhar.net/disclaimer

--- End Message ---
--- Begin Message ---
It doesn't make sense to me that the function would work fine on a file and 
not work on a directory.  Moreover, why would the ftp_site chmod command 
produce a working result and not the ftp_chmod?  This seems strange to me.

-Matt




"Raj Shekhar" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> "Matt Palermo" <[EMAIL PROTECTED]> writes:
>
>
>> ftp_chmod($connId, 0777, $folder);
>>
>> The function almost works, but when I check the permission of the folder
>> after it's run, the folder has 410 for permissions instead of 777.  So, 
>> it
>> is changing the permissions, but not to the correct value.  Now when I 
>> use
>> the following code, it seems to work fine:
>>
>> $chmodCmd = "CHMOD 0777 ".$file;
>> ftp_site($connId, $chmodCmd);
>>
>> This properly changes the folder permissions to 777.  Does anyone know 
>> why
>> the ftp_chmod() function doesn't work correctly?  As a side note, the
>> ftp_chmod() function works correctly on a file, but not a directory.  Any
>> help is appreciated.
>
> Some ftp server (like vsftpd) can be configure to change the mode of all
> uploaded files .  There is a possibility that your server is configure
> to chmod your files (in vsftpd it is controlled by the file_open_mode
> option in the config file)
>
> -- 
> Raj Shekhar
> blog : http://rajshekhar.net/blog  home : http://rajshekhar.net
> Disclaimer : http://rajshekhar.net/disclaimer 

--- End Message ---
--- Begin Message --- If you are using php 5, don't forget about str_split, with 4 as the second parameter.
http://us2.php.net/str_split

so you could do:
echo implode("<br />", str_split($string, 4));

if you still have php 4 or earlier, look at that page anyway as there is a workaround function in the comments for earlier versions of php.

Jordan



On Sep 5, 2005, at 6:50 AM, Adi Zebic wrote:

Hi,

is there any magic function who can give me from:

$string = " abcdefghijklmnopqrstuwvxyz";

somthing like this:

abcd
efgh
ijkl
mnop
qrst
uwvx
yz

(each 'x' letters go to the next line)

Thanks a lot,

ADI

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






--- End Message ---
--- Begin Message ---
On 9/4/05, John Taylor-Johnston
<[EMAIL PROTECTED]> wrote:
> This is maybe what you want:
> http://www.indigostar.com/
> http://www.indigostar.com/microweb.htm

another good method is a "Live Linux CD". you can find a light weight
live linux distro and remaster it to include your live web site. so
your client can put boot his/her pc with this cd and start browsing
the site.

this way you can use whatever the LAMP combination!

http://www.google.com/search?hl=en&q=howto+remaster&spell=1
http://taprobane.org/

~viraj.

> Runs an apache server, php & all, from a CD. (windows app.)
> John
> 
> Mario netMines wrote:
> 
> > Hi all
> >
> > I have a project where I'm using PHP/Mysql. The client wants to run
> > that project to a cd.
> > Does anyone know of a trick either by using javascript, XML or an
> > automated script that creates a static site that will allow me to do
> > that?
> >
> > Many Thanks
> >
> > M
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
Hi,

I have a regular expression check as:

preg_match("/$xyz/", $data, $matches);

And, as you know $xyz means "string starts with xyz". But somehow PHP
5 is interpreting this as variable xyz, and gives the  notice below.
You can ignore the message, but now it matches everything that has
xyz, i.e. aaxyzbb


PHP Notice:  Undefined variable: xyz in /tmp/test.php

Any idea about how I can specify "string starts with xyz" or fix it
such that PHP5 won't recognize this as a variable?

Thanks...

--- End Message ---
--- Begin Message ---
Cabbar Duzayak wrote:
I have a regular expression check as:

preg_match("/$xyz/", $data, $matches);

And, as you know $xyz means "string starts with xyz". But somehow PHP
5 is interpreting this as variable xyz, and gives the  notice below.
You can ignore the message, but now it matches everything that has
xyz, i.e. aaxyzbb

Either use single quotes:

preg_match('/$xyz/', $data, $matches);

or escape the $-sign:

preg_match("/\$xyz/", $data, $matches);

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

If you find my advice useful, please consider donating to a poor
student! You can choose whatever amount you think my advice was
worth to you. http://tinyurl.com/7oa5s

--- End Message ---
--- Begin Message ---
On 9/6/05, Cabbar Duzayak <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I have a regular expression check as:
> 
> preg_match("/$xyz/", $data, $matches);
> 
> And, as you know $xyz means "string starts with xyz". 

No it doesn't - "string starts with xyz" would be "/^xyz/" which
coincidentally avoids your problem of xyz being interpreted as a
variable name.

More generally, if you don't want $xyz interpreted as a variable, then
use single quotes - or if you must use double quotes, then escape the
$ with a backslash.

 -robin

--- End Message ---
--- Begin Message ---
David,

I'm under pressure to permit AND, OR & NOT. My research group insists that MySQL 4 syntax is "not good enough".

An idea of what one might enter is here (on the bottom): http://compcanlit.usherbrooke.ca/advanced.html

I was hoping to get away with replacing " AND " with "+", " NOT " with "-" and " OR " with " ".

I use this as SQL:

SELECT *,MATCH (YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,JR,KW,AUS,TUS,GEO,AN,SA,RB)
AGAINST ('$mydata->searchenquiry' IN BOOLEAN MODE)
AS relevancy FROM ccl_main
WHERE MATCH (YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,JR,KW,AUS,TUS,GEO,AN,SA,RB)
AGAINST ('$mydata->searchenquiry' IN BOOLEAN MODE)
ORDER BY relevancy DESC;-->

John


David Robley wrote:

John Taylor-Johnston wrote:

Any ideas? Post kind of lost in there since Saturday. Is str_replace the
best choice for case sensitive and for swapping " AND "?

<input TYPE="text" NAME="searchenquiry" VALUE="" size=30>

Any suggestion on how to swap AND OR NOT for mysql fulltext syntax in
$searchenquiry?
A simple parse for " AND " and then str_replace? Is str_replace
appropriate for case?

John


I think you have a slightly more complex situation than just replacing text
between what I assume is a LIKE or multiple WHERE situation and a fulltext
search. Perhaps if you can give an idea of the type of string you are
likely to get in $searchenquiry, and to what you wish to convert it, we
might be better placed to give advice.

I can envisage that you might get 'bananas NOT pears AND apples' in the
variable; I guess you would currently manipulate that to a query such as

"WHERE x = 'bananas' AND x <> 'pears' AND x = 'apples'"

(OK that's not a good example) but if you were to feed that to a fulltext
search you might want

WHERE MATCH (x) AGAINST ('+bananas -pears -apples' IN BOOLEAN MODE)

or maybe something else depending on the version of Mysql and exactly what
you are trying to do with your fulltext search.



--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."

°v° Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures
/(_)\ Université de Sherbrooke
^ ^ http://compcanlit.ca/ T: 819.569.2064

--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."

 ' ' '    Collège de Sherbrooke:
ô¿ô    http://www.collegesherbrooke.qc.ca/languesmodernes/
   -     819-569-2064

 °v°   Bibliography of Comparative Studies in Canadian, Québec and Foreign 
Literatures
/(_)\  Université de Sherbrooke
 ^ ^   http://compcanlit.ca/ T: 819.569.2064


--- End Message ---
--- Begin Message ---
David,

I'm under pressure to permit AND, OR & NOT. My research group insists that MySQL 4 syntax is "not good enough".

An idea of what one might enter is here (on the bottom): http://compcanlit.usherbrooke.ca/advanced.html

I was hoping to get away with replacing " AND " with "+", " NOT " with "-" and " OR " with " ".

I use this as SQL:

SELECT *,MATCH (YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,JR,KW,AUS,TUS,GEO,AN,SA,RB)
AGAINST ('$mydata->searchenquiry' IN BOOLEAN MODE)
AS relevancy FROM ccl_main
WHERE MATCH (YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,JR,KW,AUS,TUS,GEO,AN,SA,RB)
AGAINST ('$mydata->searchenquiry' IN BOOLEAN MODE)
ORDER BY relevancy DESC;-->

John


David Robley wrote:

John Taylor-Johnston wrote:

Any ideas? Post kind of lost in there since Saturday. Is str_replace the
best choice for case sensitive and for swapping " AND "?

<input TYPE="text" NAME="searchenquiry" VALUE="" size=30>

Any suggestion on how to swap AND OR NOT for mysql fulltext syntax in
$searchenquiry?
A simple parse for " AND " and then str_replace? Is str_replace
appropriate for case?

John


I think you have a slightly more complex situation than just replacing text
between what I assume is a LIKE or multiple WHERE situation and a fulltext
search. Perhaps if you can give an idea of the type of string you are
likely to get in $searchenquiry, and to what you wish to convert it, we
might be better placed to give advice.

I can envisage that you might get 'bananas NOT pears AND apples' in the
variable; I guess you would currently manipulate that to a query such as

"WHERE x = 'bananas' AND x <> 'pears' AND x = 'apples'"

(OK that's not a good example) but if you were to feed that to a fulltext
search you might want

WHERE MATCH (x) AGAINST ('+bananas -pears -apples' IN BOOLEAN MODE)

or maybe something else depending on the version of Mysql and exactly what
you are trying to do with your fulltext search.



--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."

°v° Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures
/(_)\ Université de Sherbrooke
^ ^ http://compcanlit.ca/ T: 819.569.2064

--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."

 ' ' '    Collège de Sherbrooke:
ô¿ô    http://www.collegesherbrooke.qc.ca/languesmodernes/
   -     819-569-2064

 °v°   Bibliography of Comparative Studies in Canadian, Québec and Foreign 
Literatures
/(_)\  Université de Sherbrooke
 ^ ^   http://compcanlit.ca/ T: 819.569.2064


--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."

 ' ' '    Collège de Sherbrooke:
ô¿ô    http://www.collegesherbrooke.qc.ca/languesmodernes/
   -     819-569-2064

 °v°   Bibliography of Comparative Studies in Canadian, Québec and Foreign 
Literatures
/(_)\  Université de Sherbrooke
 ^ ^   http://compcanlit.ca/ T: 819.569.2064


--- End Message ---
--- Begin Message ---
John Taylor-Johnston wrote:
David,

I'm under pressure to permit AND, OR & NOT. My research group insists that MySQL 4 syntax is "not good enough".

An idea of what one might enter is here (on the bottom): http://compcanlit.usherbrooke.ca/advanced.html

I was hoping to get away with replacing " AND " with "+", " NOT " with "-" and " OR " with " ".

I use this as SQL:

SELECT *,MATCH (YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,JR,KW,AUS,TUS,GEO,AN,SA,RB)
AGAINST ('$mydata->searchenquiry' IN BOOLEAN MODE)
AS relevancy FROM ccl_main
WHERE MATCH (YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,JR,KW,AUS,TUS,GEO,AN,SA,RB)
AGAINST ('$mydata->searchenquiry' IN BOOLEAN MODE)
ORDER BY relevancy DESC;-->

Please don't top-post [1]. Nice cryptic column names, by the way :)

Your research group obviously haven't researched very carefully, as "+term" is exactly equal to " AND term", "-term" to " NOT term" and simply "term" to " OR term". So there's no point in complicating the syntax.

Not only that, but MySQL's boolean mode fulltext search offers many more great possibilities like truncation ("app*" will match "apple", "application"...) and in-query relevance altering. Take a look at the BOOLEAN MODE section of the MySQL manual [2]; maybe print it and give it to your research group :)

[1] http://en.wikipedia.org/wiki/Top-posting
[2] http://dev.mysql.com/doc/mysql/en/fulltext-boolean.html

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

If you find my advice useful, please consider donating to a poor
student! You can choose whatever amount you think my advice was
worth to you. http://tinyurl.com/7oa5s

--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED]@-M_H/;6$r$*<jEA$$!*(B
$B=w<RD9!"<RD9Na>n!"7]G=?M!"([EMAIL PROTECTED](B
$B(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(B
$B"!%R%^$G$*6b;[EMAIL PROTECTED]@-M_$rK~$?$7$F$"$2$F$/[EMAIL PROTECTED](B
$B"!C/$G$b4JC1!*L5NAEPO?!*(B
$B"!%Q%=%3%s!&7HBSA45!<o$G%a!<%k$,Aw$l$^$9!*(B
$B"!8D?M>pJs$N%;%-%e%j%F%#!<K|A4!*(B
$B"!$*=;[EMAIL PROTECTED];$^$9!*(B
$B"[EMAIL PROTECTED],05E]E*$J$N$G!"[EMAIL 
PROTECTED]@$1$G$b$*Aj<j$,%2%C%H$G$-$^$9!#(B
$B"!6bA,LdBj$,@[EMAIL 
PROTECTED],$"$k$N$G(B18$B:PL$K~$NCK=w$NEPO?$O$41sN8$/[EMAIL PROTECTED](B

$B!!!!!!(Bhttp://80607.jp/dt/giaku/enjo.html
$B(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(B
$B"v$*6b;}$A$G%;%C%/%9$,[EMAIL PROTECTED]/Js$G$9"v(B
$B6u$$$F$$$k;~4V$rMxMQ$7$F%;%C%/%9$KNe$s$G$/[EMAIL PROTECTED](B 
$B%$%s%?!<%M%C%H$GAGE([EMAIL PROTECTED]>R2p$$$?$7$^$9!#F~$j8}"M(B
$B!!!!!!(Bhttp://80607.jp/dt/giaku/enjo.html
$B"v$*6b$K:$$C$F!"[EMAIL PROTECTED]($J%3!<%J!<"v(B
$B%3%3$+$i=w<RD9!"<RD9Na>n!"7]G=?M!"([EMAIL 
PROTECTED],$i$b!o$b%2%C%H!*!J$?$@:#F8Dg$/$s$OBg?M5$!"$?$/[EMAIL 
PROTECTED]>$5$l$F$$$k!K(B
$B!!!!!!(Bhttp://80607.jp/dt/giaku/enjo.html
$B(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(B
[EMAIL PROTECTED]>R2p$9$k%3!<%J!<(B
$B!&!D(,(,"!!!$*6b;[EMAIL PROTECTED]@b$-J}!!"!(,(,!D!&(B
$B!&%a!<%k$G==J,$K%3%_%e%K%1!<%7%g%s$r$H$j$^$7$g$&!#B(%;%C%/%98r>D$OI]$,$i$l$k%1!<%9$,$h$/$"$j$^$9!#(B
$B!&4pK\E*$K%([EMAIL 
PROTECTED]($OB>$KNc$r$_$J$$$[$I6K$a$F9b$$%5%$%H$G$9$N$G!"$"$;$i$:!"$8$C$/$j9T$/$H5U6L$NMA$OL\A0$G$9!#$,$s$P$C$F$/[EMAIL
 PROTECTED](B
[EMAIL PROTECTED]>lF~$j8}"M(B
$B!!!!!!(Bhttp://80607.jp/dt/giaku/enjo.html
$B(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(,(B




$B:#8e<u?.5qH]$9$kJ}$O([EMAIL PROTECTED]/[EMAIL PROTECTED](B

--- End Message ---
--- Begin Message ---
Hi all,

I am new to PHP.
I know some thing about SESSIONS in PHP, I am in need of your suggestions.
how to use sessions ?
what is an efficient way to handle session_id ? like that.
How efficiently we can use session concept in our web site development ?
how it is helpful.

thanks in advance.

-- 
with regds,
Nahalingam.

--- End Message ---
--- Begin Message ---
Nahalingam Kanakavel wrote:

Hi all,

I am new to PHP.
I know some thing about SESSIONS in PHP, I am in need of your suggestions.
how to use sessions ?
what is an efficient way to handle session_id ? like that.
How efficiently we can use session concept in our web site development ?
how it is helpful.

thanks in advance.

Good day

Have a look at the following:
http://www.sitepoint.com/article/users-php-sessions-mysql

Regards
Robert

--- End Message ---
--- Begin Message ---
Hi
I want to get the name of current page. I use $PHP_SELF or SCRIPT_FILENAME, but it also provides the path name . I just want to retrieve the file name with extension. How can I do that?

Regards Bushra
--- End Message ---
--- Begin Message ---
> I want to get the name of current page. I use $PHP_SELF or
> SCRIPT_FILENAME, but it also provides the path name . I just want to
> retrieve the file name with extension. How can I do that?
>

$_SERVER['SCRIPT_NAME'] and $_SERVER['ORIG_SCRIPT_NAME'] will give you the
current filename without the path.

I'm currently using PHP5.1RC so it might differ in your version but check
out phpinfo.php

These things are all displayed in phpinfo.php.

George

--- End Message ---
--- Begin Message ---
On 9/6/05, Bushra <[EMAIL PROTECTED]> wrote:
> Hi
> I want to get the name of current page. I use $PHP_SELF or
> SCRIPT_FILENAME, but it also provides the path name . I just want to
> retrieve the file name with extension. How can I do that?

http://www.php.net/manual/en/function.basename.php

  -robin

--- End Message ---
--- Begin Message ---
Rasmus Lerdorf wrote:
Also, just add a single line to your own test script and make it look
like this:

header('Location: http://www.php.net/');
$fp = fopen('/tmp/log.txt', 'w');
for ($i = 0; $i < 30; $i++)
{
    $str = "Count $i\n";
    echo str_repeat($str, 1000);
    fputs($fp, $str);
    sleep(1);
    flush();
}

Then time how long it takes for the redirect to happen. Is it still
taking 30 seconds?

Yes, it still takes 30 seconds, but each chunk is now 8000 or 9000 bytes. This is with Firefox on Linux (my previous ad hoc tests were on Mac, because I was traveling). I'd be curious to know what behavior other people observe with any of these test scripts.

1. Rasmus's original test script:

header('Location: http://www.php.net/');
$fp = fopen('/tmp/log.txt', 'w');
for ($i = 0; $i < 1000000; $i++)
{
    $str = "Count $i\n";
    echo $str;
    fputs($fp, $str);
}

When trying this one, my log.txt shows entries from 0 to 999999, so it loops the full 1000000 times. I've checked ignore_user_abort(), and it's false. You can set it in the script to be sure. If the browser aborts and requests the new URL before the script finishes executing, the log should reflect this.

2. Chris's original test script:

header('Location: http://www.php.net/');
$fp = fopen('/tmp/log.txt', 'w');
for ($i = 0; $i < 30; $i++)
{
    $str = "Count $i\n";
    echo $str;
    fputs($fp, $str);
    sleep(1);
    flush();
}

This script takes longer to execute but generates less output. I was thinking that perhaps browsers are only patient up to a point, but this is not the case with the browsers I've tried. I get redirected after about 30 seconds.

3. Chris's modified test script:

header('Location: http://www.php.net/');
$fp = fopen('/tmp/log.txt', 'w');
for ($i = 0; $i < 30; $i++)
{
    $str = "Count $i\n";
    echo str_repeat($str, 1000);
    fputs($fp, $str);
    sleep(1);
    flush();
}

Rasmus modified the echo in my test script to output 1000 times as much content. I thought this might work based on section 10.3.3 of RFC 2616 (I referenced this to try to determine why we are observing different behavior):

"Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s)."

A few hundred thousand bytes doesn't seem like a "short hypertext note" to me, but apparently size doesn't matter. :-)

If anyone can get a browser to redirect (request the new URL) before receiving the entire 302 response, I'd love to know your test script, platform, and browser. I have not been able to reproduce this.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--- End Message ---

Reply via email to