Results 1 to 40 of 40

Thread: Dislpaying URLs...

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    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??

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    PHP Code:
    echo "<a href="$myurl">NoteMe needs a brain</a>"

  3. #3

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Thanks but that didn't actually work. But with a little bit help from Front page, it did....hehehehe....Frontpage is smarter then Menhak....

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    he was close

    echo "<a href=\"$myurl\">NoteMe needs a brain</a>";

    and frontpage is stupid

  5. #5

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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....

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    no don't use dirobject. look into opendir and you have to write you own function to determine if the extension is html

  7. #7

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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???


  8. #8
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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); 
    }
    ?>

  9. #9

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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???

  10. #10
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    don't use public_html.

    all your webstuff is in www folder. if you just want the current directory do this

    if ($handle = opendir('.')) {

  11. #11

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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...

  12. #12
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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.

  13. #13

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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...

  14. #14
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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?

  15. #15

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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>

  16. #16

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Thanks I made it...

  17. #17

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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....

  18. #18

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    BTW should this produce a new line too..

    echo "$file\n";


    ???

  19. #19

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I added a <br> tag to make a line shift....really thanks for the help...

  20. #20
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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.

  21. #21

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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???

  22. #22
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    all they can do is view the contents of that folder, they can't edit anything unless you let them.

  23. #23

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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?

  24. #24
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    glad I can help.

    what about reading only the text from a webpage?

  25. #25

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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???

  26. #26
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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.

  27. #27

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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.

  28. #28
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  29. #29

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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..

  30. #30
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  31. #31

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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.

  32. #32
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    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?

  33. #33

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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....

  34. #34
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I always thought www was a shortcut to public_html...

    And again, I've never had a problem using public_html.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  35. #35

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    But I can't understand why I should have a shortcut for public_html when both the folders are in the root...

  36. #36
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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.

  37. #37

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Yes it is, and we have a public_ftp to...but we don't use that. Is it for downloading like. ftp://klubbscenen.com/*.*???

  38. #38
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  39. #39
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    it might have something to do with having frontpage uploads. not sure.

  40. #40
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    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
  •  



Click Here to Expand Forum to Full Width