php-general Digest 15 Jun 2002 19:41:07 -0000 Issue 1407

Topics (messages 102319 through 102358):

Re: Evaluation.  Easy Question but I need some help
        102319 by: Jason Morehouse

Re: php server on Windows
        102320 by: Stuart Dallas

Downside to using login sessions?
        102321 by: Leif K-Brooks
        102322 by: Justin French
        102324 by: Leif K-Brooks
        102326 by: Nathan Taylor
        102327 by: Justin French

Re: Confusion with the $_name $_type $_size Variable Extensions
        102323 by: Nathan Taylor

PHP timeout
        102325 by: Kim Bauters
        102328 by: Nathan Taylor
        102329 by: Stuart Dallas
        102330 by: Kim Bauters
        102331 by: Stuart Dallas
        102333 by: Kim Bauters
        102357 by: Stuart Dallas

Re: Regular expression newbie question, convert this: [::word1 \" word2 \" word3::] to 
: ".word1 " word2 " word3."
        102332 by: Lance
        102344 by: Analysis & Solutions
        102356 by: Lance

Re: Change Password
        102334 by: Jason Morehouse

Re: Creatng a PHP chatroom
        102335 by: Jason Morehouse

Apache/2.0.36 + Win98 + PHP4=Error(31)
        102336 by: Prachait Saxena
        102338 by: Chris Garaffa
        102343 by: Stuart Dallas

Re: 'CC' and 'BCC' in mail function
        102337 by: Christoph Grottolo

massive find/replace on MySQL db
        102339 by: Steve Clay
        102340 by: Julie Meloni
        102342 by: Steve Clay
        102351 by: John Holmes

saving a jpeg via HTTP
        102341 by: Jeff Bearer
        102345 by: Nathan Taylor
        102349 by: Daniel Tryba
        102350 by: Daniel Tryba

Can't set a cookie?
        102346 by: Lazor, Ed
        102347 by: Julie Meloni
        102348 by: Nathan Taylor

Search - 'AND' ... 'OR'
        102352 by: Scott 'INtense!' Reismanis
        102354 by: Lazor, Ed

Re: Can't set a cookie? [SOLVED]
        102353 by: Lazor, Ed

Parsing Text File
        102355 by: Jason D. Williard

Can I use a template with this site?
        102358 by: Randum Ian

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 ---
<input type="checbox" value="1" name="check"<? if($_POST[check] == 1) {
print ' checked';}?>>

-J

On Sat, 15 Jun 2002 04:53:11 +1200, Dan McCullough wrote:

> I'm trying to evaluate form submissions.  When I return a form
> submission cause of a missing field I want the radio and checkboxes to
> reflect what the client submitted.  So if somone forgets to fill in
> their address, but has done everything else fine, I dont want them to
> have to refill out the form.
> 
> So how would I in PHP say if $var == "value1" then this radio button is
> checked?  And how do I do it and keeping the code compact?
> 
> =====
> -------------------------------------------------------- "Theres no such
> thing as a problem unless the servers are on fire!"
> 
> 
> __________________________________________________ Do You Yahoo!? Yahoo!
> - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com
 

-- 
 Jason Morehouse ([EMAIL PROTECTED])
 Netconcepts LTD, Auckland, New Zealand    
 * Linux: because rebooting is for adding hardware.
--- End Message ---
--- Begin Message ---
On Saturday, June 15, 2002 at 3:48:03 AM, you wrote:
> An opinion was requested, and I gave it.

And everyone is entitled to an opinion, but what you gave was the typical "down
with windows" response when you clearly have not evidence to back it up.

> I will make a few pointed comments and then I will stop wasting my time and
> the time of the others on this list.

I would also like to apologise to the other subscribers to this list, but I
feel that this is an important topic.

> 1) If you do not know why Unix and its various derivatives are a better,
> meaning more flexible, more secure, faster, and more stable, then you
> probably don't know much about Unix.

I maintain a mixture of Linux, FreeBSD and Win2k servers. I know a lot about the
Unix platform, it's structure and it's pros and cons. However, once again you
have made several claims about how it is 'better' than Win2k but without
evidence to back them up.

Why is Unix more flexible? I can't think of anything I can do on Unix but not
on Win2k. Why is it more secure? I have been running several Win2k servers for
nearly 2 years and am yet to have a major security problem (I am certain that
the reputation IIS has gained in relation to security is due to incompetent
admins, not the product - a side effect of making it relatively easy to
configure). Why is it more stable? Since Win2k was released I have managed
uptimes comparable to the Unix-based machines I maintain.

> 2) I don't consider any Windows platform stable for commercial serving
> needs. I've had Unix boxes run continuously for over 3 years some as many as
> 5 and only one time was the crash caused by the operating system. Want to
> tell me how many times you've seen the "blue screen of death" on a Windows
> box.

How many BSODs have I seen on any Windows box? Loads. How many have I seen on
the Win2k servers I maintain? None!

> 3) Unix is faster for two main reasons - it has a real file system and it
> doesn't have all GUI overhead cluttering up CPU/Disk/Bus resources. While
> the GUI if a great feature on development boxes and workstations its a
> complete waste of resources on a server.

'It has a real file system'. Meaning? I assume you mean ext2 which is a
non-journaling and therefore highly fragile file system. Compare this to NTFS
which is a journaling file system. The performance loss by adding the
journaling is minor but has major benefits.

Hmmm, the GUI. You mean the one that shows the login screen? That tiny stub
that takes up virtually no resources while it is waiting for a user to log in?
What you have said is like saying "don't install KDE on your server, it will
take up valuable resources whether you use it or not".

> 4) If all you need to do is design web sites Win 2000 (don't use the FAT32
> file system) / apache ( not 2.x) and PHP / Pearl / cgi is OK. But if you
> want to be a successful webmaster and provide your clients / bosses / end
> users with the best possible service / speed and uptime - learn and use
> Unix.

