Jump to content

doddsey_65

Members
  • Posts

    902
  • Joined

  • Last visited

  • Days Won

    9

Posts posted by doddsey_65

  1. that sounds a bit complicated. Any tips? Here is the code for the textarea and preview box:

     

    <textarea class="test" id="reply" name="test" style="height:350px;width:785px;"></textarea>
    
    <script type="text/javascript">
        $("textarea").keyup(function () {
          var value = $(this).val();
          $("#preview").text(value);
        }).keyup();
    </script>
    
    <p id="preview">
    Your Preview will appear here
    </p>

     

    And here is some of the bbcode parser:

     

      class bbParser{
        public function __construct(){}
        
        public function getHtml($str){
    
    $bb[] = "#\[b\](.*?)\[/b\]#si";
          $html[] = "<b>\\1</b>";
          $bb[] = "#\[i\](.*?)\[/i\]#si";
          $html[] = "<i>\\1</i>";
          $bb[] = "#\[u\](.*?)\[/u\]#si";
          $html[] = "<u>\\1</u>";
    
    $str = preg_replace ($bb, $html, $str);
    
    return $str;
        }
      }

     

     

    you can see it here: http://thevault.cz.cc/new_post.php?forum=1&topic=65

    You will need to login with username:public and password:public then click Post reply at the bottom left.

  2. basically when a user enters something into textarea the content of the text area is added to the <p> as you type.

     

    but when you click a bbcode button(lets say Bold) the content of the text area will be [bold]the word[/bold]. But then the preview box will also look the same because its generated using jquerys .val().

     

    <script type="text/javascript">
        $("textarea").keyup(function () {
          var value = $(this).val();
          $("#preview").text(value);
        }).keyup();
    </script>

     

    so how would i be able to format $("#preview").text(value); with my bbparser?

  3. i have some code which displays text area contents in a preview box using jquery. but this is for a forum which means the text area will contain something like word. This will just print the . I know i can replace that with str_replace but that means the contents of the textarea need to be in a variable. so how do i add it into a variable?

     

    <script type="text/javascript">
        $("textarea").keyup(function () {
          var value = $(this).val();
          $("#preview").text(value);
        }).keyup();
    </script>
    <p id="preview">
    Your Preview will appear here
    </p>

  4. Im trying to find the time between the last database entry and the current time and then echo it so it says something like '2 minutes ago'. I tried doing:

     

    $last_post_gap = strtotime('NOW') - strtotime($topic_info->topic_last_post_time);
    	$last_post_gap = date('i', strtotime($last_post_gap));
    	$last_post = date('F j, Y', strtotime($topic_info->topic_last_post_time));
    
    
    	if ($last_post <= '- 1 DAY') 
    				{ 
    				$last_post = 'Yesterday at '.date("g:i a", strtotime($topic_info->topic_last_post_time)); 
    				}
    	if ($last_post <= '- 1 MINUTE') 
    				{ 
    				$last_post = 'Less Than 1 Minute Ago'; 
    				}
    	else
    				{
    				$last_post = $last_post_gap.' Minutes Ago';
    				}

     

    but that just displays 0 minutes ago regardless of the time.

     

    Is there anything im missing?

  5. I have the following query which selects all the info i need for the current page and displays it.

     

    $topic_info_query = $db->query("SELECT 
    								f.forum_id, f.forum_name,
    								m.user_id, m.user_username, m.user_group,
    								t.thread_topic_id, t.topic_name, t.topic_poster, t.topic_time_posted, t.topic_views,
    								t.topic_replies, t.topic_last_poster, t.topic_last_post_time, t.topic_locked,
    								t.topic_sticky, t.topic_edited
    
    								FROM ".DB_PREFIX."topics as t
    
    								LEFT JOIN ".DB_PREFIX."members as m
    								ON t.topic_poster = m.user_username
    
    								LEFT JOIN ".DB_PREFIX."forums as f
    								ON t.forum_id = f.forum_id
    
    								WHERE t.forum_id = '$forum_id'
    
    								ORDER BY t.topic_last_post_time DESC")
    								or trigger_error("SQL", E_USER_ERROR);
    
    $topic_num_rows = mysql_num_rows($topic_info_query);
    
    while ($topic_info = mysql_fetch_object($topic_info_query)) 

     

    you can see the code working here: http://thevault.cz.cc/index.php?forum=4

     

    However the last post section doesnt work.

    This is because the LEFT JOIN which joins the members table is on the topic_starter.

    but i cant add another join for the topic_last_poster cos they would go to the same thing user_username which wouldnt work.

     

    so how do i retain the join for the topic_starter while somehow getting the last_poster to work?

     

    I was under the assumption that i may have to create a new db table with seperate user information in but im not sure.

     

  6. i have the following which sends an email whenever a post is made within the topic the user is subscribed to.

    However it still sends the email to the person who made the reply. I need to take out the email of the poster if they are in the notification list. This is what i have but it doesnt seem to remove them.

     

    $notification_query = $db->query("SELECT 
    												u.user_id, 
    												u.user_email, 
    												u.user_username,
    									 n.notification_user_id
    
    									 FROM ".DB_PREFIX."members as u
    
    									 LEFT JOIN ".DB_PREFIX."notifications as n
    									 ON n.notification_user_id = u.user_id
    
    									 WHERE n.notification_topic_id = '$post_id'")
    									 or trigger_error("SQL", E_USER_ERROR);
    
    $num_rows = mysql_num_rows($notification_query);
    while ($notification_list = mysql_fetch_object($notification_query)) {
    $users4[] = $notification_list->user_email; 
    }
    
    $emailAddress = implode(', ', $users4);
    
    if (in_array($_SESSION['user_username'], $emailAddress))
    {
    $emailAddress = str_replace($_SESSION['user_username'], ' ', $emailAddress);
    }
    if ($num_rows >=1) {
    
    putenv('TZ=EST5EDT'); 
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers .= 'From: no-reply@thevault.0sites.net' . "\r\n";
    
        $message .= "A Reply Has Been Made To {$_POST['subject']}.<br /><br />";
    
    $message .= "You are receiving this message because you have subscribed
    to the topic {$_POST['subject']},<br /> which has a new post since your last one.<br />";
    $message .= "Click the link below to view the new thread now.<br />";
    $message .= "<a href=\"{$site_root}/index.php?forum={$forum_id}\">
    {$site_root}/index.php?forum={$forum_id}&topic={$thread_topic_id}</a><br />
    <br />To Unsubscribe from this topic visit the link below.<br /><br />
    <a href=\"{$site_root}/subscribe.php?forum={$forum_id}&topic={$topic_id}&uid={$notification_list->user_id}&do=unsubscribe\">
    {$site_root}/subscribe.php?forum={$forum_id}&topic={$topic_id}&uid={$notification_list->user_id}&do=unsubscribe</a><br /><br />
    Thanks";
    $subject = "A Reply Has Been Made To {$_POST['subject']}.";
        mail($emailAddress,$subject,$message,$headers);
    
    }
    				}

  7. I have this javascript code which uses mouseover for a tooltip. It works fine until i add php. Anyone know how i could add the php variable?

     

    Here is the original code:

    <span class="users_browsing" onmouseover="tooltip.show('hi');" onmouseout="tooltip.hide();">

     

    Ive tried this but it doesnt work:

     

    echo "<span class=\"users_browsing\" 
    onmouseover=\"tooltip.show(\"{$content1}\");\" 
    onmouseout=\"tooltip.hide();\">
    Users Browsing Forum: {$browsers_num}</span>";

  8. I have the following which fils a combo box with years from 1950 to 2100. This is the year box for the date of birth.

     

    Year 
    <select name="year_select">
    <?php
    for( $i=1950; $i<=2100; $i++ )
    {
    echo "<option value=\"{$i}\" class=\"year\">{$i}</option>";
    }
    ?>
    </select>

     

    I want it to automatically display the year that is in the database so instead of automatically displaying 1950 i want their birth year displayed which is $tab_info->user_dob_year. How would i go about this? i dont know where to start since im using a for loop to populate it.

  9. Im working with the animatedcollapse.js file which collapses divs. I need to collapse divs with the id's 1,2,3,4. Simple enough.

     

    However they wont always be 1,2,3,4 as these are the ids (forum_id) pulled from the database. the animatedcollapse.js script requires the names of the divs to be entered like so:

     

    <a href=\"javascript:animatedcollapse.show(['1','2','3','4'])\">

     

    but like i said it won't always be 1,2,3,4 so how can i pull the id's and add them to that href? i was thinking an array but ive never worked with them before so i cant get it to work.

     

    I need to pull all of the forum_id's where parent_id = 1 and then add the id's to the href.

  10. i have some javascript which should show the messages at the side of the input but they arent and i dont know where im going wrong.

     

    <script language="javascript">
    $(document).ready(function()
    {
    $("#fullname").blur(function()
    {
    //remove all the class add the messagebox classes and start fading
    $("#msgbox1").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
    $.post("update.php",{ fullname:$(this).val() } ,function(data)
    {
    if (data==1)
    {
    $("#msgbox1").fadeTo(200,0.1,function() //start fading the messagebox
    {
    //add message and change the class of the box and start fading
    $(this).html('Update Successful').addClass('messageboxerror').fadeTo(900,1);
    });
    }
    else
    {
    $("#msgbox1").fadeTo(200,0.1,function() //start fading the messagebox
    {
    //add message and change the class of the box and start fading
    $(this).html('Error Updating').addClass('messageboxerror').fadeTo(900,1);
    });
    }
    });
    });
    });
    </script>

     

    <input class="input2" id="fullname" type="text" name="fullname" value="<?php echo $tab_info->user_real_name; ?>" />
    <span id="msgbox1" style="display:none"></span>

     

    ive used this before and it worked but not this time. ANyone know why?

  11. i have a users online section and i am using an aray and implode so the comma is displayed on every username but the last, but it displays the same usernames several times. This could be due to the switch i am using to define user group. Heres the code:

     

    $online_query = $db->query("SELECT user_id, user_group, user_username
                                FROM ".DB_PREFIX."sessions");
    while ($online_info = mysql_fetch_object($online_query)) {
    
    switch($online_info->user_group)
            {
                case 1:
                    $userClass = 'admin';
                    break;
                case 2:
                    $userClass = 'mod';
                    break;
                case 3:
                case 0:
                default:
                    $userClass = 'user';
                    break;
            }
    
    $users2[] = "<span class=\"{$userClass}\">{$online_info->user_username}</span>"; 
    
    echo '<p>' . implode(', ', $users2) . '</p>';
    }

     

    is there something i am doing wrong?

     

  12. i have some code which sends a confrim link via the posted email. In hotmail it works fine, once the link is clicked they are confirmed but gmail adds %09 to the link making it break.

     

    example

    WHERE hash = their email hashed

     

    posted email = test@test.com

    confirm link(hotmail) confirm.php?email=HASH&o=test@test.com(works)

     

    confirm link(gmail)confirm.php?email=%09HASH&o=test@test.com(Doesnt work)

     

    anyone know why gmail does this?

  13. i am trying to update a column in the database. I can update int columns but what about text? i want to update it so that the new text is added to it while keeping the old one. Here is what i have(which isnt working):

     

    mysql_query("UPDATE ".DB_PREFIX."posts
                SET post_content = '$old_content' + '".$_POST['test']."'
                WHERE post_id = '$double_post_id'") or die(mysql_error());

     

    i have also tried:

     

    SET post_content = post_content + '".$_POST['test']."' 

     

    but that didnt work either. What should i be doing?

  14. in my login script i have the following which searches for the username they inputted and then adds their user id to the table sessions in the database.

     

    $result = mysql_query("SELECT * FROM ".DB_PREFIX."members WHERE user_username = '$username' AND user_password = '$password'");
            
                if(mysql_num_rows($result) != 1)
                {
                    $val_error = 'Username and Password incorrect.';
                }
                    else
                    {
                     $row = mysql_fetch_array($result);
                        $browser = $_SERVER['HTTP_USER_AGENT'];
                        $_SESSION['user_id'] = $row['user_id'];
                        $_SESSION['session'] = session_id();
                        mysql_query("INSERT INTO ".DB_PREFIX."sessions 
                        VALUES(NULL, '".$_SESSION['user_id']."', '".$_SESSION['session']."', '".$_SERVER['REMOTE_ADDR']."', '".$_SERVER['HTTP_USER_AGENT']."', '".date('Y-m-d')."')");
                        
                        if ($_SESSION['backpage']) 
                        {
                        header('Location: '.$_SESSION['backpage']);
                        } else {
                        
                        header('Location: index.php');
                        }
                    }

     

    then on pages which i want only logged in members to access i have the following:

     

    if ($_SESSION['user_id'] == '') {
    header ('Location: '.SITE_ROOT.'/login.php');
    } else { REST OF CODE }

     

    but when i login and try to access a page which requires you to be logged in i am directed back to index.php. I have nothing which does that. if you are not logged in you are redirected to login.php but it doesnt seem to work.

    Any ideas?

     

  15. $query = "SELECT * FROM account_info";

     

    you are selecting everyone from account_info

     

    try:

     

    $query = "SELECT * FROM account_info WHERE username = '".$_POST['username']."'";

     

    that will make sure you are only selecting the user who registered by pulling what they added in the username field

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.