php-general Digest 3 May 2005 08:08:51 -0000 Issue 3432
Topics (messages 214351 through 214370):
setting condition problem
214351 by: Ahmed Abdel-Aliem
Re: handling a user pressing browser's back button
214352 by: James
214353 by: James
Re: Can someone help me build a regular expression?
214354 by: mwestern.sola.com.au
214355 by: Rory Browne
214356 by: Jochem Maas
Re: Newbie Help
214357 by: Thomas Bonham
214358 by: Thomas Bonham
Re: php class that allow quick row ordering
214359 by: Jochem Maas
Re: Persistent Database Connections
214360 by: Jochem Maas
MySQLi group
214361 by: john
forms
214362 by: Lisa A
SSL Cores
214363 by: Oluwatope Akinniyi
php newbie question with xml files
214364 by: Jared Sherman
Re: Is it possible to save a file with UTF-8 encoding and noBOMusing PHP?
214365 by: Jon M.
214368 by: Jon M.
214369 by: Jon M.
is this possible in PHP?
214366 by: Dasmeet Singh
214367 by: Kim Madsen
214370 by: Rasmus Lerdorf
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 ---
hi all
i have a query that grabs records from the database, it works fine,
but i have a problem with acondition i want to set for it
the variable $Record[Relate] has 1 of 2 values, "self" or "share"
what i wanna do is that when the variable has the value "share" it do
check the records grabbed and get the other records that has the value
share and $Record[Title] the same and display them once,
i don't know how to start doing this,
can anyone guide me or tell me how to do it
thanks in advance
here is the query
<?
$Query = "SELECT ID FROM projects";
$Result= mysql_query($Query);
$Total_Numbers = mysql_num_rows($Result);
$StartingID=$_GET['StartingID'];
$StartingID = ($StartingID) ? $StartingID : 0; //if rec is passed in, use it,
$Row = array();
$Query = mysql_query("SELECT * FROM projects ORDER BY ID DESC LIMIT
$StartingID,$Items_Numbers");
$Num = mysql_num_rows($Query);
while ($Record=mysql_fetch_array($Query)){
$Record[ID] = stripslashes($Record[ID]);
$Record[User] = stripslashes($Record[User]);
$Record[Relate] = stripslashes($Record[Relate]);
$Record[Thumb] = stripslashes($Record[Thumb]);
$Record[Shot] = stripslashes($Record[Shot]);
$Record[Title] = stripslashes($Record[Title]);
$Record[Link] = stripslashes($Record[Link]);
$Record[Type] = stripslashes($Record[Type]);
$Record[Skill] = stripslashes($Record[Skill]);
$Record[Info] = stripslashes($Record[Info]);
$Record[Time] = stripslashes($Record[Time]);
$Record[Date] = stripslashes($Record[Date]);
$Record[Rate] = stripslashes($Record[Rate]);
$Record[Raters] = stripslashes($Record[Raters]);
$Row[] = $Record;
}
$Next = $StartingID+$Items_Numbers;
$Prev = $StartingID-$Items_Numbers;
?>
--- End Message ---
--- Begin Message ---
Thank you guys for the answers. I think I will go with the following approach.
(A) script 1 submits to script 2 then
(B) script 2 redirects browser back to script 1
Script 1 is in charge of submitting and displaying; script 2 does the
processing.
This list is the best!
-James
At 2:08 AM +0000 4/27/05, Matthew Weier O'Phinney wrote:
* James <[EMAIL PROTECTED]>:
I apologize in advance if I'm asking basic questions...
When you hit the back button, won't the browser just take the page
from the cache?
I haven't switched my POSTs to GETs and this is what I'm seeing.
I have a list of images. There are check boxes next to the images.
When the user checks images and clicks on a DELETE CHECKED link, a
new list is shown (minus the ones deleted.) When the user hits the
BACK button, I see the list again with checks next to the previous
images marked for deletion
By the way... the rule of thumb I think about is this:
* Use GET requests when you want to be able to bookmark the page --
i.e., when you want the behaviour repeatable. Typical example is
searches.
* Use POST requests when the operation will affect the data in some way
that shouldn't be cached. Examples: submitting data that will be
stored in the database, will update a database, or will delete an
entry in the database.
Because of the back button issues (namely, not all browsers treat 'back'
the same way), you will need to do some workarounds, typically with
sessions; I've mentioned these under separate cover.
Just in case...
I tried to add the following header before any html output to force
the browser to not load from the cache and it didn't work.
header("Cache-Control: no-store, no-cache, must-revalidate");
Not all browsers will actually follow these 'rules' (actually, they're
in the HTTP specification, but 'rule' just sounds better). Heck,
versions of the same browser on different platforms sometimes treat them
differently.
This is why session handling techniques are a common 'fix' for bad
browser behaviour in these instances.
--
Matthew Weier O'Phinney | WEBSITES:
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
-James
--- End Message ---
--- Begin Message ---
Actually:
Will there be an issue with the back button if I use 1 script to do
all of what I posted before?
So...
Script 1 submits to itself...it does the processing, updates
databases, etc...then it redirects back to itself for displaying for
results.
-James
Thank you guys for the answers. I think I will go with the following approach.
(A) script 1 submits to script 2 then
(B) script 2 redirects browser back to script 1
Script 1 is in charge of submitting and displaying; script 2 does the
processing.
This list is the best!
-James
At 2:08 AM +0000 4/27/05, Matthew Weier O'Phinney wrote:
* James <[EMAIL PROTECTED]>:
I apologize in advance if I'm asking basic questions...
When you hit the back button, won't the browser just take the page
from the cache?
I haven't switched my POSTs to GETs and this is what I'm seeing.
I have a list of images. There are check boxes next to the images.
When the user checks images and clicks on a DELETE CHECKED link, a
new list is shown (minus the ones deleted.) When the user hits the
BACK button, I see the list again with checks next to the previous
images marked for deletion
By the way... the rule of thumb I think about is this:
* Use GET requests when you want to be able to bookmark the page --
i.e., when you want the behaviour repeatable. Typical example is
searches.
* Use POST requests when the operation will affect the data in some way
that shouldn't be cached. Examples: submitting data that will be
stored in the database, will update a database, or will delete an
entry in the database.
Because of the back button issues (namely, not all browsers treat 'back'
the same way), you will need to do some workarounds, typically with
sessions; I've mentioned these under separate cover.
Just in case...
I tried to add the following header before any html output to force
the browser to not load from the cache and it didn't work.
header("Cache-Control: no-store, no-cache, must-revalidate");
Not all browsers will actually follow these 'rules' (actually, they're
in the HTTP specification, but 'rule' just sounds better). Heck,
versions of the same browser on different platforms sometimes treat them
differently.
This is why session handling techniques are a common 'fix' for bad
browser behaviour in these instances.
--
Matthew Weier O'Phinney | WEBSITES:
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
-James
--- End Message ---
--- Begin Message ---
Thanks to all that posted with help. I've got a book about regular
expressions but it's all very new to me.
-----Original Message-----
From: Jason Sweeney [mailto:[EMAIL PROTECTED]
Sent: Monday, 2 May 2005 9:50 PM
To: Matthew Western, IT Support, Lonsdale
Cc: [email protected]
Subject: Re: [PHP] Can someone help me build a regular expression?
Give this a shot:
^[0-9]{2,3}\.[0-9]$
Returns regex that begins with 2-3 digits, followed by a period, and
ends with one digit.
jason sweeney
jason.designshift.com
[EMAIL PROTECTED] wrote:
> Hi All,
>
> I've sucessfully got a JavaScript validating some text boxes to make
> sure that only numbers exist. I cheated and downloaded a regular
> expression someon else had used and that works nicely. I wish to
> validate the text box in the format of:
>
> xXX.X
>
> With the upper case Xs being a required number and the lower case x
> being allowed but not needed.
>
> Can anybody help me?
>
> Ta
> Matthew
>
>
>
>
>
>
>
--- End Message ---
--- Begin Message ---
> You mite try this. I know that this work with perl.
>
> =~ m/^[0-9][A-Z][a-z]{2-3} \.[0-9]+$/
I'm not sure what the initial m does(I'm not a perl person), but the
rest of the regex matches as follows.
A string whose first character is a digit between 0 and 9. This is
followed by an Upper case letter, and then two or three lower case
letters. All that is followed by a period(or dot), after which may be
a single-digit number, but nothing else.
It matches the following:
1Abc.2
1Abcd.2
1Abc.
1Abcd.
>
> I'm still very new to this. But I'm trying to help.
> Thomas
> [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Rory Browne wrote:
You mite try this. I know that this work with perl.
mites byte.
=~ m/^[0-9][A-Z][a-z]{2-3} \.[0-9]+$/
I'm not sure what the initial m does(I'm not a perl person), but the
rest of the regex matches as follows.
A string whose first character is a digit between 0 and 9. This is
followed by an Upper case letter, and then two or three lower case
letters. All that is followed by a period(or dot), after which may be
er?
a single-digit number, but nothing else.
It matches the following:
1Abc.2
1Abcd.2
1Abc.
1Abcd.
try this and see if that is correct:
php -r '
$a = array(
"gnaglreg1Abc.2ewfergwrgbt","1Abc.2","1Abcd.2","1Abc.","1Abcd.","1Abcd .2","1Abcd
.2",
"1Abcd.22","1Abcd .22","1Abcd .22","1Abcd.232");
foreach ($a as $s) {
echo "\ntrying:\t\t\"$s\":\n--\n";
echo preg_replace("/^[0-9][A-Z][a-z]{2-3} \.[0-9]+$/", "..!!GOTCHA1!!..",
$s),"\n";
echo preg_replace("/^[0-9][A-Z][a-z]{2,3} \.[0-9]+$/", "..!!GOTCHA2!!..",
$s),"\n";
echo preg_replace("/^[0-9][A-Z][a-z]{2,3} \.[0-9]?$/", "..!!GOTCHA3!!..",
$s),"\n";
echo preg_replace("/^[0-9][A-Z][a-z]{2,3}\.[0-9]+$/", "..!!GOTCHA4!!..",
$s),"\n";
echo preg_replace("/^[0-9][A-Z][a-z]{2,3}\.[0-9]?$/", "..!!GOTCHA5!!..",
$s),"\n";
echo preg_replace("/^[0-9][A-Z][a-z]{2,3}[ ]?\.[0-9]+$/", "..!!GOTCHA6!!..",
$s),"\n";
echo preg_replace("/^[0-9][A-Z][a-z]{2,3}[ ]{1,}\.[0-9]+$/", "..!!GOTCHA7!!..",
$s),"\n";
echo preg_replace("/^[0-9][A-Z][a-z]{2,3}[ ]?\.[0-9]?$/", "..!!GOTCHA8!!..",
$s),"\n";
echo preg_replace("/^[0-9][A-Z][a-z]{2,3}[ ]{1,}\.[0-9]?$/", "..!!GOTCHA9!!..",
$s),"\n";
echo "---\n";
}
'
I'm still very new to this. But I'm trying to help.
run the above code, examine the output (if you are going to do it in a browser
echo out
some <pre> tags). hopefully the 9 variations will give you a little bit of
insight.
read every page here: http://nl2.php.net/manual/en/ref.pcre.php - its a good
primer on regexp.
don't worry if you don't understand half of it. often things become
clear as you continue to read/experiment :-)
Thomas
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hello,
Thank for the information.
If that is not a good idea then how would you do it.
Thomas
--- Richard Collyer <[EMAIL PROTECTED]> wrote:
> Hello,
>
> <?php
> if(isset($_GET['page']))
> {include($_GET['page'] .
> ".php");}
> else
> {echo("Page Not Set.");}
> ?>
>
> Should work if you use ?page=index
>
> Might I suggest that what you are doing is a bad
> idea. Not only will it
> look bad becuase of people seeing stuff like
> ?page=/review/review23.php
> in the URL. Also its a security risk allowing people
> to call php scripts
> from the URL.
>
> Cheers
> Richard
>
> Thomas Bonham wrote:
> > Hello All,
> >
> > First of I'm new to this a hop I'm doing this
> right.
> >
> > If some one can help me with my web site page. I'm
> trying to make it
> > call a page and I get a error line 42. Error:
> >
> http://bonhamlinux.org/idex.php?page=links/index.php
> >
> > The code that I'm trying to do this is the
> following:
> > <?php
> > if(isset($_GET ['page']))
> > {include($_GET ['page'].".php");}
> > else
> > {echo("Page Not Set.");}
> > ?>
> >
> > My site is: http://bonhamlinux.org
> > My email is: [EMAIL PROTECTED]
> >
> > Thanks for all the help.
> > Thomas
> >
>
>
Thomas Bonham
Linux Rocks
http://www.bonhamlinux.org
Cell 602 402 9786
E-mail [EMAIL PROTECTED]
YIM freeswimfreak
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
Thanks for the help.
It works, for the most part.
Now I'm going to write the links page.
Thanks agin for all the great help.
Thomas
--- Mark Cain <[EMAIL PROTECTED]> wrote:
> Also, after I looked at more of your code you will
> need to specify the php
> extension in only one of two places. Currently you
> are specifying it in 1)
> the code below and in 2) nav.php and in nav.php you
> don't have it specified
> for the "main" but you do for the other links. That
> means that the code
> supplies the .php extension for main (which it needs
> to because it is simply
> "main" and not "main.php") but the other pages are
> specified as "name.ext"
> with the .php. Then when that page name gets to the
> script, the script is
> adding .php onto the variable -- resulting in
> main.php, links/index.php.php,
> email/email.php.php and so forth.
>
> Do it one place or the other -- but do it
> consistently.
>
> Looks like you're close to getting it to work and
> I'm close to going to bed.
>
> Mark Cain
>
>
>
> > >>The code that I'm trying to do this is the
> following:
> > >><?php
> > >> if(isset($_GET ['page']))
> > >> {include($_GET ['page'].".php");}
> > >> else
> > >> {echo("Page Not Set.");}
> > >>?>
> > >>
> > >>My site is: http://bonhamlinux.org
> > >>My email is: [EMAIL PROTECTED]
> > >>
> > >>Thanks for all the help.
> > >>Thomas
> > >>
> > >>--
> > >>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
> >
> >
>
>
Thomas Bonham
Linux Rocks
http://www.bonhamlinux.org
Cell 602 402 9786
E-mail [EMAIL PROTECTED]
YIM freeswimfreak
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
Graham Anderson wrote:
Hi
I am allready using a 'rank' field now... with 1 to N :) There are just
so damned many of them to order manually
the up/down button solution...is there a tutorial or php class out there
I could take a look at...
where you:
give the class a query...
the up and down links need to include the id of the item your moving
and possibly a direction value (depending on how you set your scripts up)
in order to move something up the list you have to find the item 'above' it
on the list (use sql for this). then you have to take the rank of the found item
and the requested item and swap the id (update with sql)
... alternatively you can use the fact that a select box can be multi-select
and that the order of the listed items in replicated in the GET/POST (and inside
php) .... i.e. use javscript to allow a user to move items up and down a select
box
(drag'n'drop or using up/down buttons), (warning - when your form submits all
the items in the multi-selectlist must be selected, a javascript
can be used for this.) and then on the server use the order of the list returned
from the page to re-order/rank the given users list.
get a found set back as html with these up/down buttons in each row
start ordering away with wild abandon....
does this allready exist somewhere ?
g
On Apr 26, 2005, at 9:59 PM, Richard Lynch wrote:
On Tue, April 26, 2005 7:05 pm, Graham Anderson said:
lately, I'm finding myself reordering large amounts of rows populated
from a database query ...with an order_id field
this is a bit tedious re-entering every order_id for a found set :(
Do different users get to order differently, or is there some "master"
order that all shall use?
If it's a "master" order, just put a "rank" field on the records, and
then
make sure it's always 1 to N for the order you want.
You can create "up" and "down" buttons to alter the order fairly easily.
If each user gets to have their own order, then you're looking at a
playlist for each user, so I'd have a different table with just "ID" and
"rank" (and userID) in it and do the same sort of thing.
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Michael Phillipson wrote:
[Please note that even though I cite Interbase in my example, I believe my
question can be generalized to all databases that allow persistent
connections]
I recently installed a trial version of Interbase on a development server
<firebird-loon>
have you tried the free trial version of Firebird, with the added bonus that
its not a trial... and has a cooler name :-/
</firebird-loon>
that includes a nifty tool that allows me to monitor, among other things,
...
--- End Message ---
--- Begin Message ---
Caio,
I have started a new group for those of us here that may run into
issues specifically with MySQLi in PHP5.
http://groups-beta.google.com/group/MySQLi
Regards,
John
--- End Message ---
--- Begin Message ---
Does anyone know of a good easy php script or Form that we can use with
Front Page.
We need a form to get results, that actually sends the results in a format
that is easy to read.
Not all run together with no spaces, etc. like the Front Page forms.
Thanks,
Lisa A
--- End Message ---
--- Begin Message ---
Hi,
Can anybody please point me to any URL where I can get PHP codes to
perform SSL cores such as:
* Certificate Signing Request
* Certificate Signing
* Revocation
* Publication of Generated Certificates and Revoked Lists
* etc
--
Best regards,
Tope Akinniyi
CEO
ShepherdHill Software
Lagos, Nigeria
Do not forget: Jesus said, I am the way, the truth and the life.
--- End Message ---
--- Begin Message ---
I have an xml document storing some data I need. What I want to do is this:
1. Scan to the end of the file.
2. Find the closing tag.
3. Insert a new entry in before the closing tag.
I've tried:
1. Creating new files and renaming them to be the original.
2. Writing the file to a dummy file and insert my lines part way through
then finish the last tag.
My problem is I'm looking for a </endtag> and it comes up as endtag. Is
there anyway to force PHP to read the .xml file as a text file so it wont
strip off the xml tag information?
I've used fopen with fgets and fwrite, and file with fwrite
Jared Sherman
Totally lost newbie
--- End Message ---
--- Begin Message ---
(Rasmus wrote:) "If you fwrite UTF-8 data to the file, then it is a UTF-8
file."
Thanks Rasmus! Honestly, that is REALLY helpful!
I was just coming back here to post that I had found that very same answer.
But I am glad to hear it confirmed by the experts.
Bottom line: I was just being silly/ignorant.
I went and downloaded a simple HEX editor and compared the actual binary
output of several files that I had created using both PHP, and my favorite
text editor (emeditor from emeditor.com). I then realized what probably
everyone else here already knew: that (most of the time) the actual binary
output from "Windows 1252" and "ISO-8859-1" and "UTF-8 without the byte
order mark" -are completely identical!
I had the false impression that when a file was saved in UTF-8, that there
was an actual binary "marker" that specified this (e.g. binary marker =
"This file is saved in UTF-8!") -there simply is no such thing. The only
thing that would set "UTF-8" apart -binarilly speaking- is the BOM, and I
had stripped that out, making the file exactly the same as plain old "ANSI"
(since I didn't have any characters that required "UTF-8", like from other
languages etc.).
My text editor displays the current character encoding in the status bar,
but since there was no way for it to tell whether it was saved with Windows
1252 or UTF-8, it just displayed that the file was encoded "windows
default - ISO-8859-1". This is where I got confused.
It turned out that my PHP script has been faithfully saving the file in
UTF-8 the whole time, and everything was fine. I was just not educated
enough about what actually changed when you save a file in UTF-8 but didn't
have any characters that differed from ANSI (which in my case, the "change"
was nothing, since ALL of the characters in my test document where
interchangeable with ANSI).
Well, this has been a learning experience! I hope that this post will help
some poor ignoramus like myself, sometime in the future! :) And hopefully I
am right about what I said above, and not flaunting my ignorance once
again -lol
Thanks again, to everyone who helped me! You guys really got me on the right
track. Not the least of which was simply causing me to think about what I
was asking more deeply.
-Jon
"Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Jon M. wrote:
>> No matter what I do to the strings to encode them in whatever format
>> before using "fwrite", it ALWAYS seems to end up writing the actual file
>> in "iso-8859-1".
>>
>> Isn't the encoding of the characters in PHP's strings, and the encoding
>> of the actual binary file on your hard drive, two totally different
>> things? Or am I just misinformed?
>
> A file is completely defined by its contents. If you fwrite UTF-8 data to
> the file, then it is a UTF-8 file. Whether your editor, or whatever it is
> you are using to determine the file is being written as iso-8859-1 is
> smart enough to pick this up is a completely different question.
>
> Why don't you try creating the same contents with PHP and with your
> preferred text editor and then compare the contents. Perhaps your editor
> is dropping a hint somewhere in it that you are not writing to the file
> from PHP.
>
> -Rasmus
--- End Message ---
--- Begin Message ---
Thanks also, Richard! You were right on.
Just a note:
I just visited the W3C validation service again, and it seems they have
recently updated it. It no longer complains if it finds a BOM in your
document binary. So it would appear that it's no longer an issue with enough
XML parsers to be relevant anymore. Still, it is nice to have a
program -like I do- that has that flexibility.
-Jon
"Richard Lynch" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, April 28, 2005 4:14 am, Jon M. said:
>> No matter what I do to the strings to encode them in whatever format
>> before
>> using "fwrite", it ALWAYS seems to end up writing the actual file in
>> "iso-8859-1".
>
> How do you know?
>
> What are you using to determine the format of the file?
>
> We are contending that either you are *not* writing UTF-8 data, but are
> writing iso-8859-1 data, or the software telling you that it's not UTF-8
> is just plain *wrong*
>
> fwrite just takes your data and dumps it on the hard drive.
>
> It doesn't know UTF-8 from U2.
>
>> Isn't the encoding of the characters in PHP's strings, and the encoding
>> of
>> the actual binary file on your hard drive, two totally different things?
>> Or
>> am I just misinformed?
>
> You are mis-informed.
>
>> How do you actually control the way the binary file itself is written,
>> and
>> not just the text that is saved in the file?
>
> If you are using Windows, then *WINDOWS* is, perhaps, guessing on the
> binary format based on the file 'extension' (.txt) and on the contents.
>
> First, try renaming the file to, err, whatever Windows thinks UTF-8 file
> extensions should be... ".utf8" ??? Whatever Notepad uses.
>
> Next, forget what Windows desktop tells you. It's bull.
>
> When you get the data back out of the file, what format is it?
>
> PS You may be confusing Windows by writing UTF-8 without the BOM, and so
> Windows then thinksit's iso-8859-1, because it's no longer a valid UTF-8
> file! You can make Windows happy; or you can make W3c happy. Not both.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Thanks also, Richard! You were right on.
Just a note:
I just visited the W3C validation service again, and it seems they have
recently updated it. It no longer complains if it finds a BOM in your
document binary. So it would appear that it's no longer an issue with enough
XML parsers to be relevant anymore. Still, it is nice to have a
program -like I do- that has that flexibility.
-Jon
"Richard Lynch" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, April 28, 2005 4:14 am, Jon M. said:
>> No matter what I do to the strings to encode them in whatever format
>> before
>> using "fwrite", it ALWAYS seems to end up writing the actual file in
>> "iso-8859-1".
>
> How do you know?
>
> What are you using to determine the format of the file?
>
> We are contending that either you are *not* writing UTF-8 data, but are
> writing iso-8859-1 data, or the software telling you that it's not UTF-8
> is just plain *wrong*
>
> fwrite just takes your data and dumps it on the hard drive.
>
> It doesn't know UTF-8 from U2.
>
>> Isn't the encoding of the characters in PHP's strings, and the encoding
>> of
>> the actual binary file on your hard drive, two totally different things?
>> Or
>> am I just misinformed?
>
> You are mis-informed.
>
>> How do you actually control the way the binary file itself is written,
>> and
>> not just the text that is saved in the file?
>
> If you are using Windows, then *WINDOWS* is, perhaps, guessing on the
> binary format based on the file 'extension' (.txt) and on the contents.
>
> First, try renaming the file to, err, whatever Windows thinks UTF-8 file
> extensions should be... ".utf8" ??? Whatever Notepad uses.
>
> Next, forget what Windows desktop tells you. It's bull.
>
> When you get the data back out of the file, what format is it?
>
> PS You may be confusing Windows by writing UTF-8 without the BOM, and so
> Windows then thinksit's iso-8859-1, because it's no longer a valid UTF-8
> file! You can make Windows happy; or you can make W3c happy. Not both.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Hi!
I want a script that can display a list of all the websites currently
hosted on my server.. (i have root access to the server)
Say I have a page sitesonmyserver.php..it shud show a list of all the
websites hosted on my server..eg:
abc.com
xyz.om
And any additional info if possible?
Is such a thing possible in PHP.. or does any such script exists?
Thanks in advance!
Dasmeet
SayOrange.com
How to choose the best web hosting?
http://www.sayorange.com
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Dasmeet Singh [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 03, 2005 9:03 AM
> I want a script that can display a list of all the websites currently
> hosted on my server.. (i have root access to the server)
>
> Say I have a page sitesonmyserver.php..it shud show a list of all the
> websites hosted on my server..eg:
> abc.com
> xyz.om
>
> And any additional info if possible?
>
> Is such a thing possible in PHP.. or does any such script exists?
If You�re running Apache, parse the httpd.conf and echo the line containing
ServerName?
--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper
--- End Message ---
--- Begin Message ---
Dasmeet Singh wrote:
Hi!
I want a script that can display a list of all the websites currently
hosted on my server.. (i have root access to the server)
Say I have a page sitesonmyserver.php..it shud show a list of all the
websites hosted on my server..eg:
abc.com
xyz.om
And any additional info if possible?
Is such a thing possible in PHP.. or does any such script exists?
Generally, no. You would need some black magic that probed the guts of
your web server for this information. And by black magic I mean some
low-level C code.
A bit of grey magic I wrote almost exactly 9 years ago now! (May 1,
1996) in the form of Apache's mod_info module might help you out a
little bit. If you define all your vhosts in your httpd.conf file and
not in included files, then you can enable mod_info in your Apache
config, and restrict access to the information to localhost with
something like:
<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
Then your PHP code would hit your server's local /server-info link and
parse it with something along the lines of:
$info = file_get_contents('http://localhost/server-info?http_core.c');
preg_match_all('/.*servername <.*?>(\S+?)<.*/i',$info,$reg);
$vhosts = $reg[1];
You may need to doublecheck that regex. I didn't actually test it.
-Rasmus
--- End Message ---