SitePoint Sponsor

User Tag List

Results 1 to 23 of 23
  1. #1
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Invision Power Board content to php pages...

    Does anyone know of a decent way to setup a function where an admin type user can post something to a restricted category in an IPB forum, and it gets formatted onto a home page (i.e. index.php of domain)

    I am trying to setup a site and have it simple enough to have updated without having to use an app like phpNuke or Post Nuke. I have a user authentication and sessions + cookies setup already.

    The site is on a regular domain.com/ and the forum is on domain.com/forum/

    Before I go tearing up files, I was just wondering if someone could give me some advise.

    v/r

    Troy

  2. #2
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    now thats a very novel idea for a ready made CMS !..

    if you used the post_topic as the name of the page, i.e index.php as the post topic...

    then its a simple matter of querying the database from the relevant page...

    //i.e. in index.php//
    "SELECT post FROM posts WHERE topic_id='index.php' ..etc, I dont know the table structure but you get the point.

    dude thats one truly excellent idea...which I am stealing as we speak !

  3. #3
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not sure how to JOIN the databases though, or do I only need to refer to the forum DB? Can I make it post to the site using an "include" instead. hmmm

  4. #4
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Questions,

    so far the idea is working well. There are two things that I need help with though.

    The avatar is difficult to query cause the path has a colon in it. I assume that "addslashes()" would take care of that, but I am not too sure how to do it.

    The other problem is the time and date in IPB are controlled with a VARCHAR(10) column. I am not sure what to do to convert that to real time.

    Any help is really appreciated.

    Take care, Troy

  5. #5
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IPB stores its dates in UNIX timestamp format. Check out the date() function to learn how to reformat them any way you like.

    And why would a colon cause query problems exactly?

  6. #6
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The colon is part of the path name Phil,

    http://localhost/domain/forum/uploads/file.jpg

    The image is in the database like so...

    uploads:file.jpg

    Thanks for the info about date(), I'll look it up in the cookbook.

  7. #7
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I am having no luck at all.

    I am trying to convert a unix timestamp into a readable format using php. Here is my query line.

    $query = "SELECT post, author_name, FROM_UNIXTIME(UNIX_TIMESTAMP(post_date), '%b %e %Y, %I:%i %p'), avatar FROM ibf_posts, ibf_members WHERE author_name = 'Troy_Bouffard' AND name = 'Troy_Bouffard'";

    I am getting no error, but nothing is displaying either. If I don't set a conversion, it displays the unix timestamp, so there is connection. Any ideas?

    Troy

  8. #8
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try $query = "SELECT post, author_name, FROM_UNIXTIME('post_date', '%b %e %Y, %I:%i %p'), avatar FROM ibf_posts, ibf_members WHERE author_name = 'Troy_Bouffard' AND name = 'Troy_Bouffard'";

    not sure if 'post_date' needs the quotes or not though

  9. #9
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No luck yet, tried a few ways. Thanks for replying.

  10. #10
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try running the qyery through MySQL commandline or phpMyAdmin and see if you're getting the results you're expecting.
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  11. #11
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Getting closer.

    FROM_UNIXTIME(UNIX_TIMESTAMP(post_date), '%b %e %Y, %I:%i %p') AS formatted_date .....

    ....$row['formatted_date']....

    outputs this:

    Dec 31 1969, 07:00 PM

    Any Idea why?

  12. #12
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    got it, needed to not use "UNIX_TIMESTAMP" :

    FROM_UNIXTIME(post_date, '%b %e %Y, %I:%i %p') AS formatted_date


    Thanks all

  13. #13
    SitePoint Addict sojomy's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Knightime
    The colon is part of the path name Phil,

    http://localhost/domain/forum/uploads/file.jpg

    The image is in the database like so...

    uploads:file.jpg

    Thanks for the info about date(), I'll look it up in the cookbook.
    Can you just string replace
    'uploads:'
    with
    'http://localhost/domain/forum/uploads/'

  14. #14
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found a better workaround for the upload issue. Since the database stores the field data with a colon, I opted to use the hotlink data instead and limit input to hotlinks instead of actually uploading the image.

    Sojomy, am not sure how to do a string replace "and" $query correctly

    Troy

  15. #15
    SitePoint Addict sojomy's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Knightime
    Sojomy, am not sure how to do a string replace "and" $query correctly
    Troy
    // I'm not sure about your SQL Statement because I don't know about the
    // DB structure, but this will get a the avatar from a simple DB
    $SQL = mysql_query('SELECT Avatar FROM Users WHERE UserID=1');
    $Avatar = mysql_result($SQL,0,0);
    $Avatar = str_replace('uploads:', 'http://localhost/domain/forum/uploads/', $Avatar);

    This should convert
    'uploads:file.gif'
    to
    'http://localhost/domain/forum/uploads/file.gif'

  16. #16
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sojomy, thanks for the reply. I see what you mean now. I tried to apply your advice the best Icould but I am missing something. Here is the whole script:

    PHP Code:
     
    include("connect.php" );
    $query "SELECT post, author_name, FROM_UNIXTIME(post_date, '%b %e %Y, %I:%i') AS formatted_date, avatar FROM ibf_posts, ibf_members WHERE author_name = 'Troy_Bouffard' AND name = 'Troy_Bouffard'";
    $result mysql_query($query);
    $Avatar mysql_result($query,0,0); 
        
    $Avatar str_replace('uploads:''http://localhost/hfrl/forum/uploads/'$Avatar);
    if (!
    $result) {
    echo(
    "<p>Error performing query: " mysql_error() . "</p>" );
    exit();
    }
    while ( 
    $row mysql_fetch_array($result) ) {
    echo(
    "<tr><td class=\"content\"><p class=\"bodypad\"><span class=\"title\">Subject: </span>" $row["title"] . "&nbsp;&nbsp;<span class=\"submitted\">Submitted by: </span>" $row["author_name"] . "</p></td><td class=\"content\"><p class=\"bodypad\">" $row['formatted_date'] . "</p></td></tr>" );
    echo(
    "<tr><td class=\"content\"><p class=\"bodypad\">" $row["post"] . "</p></td><td class=\"image\"><img src=""\" " $row[$Avatar] . " \" alt=\"Author's avatar\" /></td></tr>" );
    echo(
    "<tr><td colspan=\"2\" class=\"separate\"><img src=""\"pics/black.jpg\" height=\"3\" /></td></tr>" );

    It's getting close cause the str_replace() seemed to work. Here is the path on the image properties:

    http://localhost/hfrl/

    Just a bit short, not sure why though. Thanks again for your time.

    Troy
    Last edited by Knightime; Mar 9, 2003 at 16:48.

  17. #17
    SitePoint Addict sojomy's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Knightime
    Sojomy, thanks for the reply. I see what you mean now. I tried to
    apply your advice the best Icould but I am missing something.
    Here is the whole script:
    ...
    It's getting close cause the str_replace() seemed to work. Here is the path on the image properties:
    http://localhost/hfrl/
    Just a bit short, not sure why though. Thanks again for your time.
    Troy
    First, in your last post, you should DEFINITELY go and break some of those lines so we don't have so much horizontal scrolling. But try this
    PHP Code:
    <?
    include('connect.php');
    $query 'SELECT post, title, author_name, avatar, FROM_UNIXTIME(post_date, '%%%Y, %I:%i') AS formatted_date '
           
    'FROM ibf_posts, ibf_members WHERE author_name = \'Troy_Bouffard\' AND name = \'Troy_Bouffard\'';
    if (!
    $result mysql_query($query)) {
      exit(
    '<p>Error performing query: ' mysql_error() . '</p>');
    }
    while (
    $Row mysql_fetch_array($result)) {
      
    $Avatar str_replace('uploads:''http://localhost/hfrl/forum/uploads/'$Row['avatar']);
      echo 
    '<tr>'
         
    '  <td class="content">'
         
    '    <p class="bodypad">'
         
    '      <span class="title">Subject: </span>' $Row['title'] . '&nbsp;&nbsp;'
         
    '      <span class="submitted">Submitted by: </span>' $Row['author_name']'
         . '    
    </p>'
         . '  
    </td>'
         . '  
    <td class="content"><class="bodypad">' . $Row['formatted_date'] . '</p></td>'
         . '
    </tr>'
         . '
    <tr>'
         . '  
    <td class="content"><class="bodypad">' . $Row['post'] . '</p></td>'
         . '  
    <td class="image"><img src="' . $Avatar . '" alt="Author\'s Avatar"></td>'
         . '
    </tr>'
         . '
    <tr>'
         . '  
    <td colspan="2" class="separate"><img src="pics/black.jpg" height="3"></td>'
         . '
    </tr>';
    }
    ?>

  18. #18
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    very sorry about the horizontal scrolling.

  19. #19
    SitePoint Addict sojomy's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Knightime
    very sorry about the horizontal scrolling.
    No problem, it's still usable. I just wish sitepoint did increase the size of their fonts when they did the facelift. The font size should default to 1 or 2 sizes smaller. But that's just my opinion

  20. #20
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php doesn't close correctly using that.

    What happened to all the escaped quotes? You just threw me a curve ball I don't fully understand.

  21. #21
    SitePoint Addict sojomy's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Knightime
    <?php doesn't close correctly using that.

    What happened to all the escaped quotes? You just threw me a curve ball I don't fully understand.
    What do you mean by "<?php doesn't close correctly?" I'm not understanding that part.

    I forgot to mention, that when I edited your code, I changed all of the double-quoted strings
    to single-quoted strings. I was told that when PHP parses double-quoted strings, it has
    to check to see if any of it is a variable and then put the value in the string, but if you use
    single-quote strings, it doesn't, so it's faster. So I always use single quoted strings. Other
    than that, I just reformatted the code so it didn't go so far horizontally.

    Are you getting an error message? If so, what is it, and what line number?

  22. #22
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I meant was that when I copied and pasted your code from your reply window, the <?php didn't close correctly.

    On my editor (homesite) <?php and ?> will show up red if they are opened and closed correctly.

    If there is something incorrect inside, that could cause it to not close correctly also.

    Any ideas?
    Last edited by Knightime; Mar 9, 2003 at 16:30.

  23. #23
    SitePoint Addict sojomy's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try editing this line

    PHP Code:
         '      <span class="submitted">Submitted by: </span>' $Row['author_name']
    Take off the last character, the single quote. It shouldn't be there. That's the only problem
    I can see in the code. If it still doesn't work, try doing a "reply with quote" to that message
    that has the code in it and copy/paste the code from the message box. Sometimes sitepoint
    edits the code by removing single/double quotes as well as slashes.


Bookmarks

Posting Permissions

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