Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: showing live source

  1. #1
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Question showing live source

    I am basically finished modifing the pages of the php weblog. And I am thinking of putting a "View Source" Link and all the front-end pages. What do the php people here think about doing this? am I opening a big can of worms by letting everybody see the source?

  2. #2
    Join Date
    Aug 2004
    Posts
    162
    Rep Power
    0

    Default

    Hey owen, sup. anyway to view the source I would recommend that you use the show_source or highlight_file function, they are both the same (i think). All you would need to do is just send a variable in the link.

    PHP Code:
    <? if ($_GET[show] = "yes") {
    show_source("blah.php");
    }
    By letting people see your source you are not opening a can or worms, you are opening the source, OpenSource . I support opensource since I think what I know today is heavily dependent on it, but people can copy your code and not give you credit for it. I believe in knowing the algorithm, so that even if i see the code for something I may be able to code the same thing in a more efficient way.
    He who hesitates, dies.

  3. #3
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default

    Open source is different when it comes to php because of how simple the program is. When a person says open source UNIX you can't just pick a page in the UNIX source and look at it because it will look meaningless. However with a simpler app its a different ball game.

    Stealing the code isn't a issue because its basic stuff you can find in th php help manual.

    super kungfu way to do it (much like http://www.owensoft.net/v4/archive/source/ )

    PHP Code:

    if($option=='source' $record=='source'  ) {
        
    highlight_file __FILE__ );
        return 
    false;

    but putting that code into every file isn't going to cut it for me I am going to do something ++.
    Last edited by owen; Jul 13, 2005 at 11:56 AM.

  4. #4
    Join Date
    Jun 2004
    Posts
    296
    Rep Power
    0

    Default

    ive started doing that with all the scripts i write, i agree with owen, most of these scripts that we write are so simple that they are hardly propriety. Hardly ne thing another person cant read on the billions of free tutorials out there. I like the view source option because it makes it easier for me to view code when im in a remote location and when some one asks me a php question, i can just refer them to a script i have online which outlines what i did. So yeah, go ahead owen. I recommend putting a view source link on ur php chat script

  5. #5
    Join Date
    Jun 2004
    Posts
    296
    Rep Power
    0

    Default

    http://www.fiwizone.com/alex/picture/index.php?source

    For thos who have no idea what we talking about.

  6. #6
    Join Date
    Aug 2004
    Posts
    76
    Rep Power
    0

    Default

    I think a simple php include would solve the problem of writing the code everytime.

  7. #7
    Join Date
    Aug 2004
    Posts
    162
    Rep Power
    0

    Default

    owen when you say ++ do you mean object oriented? using a class can be an easy way but an ordinary funcition would do this best (I think) all you need to do is pass the variable containing the file name

    PHP Code:
    function printSource ($page) {
    highlight_file($page);
    }

    $page "blah.php";
    printSource($page); 
    He who hesitates, dies.

  8. #8
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default

    no + was not refering object oriented. I meant doing "extra" stuff that the highlight_file functions doesn't do like putting in line numbers, and reading template files.

  9. #9
    Join Date
    Aug 2004
    Posts
    162
    Rep Power
    0

    Default

    the line numbers feature sounds cool. i saw something once and i think they used some file i/o function to make an array of the lines.
    He who hesitates, dies.

  10. #10
    Join Date
    Jun 2004
    Posts
    296
    Rep Power
    0

    Default

    Quote Originally Posted by owen
    no + was not refering object oriented. I meant doing "extra" stuff that the highlight_file functions doesn't do like putting in line numbers, and reading template files.
    I was thinking of doing that once. Was actually thinking of using the file function to get it all up in an array and then spit out line numbers are I parse each individual line. Sounds like too much work tho, but the line numbers would definitely be a +, if not a ++. But I dont like the idea of creating some parser to handle the syntax. Probably would involve putting the keywords into an array, look out for comments, might not be too bad.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •