Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Mar 2008
    Location
    New Brunswick, Canada
    Posts
    53
    Tokens
    89

    Question Need some small (I think) help!

    Hey HXFers! How are you today? Nice weather, is it not?

    Anyhow, I am remaking a nonprofit youth related website and this time around I am using a flat file based CMS.. makes it easier for me and the person who will be using the backend updater.

    So, that said, the guy who will be using the CMS will be using an uploader function to upload .PDF files to the website. The PDF files will be for various things, but mostly just to donators and supporters updates of what's going on.

    SO, I need some help on this part of the race.

    The code I'm using to show the contents of the folder the PDF files are in is this:
    PHP Code:
    <?php  
    if ($handle opendir('../updates/')) { 
        while (
    false !== ($file readdir($handle))) {  
            if (
    $file != "." && $file != "..") {  
                echo 
    "<div align=\"center\"> <a target=\"devotions\" href=\"".$file."\">".$file."</a></div><br />"
            }  
        } 
        
    closedir($handle);  

    ?>
    So I need to do two things with this that aren't currently working.

    1. I want to have it so when the PHP uses the echo function to display the files, it does not show the file extention (i.e. 03.21.2011.PDF, I want the .PDF to remain hidden). How do I do this, or is it possible? I know I need to change the ".$file.", but I don't know what I need to change it to.

    2. In all pages for the flat editor the man running the CMS can edit the pages.. Right now it looks like when you open a .html file in Notepad, you see all the HTML and no formatting options are avaliable.
    I'm wondering if someone can give me a code for the text boxes that will put formatting buttons (B will add <b></b> tags, U will add <u></u> tags).. I'd really appreciate that!


    Now I don't know how hard these things are, but I would VERY much appreciate it if someone could help me out! Even if you know how to do one thing, It would help for you to post that too!

    Thanks in advance!,
    Daniel

  2. #2
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    1. I'm sure there's a really, really easy way to do that, I just can't remember what it is. I guess you could explode('.', $file) and echo everything before the last item in the array. Or if the extension is always .PDF (or some other 3 letter extension), just remove the last 4 characters. I'm 99% certain I've seen a much more straightforward way to do it though

    2. You could use one of these:
    http://developer.yahoo.com/yui/editor/
    http://tinymce.moxiecode.com/tryit/full.php
    Or just google 'rich text editor'.

  3. #3
    Join Date
    Mar 2008
    Location
    New Brunswick, Canada
    Posts
    53
    Tokens
    89

    Default

    Quote Originally Posted by Trinity View Post
    1. I'm sure there's a really, really easy way to do that, I just can't remember what it is. I guess you could explode('.', $file) and echo everything before the last item in the array. Or if the extension is always .PDF (or some other 3 letter extension), just remove the last 4 characters. I'm 99% certain I've seen a much more straightforward way to do it though

    2. You could use one of these:
    http://developer.yahoo.com/yui/editor/
    http://tinymce.moxiecode.com/tryit/full.php
    Or just google 'rich text editor'.
    Thank you very much, the editor is working perfect and is doing just what I need it to!

    How would I go about removing the last 3 letters, though? It will always be .PDf, .doc, or .txt, but it CAN be set up for only .PDF, that wouldn't be a problem if needed. What you see for PHP is as far as I've learned so far hahaha.

    Also, I'm looking to order the files in the order of upload.. Most recent will be first, oldest will be last. Any way to do that?

  4. #4

    Default

    PHP Code:
    if ($handle opendir('../updates/')) {  
        while (
    false !== ($file readdir($handle))) {
            
    $index='$file != "index.php"||$file != "index.html"||$file != "index.asp"';
            if (
    $file != "." && $file != "..") {
                if (!
    $index){
                    
    $file=explode("."$file);
                    
    $extention=$file['1'];//file extention
                    
    $file=$file['0'];//file name
                    
    echo "<div align=\"center\"> <a target=\"devotions\" href=\"".$file."\">".$file."</a></div><br />";  
                }
            }   
        }  
        
    closedir($handle);   


  5. #5
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by badboyxlr View Post
    PHP Code:
    if ($handle opendir('../updates/')) {  
        while (
    false !== ($file readdir($handle))) {
            
    $index='$file != "index.php"||$file != "index.html"||$file != "index.asp"';
            if (
    $file != "." && $file != "..") {
                if (!
    $index){
                    
    $file=explode("."$file);
                    
    $extention=$file['1'];//file extention
                    
    $file=$file['0'];//file name
                    
    echo "<div align=\"center\"> <a target=\"devotions\" href=\"".$file."\">".$file."</a></div><br />";  
                }
            }   
        }  
        
    closedir($handle);   

    I'm pretty sure that $index = 'blabla' line combined with the if(!$index) is pointless. You're setting $index as a weird string then checking if $index is true (contains anything). Of course it does, you just set it.

    Edit: My mistake, you were checking if it's false (contains nothing)

    Also, the method you've used to remove the file extension won't work if there are any dots in the file name. That's why I said to remove the last item in the array, not the second.

    Quote Originally Posted by DannLea View Post
    Thank you very much, the editor is working perfect and is doing just what I need it to!

    How would I go about removing the last 3 letters, though? It will always be .PDf, .doc, or .txt, but it CAN be set up for only .PDF, that wouldn't be a problem if needed. What you see for PHP is as far as I've learned so far hahaha.

    Also, I'm looking to order the files in the order of upload.. Most recent will be first, oldest will be last. Any way to do that?
    To remove the last 3 letters (plus the dot, so 4 characters), use substr.
    PHP Code:
    $removed substr($file0, -4); 
    For ordering the files, I'd probably load all of the details into an array and use a combination of filectime() and sort(). My head's not working at the moment though, maybe there's a better way.
    Last edited by Trinity; 21-03-2011 at 11:24 PM.

  6. #6

    Default

    the index string is getting rid of the index.html .asp and .php files so there not echo'ed

    you can always count the arrays, and -1 then add the others together ...

  7. #7
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by badboyxlr View Post
    the index string is getting rid of the index.html .asp and .php files so there not echo'ed

    you can always count the arrays, and -1 then add the others together ...
    I'm pretty sure it isn't.
    I'm not so sure that the second part of your post makes sense.
    Edit: Wait, I just deciphered it, my bad. Be clearer, yo.
    Last edited by Trinity; 21-03-2011 at 11:21 PM.

  8. #8

    Default

    correct, i added an extra ! it should be if ($index){//code}

  9. #9
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by badboyxlr View Post
    correct, i added an extra ! it should be if ($index){//code}
    No, that wasn't my problem with it. That method of checking doesn't work, unless it's some freaky voodoo code that I've never seen before. Although I just tested it and it didn't work so I doubt it's voodoo magic.

    You are setting a static string, then checking if there is anything in the string. PHP does not evaluate or even notice any of the operators in that string.

  10. #10
    Join Date
    Mar 2008
    Location
    New Brunswick, Canada
    Posts
    53
    Tokens
    89

    Default

    Quote Originally Posted by badboyxlr View Post
    the index string is getting rid of the index.html .asp and .php files so there not echo'ed

    you can always count the arrays, and -1 then add the others together ...
    I understand what you mean as for the first point.. I got that far. As for the -1 arrays etc. thing, you've lost me! I code mainly HTML and CSS, and that's it really. More of a web designer to be honest I'm just trying to get this website working for the organization.

    Quote Originally Posted by Trinity View Post
    I'm pretty sure that $index = 'blabla' line combined with the if(!$index) is pointless. You're setting $index as a weird string then checking if $index is true (contains anything). Of course it does, you just set it.

    Edit: My mistake, you were checking if it's false (contains nothing)

    Also, the method you've used to remove the file extension won't work if there are any dots in the file name. That's why I said to remove the last item in the array, not the second.



    To remove the last 3 letters (plus the dot, so 4 characters), use substr.
    PHP Code:
    $removed substr($file0, -4); 
    For ordering the files, I'd probably load all of the details into an array and use a combination of filectime() and sort(). My head's not working at the moment though, maybe there's a better way.
    K so I realize I'm supposed to put that snippit somewhere, but as for where in the code and what to implement it with, I'm clueless ahaha.

    And for the ordering explanation, no idea what you're talking about hahaha.

    I feel so embarrassed, I should really look into PHP more than I do D:

Page 1 of 2 12 LastLast

Posting Permissions

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