I am a successful sysadmin (at least my customers think so) and I do provide
the best 'possible service / speed and uptime' on both Unix and Win2k
platforms. Suffice to say that you are yet to convince me.

> 5) If you want to learn how to configure the hardware - I'll teach you that
> too. Just contact me off list.

What gave you the impression that I need help? I butcher and build machines
every day, but even if I did need help, I would be reluctant to accept it from
someone who can't spell Perl and doesn't even understand the purpose of /tmp on
the Unix platform.

> Nuff said.

Not quite. I would just like to say that I don't preach that either platform is
'better'. It all depends on the job in hand and I will choose a platform based
on my requirements. I would certainly not base my decision on the
foundation-less spoutings of someone on a mailing list (that includes me,
although I am trying to walk the neutral path). My only hope is that people
will stop dismissing one of the options because of a bad reputation that was
created many moons ago and will therefore take a while to counter.

-- 
Stuart

--- End Message ---
--- Begin Message ---
I am planning to change how my site stores logins to using sessions. 
 Are there any reasons not to do this?  Reasons against it I should 
know?  Thanks for your input.

--- End Message ---
--- Begin Message ---
How is it currently storing it?

Sessions are fine, depending on how the code is written, and the obviouse
downside to COOKIE based sessions is that they will break on non-cookie
browsers, so a smarter move is to use URL based sessions.

A more focused question will of course result in a more focused answer :)

Justin French


on 15/06/02 6:59 PM, Leif K-Brooks ([EMAIL PROTECTED]) wrote:

> I am planning to change how my site stores logins to using sessions.
> Are there any reasons not to do this?  Reasons against it I should
> know?  Thanks for your input.
> 

--- End Message ---
--- Begin Message ---
I'm currently storing the username and password directly in cookies (the 
password isn't even md5()'d).  I'm just wondering if there's security 
risks/whatever in sessions.  I've seen that most sites seem to store the 
login data directly in the cookie (with the password md5()'d).  Is that 
because there's something wrong with sessions, or did they just not use 
them for no reason?  Thanks.

Justin French wrote:

>How is it currently storing it?
>
>Sessions are fine, depending on how the code is written, and the obviouse
>downside to COOKIE based sessions is that they will break on non-cookie
>browsers, so a smarter move is to use URL based sessions.
>
>A more focused question will of course result in a more focused answer :)
>
>Justin French
>
>
>on 15/06/02 6:59 PM, Leif K-Brooks ([EMAIL PROTECTED]) wrote:
>
>  
>
>>I am planning to change how my site stores logins to using sessions.
>>Are there any reasons not to do this?  Reasons against it I should
>>know?  Thanks for your input.
>>
>>    
>>
>
>
>  
>

--- End Message ---
--- Begin Message ---

As a general rule it is always good to store data that is secure in a encrypted 
format.  My website for example uses a mysql database and I store the encrypted mysql 
password in the cookie so I get somethign like 435gcg34tsskhj57 to equal 123.  It's 
far more secure because cookies are on the user's computer and anything there is not 
secure, regardless of who the owner is.

----- Original Message -----
From: Leif K-Brooks
Sent: Saturday, June 15, 2002 5:53 AM
To: Justin French
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Downside to using login sessions?

I'm currently storing the username and password directly in cookies (the
password isn't even md5()'d).  I'm just wondering if there's security
risks/whatever in sessions.  I've seen that most sites seem to store the
login data directly in the cookie (with the password md5()'d).  Is that
because there's something wrong with sessions, or did they just not use
them for no reason?  Thanks.

Justin French wrote:

>How is it currently storing it?
>
>Sessions are fine, depending on how the code is written, and the obviouse
>downside to COOKIE based sessions is that they will break on non-cookie
>browsers, so a smarter move is to use URL based sessions.
>
>A more focused question will of course result in a more focused answer :)
>
>Justin French
>
>
>on 15/06/02 6:59 PM, Leif K-Brooks ([EMAIL PROTECTED]) wrote:
>
>
>
>>I am planning to change how my site stores logins to using sessions.
>>Are there any reasons not to do this?  Reasons against it I should
>>know?  Thanks for your input.
>>
>>
>>
>
>
>
>Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com
--- End Message ---
--- Begin Message ---
Well, all passwords on my sites are stored md5'd, so i'm comparing an md5()
of the password they have supplied with the one stored in the DB, so I don't
need to know what the original password was -- only if the two encrypted
passwords match.

Since md5() is one-way encryption, it makes sense to store the password in a
cookie this way as well, so that people digging around can't possibly figure
it out.

I guess leaving the password in plain text in the cookie opens a small
security hole which is unneccassary, as long as you're storing an encrypted
password in the database.


Justin French


on 15/06/02 7:51 PM, Leif K-Brooks ([EMAIL PROTECTED]) wrote:

> I'm currently storing the username and password directly in cookies (the
> password isn't even md5()'d).  I'm just wondering if there's security
> risks/whatever in sessions.  I've seen that most sites seem to store the
> login data directly in the cookie (with the password md5()'d).  Is that
> because there's something wrong with sessions, or did they just not use
> them for no reason?  Thanks.
> 
> Justin French wrote:
> 
>> How is it currently storing it?
>> 
>> Sessions are fine, depending on how the code is written, and the obviouse
>> downside to COOKIE based sessions is that they will break on non-cookie
>> browsers, so a smarter move is to use URL based sessions.
>> 
>> A more focused question will of course result in a more focused answer :)
>> 
>> Justin French
>> 
>> 
>> on 15/06/02 6:59 PM, Leif K-Brooks ([EMAIL PROTECTED]) wrote:
>> 
>> 
>> 
>>> I am planning to change how my site stores logins to using sessions.
>>> Are there any reasons not to do this?  Reasons against it I should
>>> know?  Thanks for your input.
>>> 
>>> 
>>> 
>> 
>> 
>> 
>> 
> 
> 

