|
-
Feb 15th, 2003, 06:27 AM
#1
Dislpaying URLs...
If I have a string with an URL....like $MyUrl contains http://www.klubbscenen.com
How can I display that as a hyper link on my PHP page??
-
Feb 15th, 2003, 09:45 AM
#2
PHP Code:
echo "<a href="$myurl">NoteMe needs a brain</a>";
-
Feb 15th, 2003, 02:50 PM
#3
Thanks but that didn't actually work. But with a little bit help from Front page, it did....hehehehe....Frontpage is smarter then Menhak....
-
Feb 15th, 2003, 05:39 PM
#4
Frenzied Member
he was close
echo "<a href=\"$myurl\">NoteMe needs a brain</a>";
and frontpage is stupid
-
Feb 15th, 2003, 05:43 PM
#5
Yes FrontPage is stupid, but at least it told me the right syntax....but while you are here....how do I cruse thrue a folder...lets say http://www.klubbscenen.com again for htm files. I am trying to use the Dirobject. But I'm not there yet.
BTW I only want to find the htm pages and not all the gif and jpg ect pages....
-
Feb 15th, 2003, 05:54 PM
#6
Frenzied Member
no don't use dirobject. look into opendir and you have to write you own function to determine if the extension is html
-
Feb 15th, 2003, 06:12 PM
#7
OK...I have to admitt that I am pretty new to PHP. So I have some problems. I don't know what parameter I should use to open up my directory.
If I open up CuteFTP I see the folders that are on the picture. We always put our htm files in www folder. But when we want to acces the files, we only writes something like http://www.klubbscnen.com/startsiden.htm but I now saw that all the files we have also are in the public_html folder too. So what folder should I open up. Or do I need to open up a folder at all, because the php file is in the same folder as all the htm files. Any hints on how to read a file that I don't know the name of???
-
Feb 15th, 2003, 06:24 PM
#8
Frenzied Member
correct, you only opne the folder the php file is in. or you can open all of them that are under the script as well. so i fyou use opendir and readdir you can do this (rigth out of the PHP manual)
PHP Code:
// Note that !== did not exist until 4.0.0-RC2
<?php
if ($handle = opendir('/path/to/files')) {
echo "Directory handle: $handle\n";
echo "Files:\n";
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo "$file\n";
}
/* This is the WRONG way to loop over the directory. */
while ($file = readdir($handle)) {
echo "$file\n";
}
closedir($handle);
}
?>
-
Feb 15th, 2003, 06:33 PM
#9
Thanks for that...but I am still a little bit lost on the folders. My test file is now at
http://www.klubbscenen.com/search2.php
so that meens that I did put the search2.php file in the www folder. But if you try to run the file it gives me this error:
Warning: OpenDir: Permission denied (errno 13) in /home/klub/public_html/search2.php on line 7
do I try to access the wrong directory?? What do I do wrong. And why does it say /home/klub/public_html if you can see on the picture abow public_html is not in any folders. It is in the root. What is it I'm missing here???
-
Feb 15th, 2003, 06:42 PM
#10
Frenzied Member
don't use public_html.
all your webstuff is in www folder. if you just want the current directory do this
if ($handle = opendir('.')) {
-
Feb 15th, 2003, 06:49 PM
#11
But I still get the same error message....my file is still here...
http://www.klubbscenen.com/search2.php
Can the people we are borrowing the server from hvae done something that does this operation illigal??? Or am I just a tired noobie of a PHP writer...
-
Feb 15th, 2003, 06:54 PM
#12
Frenzied Member
you can't do it from public
/home/klub/public_html/search2.php
you have to do it in www folder.
/home/klub/www/search2.php
that is where you want the script.
-
Feb 15th, 2003, 06:57 PM
#13
Yes...and I did put the file in the www folder...but that is the error message. But as I said, I notised that all the files we have in the www folder is also in the public_html folder....eaven my search2.php file, and I did not put it there....it is like looking in a mirror when I am looking in that folder...
-
Feb 15th, 2003, 07:02 PM
#14
Frenzied Member
then your host has blocked it.
/home/klub/public_html/search2.php
that tells me the web folder is in public as the error is coming from that folder. what is the script you have now?
-
Feb 15th, 2003, 07:03 PM
#15
Search2.php is just the script you gave me...
PHP Code:
<HTML>
<HEAD>
</HEAD>
<BODY>
Opening a folder:
<?PHP
if ($handle = opendir('.')) {
echo "Directory handle: $handle\n";
echo "Files:\n";
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo "$file\n";
}
closedir($handle);
}
?>
</BODY>
</HTML>
-
Feb 15th, 2003, 07:05 PM
#16
-
Feb 15th, 2003, 07:06 PM
#17
In CuteFTP I right clicked the public_html folder. I checked the read property for public, and that did it. But can hacker take advantage of this??? Or not....
-
Feb 15th, 2003, 07:08 PM
#18
BTW should this produce a new line too..
echo "$file\n";
???
-
Feb 15th, 2003, 07:10 PM
#19
I added a <br> tag to make a line shift....really thanks for the help...
-
Feb 15th, 2003, 07:23 PM
#20
Frenzied Member
Originally posted by NoteMe
In CuteFTP I right clicked the public_html folder. I checked the read property for public, and that did it. But can hacker take advantage of this??? Or not....
very possible, that is why you don't let anybody know that script exits or you or you send only people you trust to it.
-
Feb 15th, 2003, 07:28 PM
#21
So I should probably delete the whole thread... ....I don't care if people do read read the files, becase it is all public. The script is only writing down the files. But I don't want people to be able to delete, or move any of our files. Can that happend? Or am I paranoid now??
BTW if you open up a html file. And reads everything in it. Is it possible to "strip" away all the html and just have the text of the file. Or am I dreaming when I am asking now???
-
Feb 15th, 2003, 07:35 PM
#22
Frenzied Member
all they can do is view the contents of that folder, they can't edit anything unless you let them.
-
Feb 15th, 2003, 07:37 PM
#23
Thanks a lot. You have made my day...and since it is past midnight here a long time ago, I guess that you have made the next 22 hours or so....thanks...
BTW did you know anything about that reading only the text from a html page, or something like that?
-
Feb 15th, 2003, 07:40 PM
#24
Frenzied Member
glad I can help.
what about reading only the text from a webpage?
-
Feb 15th, 2003, 07:42 PM
#25
I havn't tested yet...but if I want to read a html page with file() or something then I will have all the html code too. Is it possible to just read the text, or take away the html code from the string (array) afterwards???
-
Feb 15th, 2003, 08:02 PM
#26
Frenzied Member
well yeah you could, but that would mean to set up a bunch of ereg_replace functins to detect the html. to hard to do especailly if you are just learning. Regular expressin is difficult if you are a newbie.
but you can load a html file into a textbox and then save it.
-
Feb 15th, 2003, 08:25 PM
#27
OK...so it was only a question anyway. But again thanks for all your help. And yes I am new to PHP but not to programming, so I hope that I will learn fast, but I will wait with that html code thingy....
Thanks again.
-
Feb 16th, 2003, 01:23 PM
#28
Stuck in the 80s
Originally posted by phpman
you can't do it from public
/home/klub/public_html/search2.php
Where do you get that from? I've never had a problem using public_html before.
-
Feb 16th, 2003, 01:25 PM
#29
I fixed it yesterday. The problem was that "public" did not have could not read from that folder, so I checked a check box with cuteFTP on the folder, and then it worked..
-
Feb 16th, 2003, 01:28 PM
#30
Stuck in the 80s
I know. I'm just wondering where phpman got the information that it could not work from public_html, as I've never had a problem doing it.
-
Feb 16th, 2003, 01:32 PM
#31
I think he ment that since I did put the file in the www folder, I should use the www folder and not the public_html folder or something. I'm not 100% sure, can't remember what exactly we where doing at the moment, I was so tired yesterday....But it is working now.
-
Feb 16th, 2003, 01:47 PM
#32
Originally posted by NoteMe
I think he ment that since I did put the file in the www folder, I should use the www folder and not the public_html folder or something. I'm not 100% sure, can't remember what exactly we where doing at the moment, I was so tired yesterday....But it is working now.
AFAIK... www = public_html.
You're using Cute FTP... when you double click www, do you get public_html? or a separate www?
-
Feb 16th, 2003, 01:51 PM
#33
I am getting a two separate folders. Like in the picture a little bit up in this thread....but if place a file in the WWW folder, I can see it in the public_html folder too. But the folders do not have the same "user rights"...that was the problem yesterday. And I have to admitt that I don't know much abou this, but I can't understand why I have both folders....
-
Feb 16th, 2003, 01:52 PM
#34
Stuck in the 80s
I always thought www was a shortcut to public_html...
And again, I've never had a problem using public_html.
-
Feb 16th, 2003, 01:54 PM
#35
But I can't understand why I should have a shortcut for public_html when both the folders are in the root...
-
Feb 16th, 2003, 02:11 PM
#36
Frenzied Member
I have never had a host that had public_html, they always had www folder. so I assumed that public_html wasn't the web folder as www is always the web folder. so since he had that error I assumed that public didn't have access to anything like www should. that is a wierd setup if both folders are the same.
-
Feb 16th, 2003, 02:13 PM
#37
Yes it is, and we have a public_ftp to...but we don't use that. Is it for downloading like. ftp://klubbscenen.com/*.*???
-
Feb 16th, 2003, 03:19 PM
#38
Stuck in the 80s
Originally posted by phpman
I have never had a host that had public_html, they always had www folder. so I assumed that public_html wasn't the web folder as www is always the web folder. so since he had that error I assumed that public didn't have access to anything like www should. that is a wierd setup if both folders are the same.
I've never had a host without both folders. www has always been a shortcut to public_html on all the hosts I've had, as well.
-
Feb 16th, 2003, 04:23 PM
#39
Frenzied Member
it might have something to do with having frontpage uploads. not sure.
-
Feb 17th, 2003, 01:09 AM
#40
Originally posted by NoteMe
I am getting a two separate folders. Like in the picture a little bit up in this thread....but if place a file in the WWW folder, I can see it in the public_html folder too. But the folders do not have the same "user rights"...that was the problem yesterday. And I have to admitt that I don't know much abou this, but I can't understand why I have both folders....
That's what I was saying. As hobo and the rest are pointing out, www is a shortcut to public_html. You just need to work with public_html.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|