--- End Message ---
--- Begin Message ---
I know it has nothing to do with filesize because I am the server and I set the 
configuration.  But lemme show you some code, maybe that'll help.  Here we go:  

(please no ripping)
function MyFiles() {
global $username, $Upload, $Rename, $Delete, $PHP_SELF, $File, $File_size, $File_name, 
$File_type, $page, $src;
echo "<table bgcolor=#CCCCCC width=60% cellspacing=0 cellpadding=2 align=center>
<tr><th bgcolor=#888888 colspan=6>My Files</th></tr>";
$Folder = "article_files";
if(isset($src)) {
FileDetails($src);
Close();
}
if ($Upload) {
$File_name = strtolower($File_name);
$File_name = ereg_replace(" ","_","$File_name");
$File_name = ereg_replace("#","hash","$File_name");
$upfile = "../$Folder/$File_name";  
if($File_name == "$PHP_SELF" or $File_name == "resize_image.php" or $File_name == 
"login.php" or $File_name == "logout.php" or $File_name == "latest.txt" or 
eregi("index",$File_name)) {  
echo "<tr><td colspan=6 align=center>For security reasons, your file could not be 
uploaded.<p></td></td>\n";
}
elseif(copy($File,$upfile)) {
if(is_uploaded_file($File_name)) {
echo "<tr><td colspan=6 align=center><hr>Your file, <a href=$File_name>$File_name</a>, 
was successfully uploaded.</td></tr>\n";
FileDetails($File_name);
$time = time();
$query = "insert into article_files 
values(null,'$username','$File_name','$File_size','$File_type','$time')";
mysql_query($query);
} else {
echo "<tr><td colspan=6 align=center>Your file was not copied.</td></td>\n";
}
}
//unlink ($File);
Close();
}
if($Delete) {  
for($i=0; $i<count($Delete); $i++) {
echo "<tr><td colspan=6 align=center><hr></td></tr>";
if(unlink("$Delete[$i]")) {
echo "<tr><td colspan=6 align=center>Your file, $Delete[$i], was successfully 
deleted.</td></tr>\n";
} else {
echo "<tr><td colspan=6 align=center>Your file, $Delete[$i], could not be 
deleted.</td></tr>\n";
}
}
Close();
}
if($Rename) { // Handle file renaming
for($n = 0; $n < count($Rename); $n++) {
$OldFilename = $Rename[$n];
$NewName[$OldFilename] = strtolower($NewName[$OldFilename]);
$NewName[$OldFilename] = ereg_replace(" ","_","$NewName[$OldFilename]");
$NewName[$OldFilename] = ereg_replace("#","number","$NewName[$OldFilename]");
$Old = "$OldFilename";
$New = "$NewName[$OldFilename]";
echo "<tr><td colspan=6 align=center><hr></td></tr>";
if(rename($Old, $New)) {
echo "<tr><td colspan=6 align=center>Your file, $Rename[$n], was successfully renamed 
to <a href=$NewName[$OldFilename]>$NewName[$OldFilename]</a>.</td></tr>\n";
} elseif($New=="manage.php" or $New=="index.php" or $New=="index.html" or 
$New=="index.htm" or $New=="index.shtml" or $New=="index.shtm" or $New=="index.asp" or 
$New=="login.php" or $New=="logout.php" or $New=="files.php" or 
$New=="resize_image.php" or $New=="latest.txt") {
echo "<tr><td colspan=6 align=center>Your file, $Rename[$n], could not be 
renamed.</td></tr>\n";
} else {
echo "<tr><td colspan=6 align=center>Your file, $Rename[$n], could not be 
renamed.</td></tr>\n";
}
}
Close();
}
echo "<form action=$PHP_SELF method=post enctype=multipart/form-data>\n
<tr><td><b>File Name</b></td><td><b>File 
Size</b></td><td><b>Added</b></td><td><b>Delete</b></td><td><b>Rename</b> (Enter new 
name in the box)</td><td><b>Details</b></td></tr>\n";
$query = "select * from article_files where owner='$username' order by filename asc";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
$Size = $row[filesize];
$Size = $Size/1023;
if($Size < 1023){
$Size = number_format($Size, 2);
$Size = $Size." kb";
} else {
$Size = $Size/1023;
$Size = number_format($Size, 2);
$Size = $Size." mb";
}
$type = GetExtension($row[filename]);
if($type == "jpg" or $type == "gif" or $type == "png" or $type == "txt" or $type == 
"sql")
$details = "<a href=$PHP_SELF?page=$page&src=$row[filename]>Details</a>";
else
$details = "N/A";
$Date = date("m/d/y", $row[filedate]);
echo "<tr>
<td><a href=../$Folder/$row[filename]>$row[filename]</td>
<td>$Size</td>
<td>$Date</td>
<td>  
<input type=checkbox name=Delete[] value=\"$row[filename]\">
</td>
<td>  
<input type=checkbox name=Rename[] value=\"$row[filename]\">
<input type=text name=NewName[$row[filename]]>
</td>
<td>
$details
</td>
</tr>";
}
echo "<tr><td colspan=6 align=center>&nbsp;</td></tr>";
echo "<tr><td colspan=6 align=center><hr></td></tr>";
echo "<tr>
<td colspan=6 align=center>  
<input type=checkbox name=Upload value=Yes>
Upload a file:  
<input type=file name=File size=20>
</td>
</tr>
<tr>  
<td colspan=6 align=center>  
<input type=hidden name=page value=$page>
<input type=submit name=myfiles_submit value=Submit>
</form>
</tr>
</form>
</table>\n
}

All that is included within a main program and when you send data out from this it 
gets looped back into itself with the global statements, that's the idea anyway.  
However, $File_name always turns up null, (as well as the other operators) which makes 
uploading not possible.
----- Original Message -----
From: SenthilVelavan
Sent: Friday, June 14, 2002 10:49 PM
To: Nathan Taylor; php-general
Subject: Re: [PHP] Confusion with the $_name $_type $_size Variable Extensions

-Lakario,
                Please have a look on
http://www.php.net/manual/en/features.file-upload.php  for more information
on fileuploads in php.Also check with the size of the files you have
transferred.When file size is large, then your files won't get uploaded.This
is due to the low execution time,If you don't mind please send your programs
to dig more.
regards,
SenthilVelavan.P

----- Original Message -----
From: "Nathan Taylor" <[EMAIL PROTECTED]>
To: "php-general" <[EMAIL PROTECTED]>
Sent: Saturday, June 15, 2002 6:46 AM
Subject: [PHP] Confusion with the $_name $_type $_size Variable Extensions


I am having a lot of trouble with the $_name, $_size, and $_type
variable extensions.  I have a basic file upload system however it is
within a function.  Sometimes when I declare the aforementioned
variables in a global statement such as global $file_name I can get a
value for _name, other times, I get nothing.  Can someone clarify
this because I was unable to find anything in the manual?

Cheers,
------------
Lakario
ModDev.netGet more from the Web.  FREE MSN Explorer download :
http://explorer.msn.com



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpGet more from the Web.  FREE MSN 
Explorer download : http://explorer.msn.com
--- End Message ---
--- Begin Message ---
I'm running PHP script that check for the existance of certain pages on the
web. The problem is that fopen to check for the existance of a page and this
seems to consume time. It has to check for a nuber of pages, conforming to a
certain pattern. This pattern is Ab#####

What I want to do is extend the time a script is allowed to run (because I
can only check 10 pages, then need to change the code for the next pages)
but I don't seem to be able to do this. I'm using Windows 2000 and PHP is
installed on my IIS server. In the file php.ini, the 2 timeout settings are
both changed from 30 to 300, but I keep on getting an error like "CGI script
Timeout".

Can anyone help?


--- End Message ---
--- Begin Message ---
Hmm, I haven't heard of such a thing. That's kinda weird though because just yesterday 
I modified my timeout settings for my script that parses logfiles that are several 
thousand lines long, and it worked. Did you perhaps forget to reboot the server? If 
you have my suggestion is perhaps taking a look at FoxServ, it is a very good server 
that auto configures itself on your machine with apache and the whole lot.   
www.foxserv.net   

----- Original Message -----
From: Kim Bauters
Sent: Saturday, June 15, 2002 5:55 AM
To: [EMAIL PROTECTED]
Subject: [PHP] PHP timeout

I'm running PHP script that check for the existance of certain pages on the
web. The problem is that fopen to check for the existance of a page and this
seems to consume time. It has to check for a nuber of pages, conforming to a
certain pattern. This pattern is Ab#####

What I want to do is extend the time a script is allowed to run (because I
can only check 10 pages, then need to change the code for the next pages)
but I don't seem to be able to do this. I'm using Windows 2000 and PHP is
installed on my IIS server. In the file php.ini, the 2 timeout settings are
both changed from 30 to 300, but I keep on getting an error like "CGI script
Timeout".

Can anyone help?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpGet more from the Web.  FREE MSN 
Explorer download : http://explorer.msn.com
--- End Message ---
--- Begin Message ---
On Saturday, June 15, 2002 at 10:52:14 AM, Kim Bauters wrote:
> In the file php.ini, the 2 timeout settings are
> both changed from 30 to 300, but I keep on getting an error like "CGI script
> Timeout".

I think you'll find that's the IIS CGI timeout, not PHPs. You can find that
setting in the site properties, Home Directory tab, click on the Configuration
button, then go to the Process Options tab. At the bottom of that tab you
should have a CGI script timeout value. Try increasing that.

-- 
Stuart

--- End Message ---
--- Begin Message ---
Hi,
indeed, it is a IIS CGI timeout. However, when I take a look at the tab you
gave me, I can only seem to find the tabs called "App Mappings", "App
Options" and "App Debugging". Is this the right place and is the tab just
missing or is there a problem on my behalf?

thx

"Stuart Dallas" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Saturday, June 15, 2002 at 10:52:14 AM, Kim Bauters wrote:
> > In the file php.ini, the 2 timeout settings are
> > both changed from 30 to 300, but I keep on getting an error like "CGI
script
> > Timeout".
>
> I think you'll find that's the IIS CGI timeout, not PHPs. You can find
that
> setting in the site properties, Home Directory tab, click on the
Configuration
> button, then go to the Process Options tab. At the bottom of that tab you
> should have a CGI script timeout value. Try increasing that.
>
> --
> Stuart
>


--- End Message ---
--- Begin Message ---
On Saturday, June 15, 2002 at 11:43:05 AM, Kim Bauters wrote:
> indeed, it is a IIS CGI timeout. However, when I take a look at the tab you
> gave me, I can only seem to find the tabs called "App Mappings", "App
> Options" and "App Debugging". Is this the right place and is the tab just
> missing or is there a problem on my behalf?

What version of IIS are you running? It may be in a different place on your
server.

-- 
Stuart

--- End Message ---
--- Begin Message ---
hi,
My IIS version is 5.0

"Stuart Dallas" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Saturday, June 15, 2002 at 11:43:05 AM, Kim Bauters wrote:
> > indeed, it is a IIS CGI timeout. However, when I take a look at the tab
you
> > gave me, I can only seem to find the tabs called "App Mappings", "App
> > Options" and "App Debugging". Is this the right place and is the tab
just
> > missing or is there a problem on my behalf?
>
> What version of IIS are you running? It may be in a different place on
your
> server.
>
> --
> Stuart
>


--- End Message ---
--- Begin Message ---
On Saturday, June 15, 2002 at 11:58:44 AM, Kim Bauters wrote:
> My IIS version is 5.0

Hmm, same as mine. Have a look in the master properties of the server. If it's
not there then I suggest you search the MS site for help.

-- 
Stuart

--- End Message ---
--- Begin Message ---
hi, thanks for the code. i tried. it only worked if the string is simply 
the one i wanna convert. but that particular string is in the middle of 
a long text, and there are multiple occurance, it won't.

however, i did manage to come up with this code that worked. but i 
believe it can be improved on. it will identify all occurance of the 
specified pattern and do the necessary replacement throughout the whole 
string.

preg_match_all("|\[::(.*)::\]|U", $longTxt, $matchedResult);
for ($idx = 0; $idx < count($matchedResult[1]); $idx++) {
        $extract = stripslashes($matchedResult[1][$idx]);
        $longTxt = str_replace("[::{$matchedResult[1][$idx]}::]", 
"\".$extract.\"", $longTxt);
}

lance

Analysis & Solutions wrote:
> Lance:
> 
> On Fri, Jun 14, 2002 at 11:41:34PM +0800, Lance wrote:
> 
>>[::word1 \" word2 \" word3::]
>>to:
>>".word1 " word2 " word3."
> 
> 
> While I don't know if this is really what you need, it does do exactly 
> what you want to do in your example:
> 
>    $Replace['\\']  = '';
>    $Replace['::']   = '.';
>    $Replace['[']   = '';
>    $Replace[']'] = '';
> 
>    $UserInput = '[::word1 \" word2 \" word3::]';
> 
>    echo strtr($UserInput, $Replace);
> 
> --Dan
> 

--- End Message ---
--- Begin Message ---
Hi Lance:

On Sat, Jun 15, 2002 at 06:54:24PM +0800, Lance wrote:
> hi, thanks for the code. i tried. it only worked if the string is simply 
> the one i wanna convert. but that particular string is in the middle of 
> a long text, and there are multiple occurance, it won't.

Strange.  It should work regardless of length.

Couple things.  Could you please provide an example of the text you're 
trying to convert and explain why you have this weird format and why 
you need the other unusual format.  We may be able to come up with 
something far more straight forward.

--Dan

--
               PHP classes that make web design easier
        SQL Solution  |   Layout Solution   |  Form Solution
    sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY     v: 718-854-0335     f: 718-854-0409
--- End Message ---
--- Begin Message ---
hi,

i was developing an application that will read in the content of a html 
file. and within this html file contains php variables which will be 
replaced using the eval() function with its required value. and within 
this html, i want to be able to run php functions. however, due to the 
fact that characters need to be escaped so that eval() can process it, i 
have to make use of addslashes() to escape all " that are embedded in 
the html file.

with the " escaped, eval() will be able to work and evaluate the php 
variable and instead of:

eval("\$rs = \"<span class="normal">$phpVar</span>\";"); (won't work)

it will now be:
eval("\$rs = \"<span class=\"normal\">$phpVar</span>\";"); (work)

and to call a date() function on the above text, this format will work:

eval("\$rs = \"<span class=\"normal\">".date("m d y")."$phpVar</span>\";");

since the text that is passed into eval() came from a html/php/inc 
(whatever you name it) file, there is no way you will know that a 
particular text is in fact a php function.

so i thought of prefixing and suffixing php function with [::date("m d 
y")::] and it will be helpful in the sense that the application will 
know that oh, this is a php function, i need to ".  ." it so that eval 
will not throw me an error.

with that, now the html file's content will be something like:
<span class="normal">[::date("m d y",$phpVar)::]</span>

after using addslashes(), it will be:
<span class=\"normal\">[::date(\"m d y\",$phpVar)::]</span>

for the above text, in order for eval() to parse correctly, it has to be 
in this format:
eval("\$rs = \"<span class=\"normal\">".date("m d y",$phpVar)."</span>\";")

and there is always a chance that the html text could contain more than 
1 block of [:: phpfunction ::]

thats why i came up with that piece of code to convert the text to a 
string that eval will be able to understand. and at the end of it, i 
will be echoing $rs to display the final result.

you probably will wonder why dont i use include() and require()? that 
way, php will be handling all the above without requiring additional 
work. however, due to the way the result has to be handled, i couldn't 
use include nor require.

lance

--- End Message ---
--- Begin Message ---
No practical way I know of w/ PHP...

Try (Perl):

http://search.cpan.org/doc/SSNODGRA/Unix-ConfigFile-0.06/PasswdFile.pm

Though I wouldn't be able to sleep at night knowing browsers had access to the passwd 
file!

Cheers,
-J

On Fri, 14 Jun 2002 10:08:56 +1200, Brian V Bonini wrote:

> Anyone know of a script that will allow a user to change their
> system/email password form the web on a UNIX system. wither PHP or Perl
> based?
> 
> -B
 

-- 
 Jason Morehouse ([EMAIL PROTECTED])
 Netconcepts LTD, Auckland, New Zealand    
 * Linux: because rebooting is for adding hardware.
--- End Message ---
--- Begin Message ---
http://stutter.screwdriver.net is a good clean example.

-J


On Thu, 13 Jun 2002 12:02:12 +1200, Phil Powell wrote:

> I am intrested in creating a chatroom entirely in PHP involving
> streaming text.  Where can someone help me to find such a means of doing
> so?
> 
> Thanx
> Phil
> http://valsignalandet.com
 

-- 
 Jason Morehouse ([EMAIL PROTECTED])
 Netconcepts LTD, Auckland, New Zealand    
 * Linux: because rebooting is for adding hardware.
--- End Message ---
--- Begin Message ---
Hello !!!

I am using Apache/2.0.36 (Win32) DAV/2 on Win98.
my server  is running very fine when i use PHP4 as a interpreter.
but as i use " LoadModule  " to use PHP4 as a modules i am getting the
error as
(31) A device attached to the system is not functioning:

This error also come when i try to load SSL
I also tried to run server on Win 2k. Same error :(


Can any one help me out. why this error is comming ?

Or where i am wrong ?

Thanks is advance
Prachait Saxena
WebMaster [SitesOnTesting.Com]

If you do for other's ! Other's will do for you !!
Visit me at http://www.sitesontesting.com/prachait



--- End Message ---
--- Begin Message ---
Prachait,
If I recall correctly, PHP 4.x doesn't work with Apache 2... Actually, no
Apache 1.x modules do, because of the new apxs architechture. Apache 2
support is planned for the 4.3 release (someone correct me if I'm wrong).
On UNIX, I compiled with a -apxs2=[path] option to the configure script, but
I'm not sure on Windows...

Chris Garaffa

On 6/15/02 10:24 AM, "Prachait Saxena" <[EMAIL PROTECTED]> wrote:

> Hello !!!
> 
> I am using Apache/2.0.36 (Win32) DAV/2 on Win98.
> my server  is running very fine when i use PHP4 as a interpreter.
> but as i use " LoadModule  " to use PHP4 as a modules i am getting the
> error as
> (31) A device attached to the system is not functioning:
> 
> This error also come when i try to load SSL
> I also tried to run server on Win 2k. Same error :(
> 
> 
> Can any one help me out. why this error is comming ?
> 
> Or where i am wrong ?
> 
> Thanks is advance
> Prachait Saxena
> WebMaster [SitesOnTesting.Com]
> 
> If you do for other's ! Other's will do for you !!
> Visit me at http://www.sitesontesting.com/prachait
> 
> 
> 

--- End Message ---
--- Begin Message ---
On Saturday, June 15, 2002 at 3:34:06 PM, Chris Garaffa wrote:
> If I recall correctly, PHP 4.x doesn't work with Apache 2

There is a module specifically for Apache 2 in PHP 4.2.0 onwards. I'm not sure
what error using the module for Apache 1.3.x would produce. This could be the
problem. The Apache 2 module is still experimental and should not be used in a
production environment.

-- 
Stuart

--- End Message ---
--- Begin Message ---
Stuart Dallas wrote:
> On Friday, June 14, 2002 at 10:01:24 PM, Sridhar Moparthy wrote:
>> Does any one know how to make mail() function to send mail to 'CC'
>> and 'BCC' address. I have tried to keep 'CC' and BCC' in header, but
>> it is not working. Mail function is sending the message to 'To'
>> address but not to 'CC' and 'BCC'. <snip
>>         if (mail($to,$subject,$message,$header)) <snip>
> 
> The mail function sends the message to the addresses in the first
> parameter, so you need to specify all the users you want the message
> to go to in $to. 
> 
> PS. I (and I'm sure there are others) would prefer it if you could
> create a new thread for a new topic. It makes things a lot easier to
> follow. 

--- End Message ---
--- Begin Message ---
Hello,

I've inherited a MySQL db (4MB on disk) that's riddled with
inconsistent storage of character entities from being pasted from
Word.  At very least I hope to convert all quotes "&#145;" - "&#148;"
to HTML's "&#34;" and "&#39;".

I imagine I'll run a big query, save the id's needing edit in a file
than have a script hit all those, pulling text/varchar fields, using
strtr() to make changes and updating.  I suppose I could have the
script just do the 1st 10 in the file, remove those from the file,
then I'd recall the script.  I imagine this might take 10/20 minutes.

Am I missing some internal MySQL feature that would do this?  Hmm,
what about running strtr() on a mysqldump-ed file?  Any advice/links
appreciated.  Please CC me.

Thanks a lot!

Steve
-- 
[EMAIL PROTECTED] ** http://mrclay.org

--- End Message ---
--- Begin Message ---
SC> I've inherited a MySQL db (4MB on disk) that's riddled with
SC> inconsistent storage of character entities from being pasted from
SC> Word.  At very least I hope to convert all quotes "&#145;" - "&#148;"
SC> to HTML's "&#34;" and "&#39;".

For each entity you wanted to replace, you could:

update tablename set fieldwithcrap = replace(fieldwithcrap,
'oldstring', 'newstring');

Keep an eye on all your escaping and what not.  And do a dump before
you do all your replacing, just in case something goes awry.

If that doesn't work well, then I'd probably dump the data, run it
through a string replacing script, and load it all back in.  That
wouldn't take too long either.

- Julie

--> Julie Meloni
--> [EMAIL PROTECTED]
--> www.thickbook.com

Find "Sams Teach Yourself MySQL in 24 Hours" at
http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20

--- End Message ---
--- Begin Message ---
Saturday, June 15, 2002, 11:11:49 AM, Julie wrote:

JM> update tablename set fieldwithcrap = replace(fieldwithcrap,
JM> 'oldstring', 'newstring');

Julie, lovely solution and shockingly fast.  Thanks.

Steve
-- 
[EMAIL PROTECTED] ** http://mrclay.org

--- End Message ---
--- Begin Message ---
Yeah, do it all with regular queries. You shouldn't have to do any
replacing in PHP. You can even use the MySQL regular expressions in your
query for some more complex matching and replacing...

It's all in the manual...

---John Holmes...

> -----Original Message-----
> From: Julie Meloni [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, June 15, 2002 11:12 AM
> To: Steve Clay
> Cc: PHP-GENERAL
> Subject: Re: [PHP] massive find/replace on MySQL db
> 
> SC> I've inherited a MySQL db (4MB on disk) that's riddled with
> SC> inconsistent storage of character entities from being pasted from
> SC> Word.  At very least I hope to convert all quotes "&#145;" -
"&#148;"
> SC> to HTML's "&#34;" and "&#39;".
> 
> For each entity you wanted to replace, you could:
> 
> update tablename set fieldwithcrap = replace(fieldwithcrap,
> 'oldstring', 'newstring');
> 
> Keep an eye on all your escaping and what not.  And do a dump before
> you do all your replacing, just in case something goes awry.
> 
> If that doesn't work well, then I'd probably dump the data, run it
> through a string replacing script, and load it all back in.  That
> wouldn't take too long either.
> 
> - Julie
> 
> --> Julie Meloni
> --> [EMAIL PROTECTED]
> --> www.thickbook.com
> 
> Find "Sams Teach Yourself MySQL in 24 Hours" at
> http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
What is the best way using only PHP to grab a image file off a website a
d save it locally?  I know I can use wget and this would be a piece of
cake, but in this case I don't want to rely on external programs.

I'm trying to read it with fsockopen and writing it with fopen to the
file  but the file is no good when it's saved, I saw that it saved the
http headers in there so I cut those out but still, the image wan't
viewable.

I was using fsockopen instead of file because I want to use the timeout
feature of fsockopen.

any help is appriciated.

-- 
Jeff Bearer, RHCE
Webmaster, PittsburghLIVE.com
2002 EPpy Award, Best Online U.S. Newspaper
--- End Message ---
--- Begin Message ---
Perhaps you could try a cURL or some other FTP approach?

----- Original Message -----
From: Jeff Bearer
Sent: Saturday, June 15, 2002 11:16 AM
To: [EMAIL PROTECTED]
Subject: [PHP] saving a jpeg via HTTP

What is the best way using only PHP to grab a image file off a website a
d save it locally?  I know I can use wget and this would be a piece of
cake, but in this case I don't want to rely on external programs.

I'm trying to read it with fsockopen and writing it with fopen to the
file  but the file is no good when it's saved, I saw that it saved the
http headers in there so I cut those out but still, the image wan't
viewable.

I was using fsockopen instead of file because I want to use the timeout
feature of fsockopen.

any help is appriciated.

--
Jeff Bearer, RHCE
Webmaster, PittsburghLIVE.com
2002 EPpy Award, Best Online U.S. Newspaper

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpGet more from the Web.  FREE MSN 
Explorer download : http://explorer.msn.com
--- End Message ---
--- Begin Message ---
On Sat, Jun 15, 2002 at 11:15:42AM -0400, Jeff Bearer wrote:
> I'm trying to read it with fsockopen and writing it with fopen to the
> file  but the file is no good when it's saved, I saw that it saved the
> http headers in there so I cut those out but still, the image wan't
> viewable.

Are you using the binary safe fread/fwrite()? Didn't forget to fclose()
the output file?

This works for me:

<?php
if($fi=fsockopen("host",80))
{
   fputs($fi,"GET /image.gif HTTP/1.0\r\n\r\n");

   while(!preg_match("/^\r?\n$/",fgets($fi,1024))); //skip headers

   while(!feof($fi))
   {
      if($fo=fopen("/tmp/tmp.gif","w"))
      {
         while(!feof($fi))
         {
            fwrite($fo,fread($fi,65535));
         }
 
         fclose($fo);
      }
   }

   fclose($fi);
}
?>

-- 

  Daniel Tryba

--- End Message ---
--- Begin Message ---
On Sat, Jun 15, 2002 at 06:02:58PM +0200, Daniel Tryba wrote:
> This works for me:

Hmmm, one while(!feof()) to many.... not that it really matters :)

<?php
if($fi=fsockopen("host",80))
{
   fputs($fi,"GET /image.gif HTTP/1.0\r\n\r\n");

   while(!preg_match("/^\r?\n$/",fgets($fi,1024))); //skip headers

   if($fo=fopen("/tmp/tmp.gif","w"))
   {
      while(!feof($fi))
      {
         fwrite($fo,fread($fi,65535));
      }
 
      fclose($fo);
   }

   fclose($fi);
}
?>

-- 

  Daniel Tryba

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

Any idea why I'm getting this error?

Warning: setcookie() expects parameter 3 to be long, string given in *my
script* on line 2

Here's the entire script generating the error:

<?php
setcookie("mytest", 1, "", "/");
?>

The script doesn't work on a new hosting service I subscribed to, but it
works on two other servers - 1 linux and 1 windows, both with Apache 1.3.24.
I'm looking for what version the hosting service is using... their support
page says "PHP4 with Zend Optimizer".  The other two servers are using PHP
4.1.1.

Any ideas of what's going on?

-Ed
 
****************************************************************************
This message is intended for the sole use of the individual and entity to
whom it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  If you are
not the intended addressee, nor authorized to receive for the intended
addressee, you are hereby notified that you may not use, copy, disclose or
distribute to anyone the message or any information contained in the
message.  If you have received this message in error, please immediately
advise the sender by reply email and delete the message.  Thank you very
much.                                                                       
--- End Message ---
--- Begin Message ---
LE> Any idea why I'm getting this error?

LE> Warning: setcookie() expects parameter 3 to be long, string given in *my
LE> script* on line 2

LE> setcookie("mytest", 1, "", "/");

It needs the time to be something not null.  If you mean to set 0, use
"0" instead of "".  Or, time()+somenum (not in quotes).


- Julie

--> Julie Meloni
--> [EMAIL PROTECTED]
--> www.thickbook.com

Find "Sams Teach Yourself MySQL in 24 Hours" at
http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20

--- End Message ---
--- Begin Message ---
The 3rd parameter is an optional time to expire parameter, if you don't want to set 
it, leave it out.  setcookie(cookiename,"value");  works fine

----- Original Message -----
From: Lazor, Ed
Sent: Saturday, June 15, 2002 11:48 AM
To: php-general
Subject: [PHP] Can't set a cookie?

Hi Everyone,

Any idea why I'm getting this error?

Warning: setcookie() expects parameter 3 to be long, string given in *my
script* on line 2

Here's the entire script generating the error:

<?php
setcookie("mytest", 1, "", "/");
?>

The script doesn't work on a new hosting service I subscribed to, but it
works on two other servers - 1 linux and 1 windows, both with Apache 1.3.24.
I'm looking for what version the hosting service is using... their support
page says "PHP4 with Zend Optimizer".  The other two servers are using PHP
4.1.1.

Any ideas of what's going on?

-Ed

****************************************************************************
This message is intended for the sole use of the individual and entity to
whom it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  If you are
not the intended addressee, nor authorized to receive for the intended
addressee, you are hereby notified that you may not use, copy, disclose or
distribute to anyone the message or any information contained in the
message.  If you have received this message in error, please immediately
advise the sender by reply email and delete the message.  Thank you very
much.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpGet more from the Web.  FREE MSN 
Explorer download : http://explorer.msn.com
--- End Message ---
--- Begin Message ---
Hey all,
 
I am in the middle of writing a script to allow users to search through
news archives on my website. Anyhow I am just wondering which logic you
believe best suits a search.
 
i.e. say a user types in 'games AND playstation' then only results
containing both those words will be returned
by the same token they could type in 'games OR playstation' then results
containing either word will be returned
 
However if a user does not explicity join there search critiera
i.e. 'games playstation' what should I assume?
 
What would you expect? Google for example wacks an 'AND' inbetween which
is wise considering they are searching billions of pages however my site
obviously will only be searching a few hundred so maybe I should assume
an 'OR'?
 
So basically I just am curious to know what you would expect when
entering multiple critera.
 
            Regards,
 
 
                   Scott
 
--- End Message ---
--- Begin Message ---
Funny.  I asked a very similar question the other day.  Jason Morehouse was
nice enough to offer this advice:

If you use fulltext search (assuming you are using MySQL), it deals with
stop
words on its own as well as some additional search logic.

http://www.mysql.com/doc/F/u/Fulltext_Search.html

-J



> -----Original Message-----
> From: Scott 'INtense!' Reismanis [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, June 16, 2002 2:36 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Search - 'AND' ... 'OR'
> 
> 
> Hey all,
>  
> I am in the middle of writing a script to allow users to 
> search through
> news archives on my website. Anyhow I am just wondering which 
> logic you
> believe best suits a search.
>  
> i.e. say a user types in 'games AND playstation' then only results
> containing both those words will be returned
> by the same token they could type in 'games OR playstation' 
> then results
> containing either word will be returned
>  
> However if a user does not explicity join there search critiera
> i.e. 'games playstation' what should I assume?
>  
> What would you expect? Google for example wacks an 'AND' 
> inbetween which
> is wise considering they are searching billions of pages 
> however my site
> obviously will only be searching a few hundred so maybe I 
> should assume
> an 'OR'?
>  
> So basically I just am curious to know what you would expect when
> entering multiple critera.
>  
>             Regards,
>  
>  
>                    Scott
>  
> 
 
****************************************************************************
This message is intended for the sole use of the individual and entity to
whom it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  If you are
not the intended addressee, nor authorized to receive for the intended
addressee, you are hereby notified that you may not use, copy, disclose or
distribute to anyone the message or any information contained in the
message.  If you have received this message in error, please immediately
advise the sender by reply email and delete the message.  Thank you very
much.                                                                       
--- End Message ---
--- Begin Message ---
Thanks for your help Everyone =)
 
I needed the 3rd parameter set in order to specify the fourth "/", because
the cookie is being set by a script located in a sub-directory.  One of the
old documents I read said "" would work as the third parameter - and it did
on my old servers.  Setting the third parameter to 0 worked on all servers.

-----Original Message-----

The 3rd parameter is an optional time to expire parameter, if you don't want
to set it, leave it out.  setcookie(cookiename,"value");  works fine

 
****************************************************************************
This message is intended for the sole use of the individual and entity to
whom it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  If you are
not the intended addressee, nor authorized to receive for the intended
addressee, you are hereby notified that you may not use, copy, disclose or
distribute to anyone the message or any information contained in the
message.  If you have received this message in error, please immediately
advise the sender by reply email and delete the message.  Thank you very
much.                                                                       
--- End Message ---
--- Begin Message ---
I am trying to input data from a text file into a MySQL database and would
like to be able to input the data using a single script.  What's the easiest
way to parse a line, such as below, and turn it into variables to be placed
in the database.  While I can simply place the data in by importing from a
file, it's not quite so easy.  I only need to place some of the data in,
plus I would like to split one of the fields.  Below is an example of a line
from the file, and then the variables that I need to enter.

Here is an example of a line from the file:
Number,City,State,Country,Provider,Isdn,56K,CreateDate,Active,Timezone,ModDa
te,ModNote
403 -770 -4904 ,CALGARY,AB,CAN,T2,Y,Y,Apr 29 2002
12:00:00:000AM,I,GMT-0700,,

As for variables, I need the following:
Split Number into $AreaCode & $Number > 403 & 770-4904
$City
$State
$Country

Thanks for any help.

Jason D. Williard




--- End Message ---
--- Begin Message ---
Hi All, Hope you are all well.

I am coding a website for a client and they involve a series of files:

logobanner.php
navbar.php
leftmenu.php
main.php
rightmenu.php
copyright.php

These are all just simple HTML files which are placed in a Global dir apart
from main.php which is in the same dir as the index.php file. Is there a way
where I can have one index.php file which calls all the Global files and
only the relevant main.php file? Kind of like a simple template system?

For example at the moment I have this for my dir pattern:

/global/
-logobanner.php
-navbar.php
-leftmenu.php
-rightmenu.php
-copyright.php
/home/
-index.php
-main.php
/news/
-index.php
-main.php

When /news/index.php is called, all the global files are called along with
the main.php that is in the News dir, the same for all the others in their
respective dirs.

Am I overlooking an important function or script that can do this without
being too complicated?

Please let me know, Ian.
---
Randum Ian
DJ / Reviewer / Webmaster, DancePortal (UK) Limited
[EMAIL PROTECTED]
http://www.danceportal.co.uk
DancePortal.co.uk - Global dance music media

--- End Message ---

Reply via email to