SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Location
    Medford, Oregon
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    One page in forum on my site loading wayyyyyy too slowly after new function added

    A short while back I paid a guy to make some changes. He mostly did great work, then disappeared. Before long the view forum thread page began getting slower and slower.

    One of the changes added a thumbs-up rating mechanism. Additionally, all of the ratings were tabulated and printed under the user name each time he posted even if not being rated for that particular post.

    Though mostly older Php 3, I recall being told that he was going to be using objects and Ajax. So the overall site design may change drastically right there.

    I really need help and would be cheered to either pay or praise anyone who can go in there and fit the pieces together. I studied 3.0 and 4.0 for a while, then gave up. The reading leaves me rather well being able to read the older code, but not Ajax or objects. Trying to shut it off myself led to a complete page error.

    Moreover, there is at least a possibility that some other issue is the culprit.

    Ideally, I would like to get the rating function working properly. But off is better than the massive slowdown currently being endured.

    Below are the lines from the file where the new function was installed. The site is meetchristians.com. You can view any forum posting in two ways, through the tour view (no ratings, no slowdown) or in logged in mode. Logging in is the only way to experience the slowdown. Anyone interested enough can easily create a free membership in about 5 minutes by just using the tab key and spacebar to quickly insert the default value for each field when creating a dummy profile.

    Anyway, I have been running ads for weeks on craigslist, to no avail, and started seeking help on oDesk yesterday, thus far without remedy. That brings me here. A while back I brought a problem to sitepoint and actually got contacted by a member who repaired the SQL issue on that occasion.

    So for money or mercy, if you can and will help, if you are advanced enough to navigate through somewhat complicated code that mixes old and new, terrific. Though with limited resources, I have some dinero saved and will feel just fine if the total is merely a few hours with a fairly modest hourly rate.

    Unless just fixing a typo, instructing me in long language how to get in there and code will probably be wasted. Just let me pay. I would love hearing the remedy explained, to be sure, but also need to make sure the work is done by somebody a lot more capable than me.

    Instead of pasting code in this post, I will drop it into the next one because it turns out to be more than just a few lines.

    Oh, and by the way, his database SQLi calls are in addition to the SQL calls made higher up on the page for every other function.
    Visit http://meetchristians.com. Not today tho - She's broken

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Location
    Medford, Oregon
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    ## 2012 AUG 18 - Phoenix - thumbWrap class added for thumbs up/down

    // Using mysqli for these calls, older database access methods
    // are depreciated and will not allow stored procedure calls
    // to run correctly (if at all)

    // Connect to the database and table
    $mysqli = new mysqli("localhost""xxxxx""xxxxx"$db);

    // execute the stored procedure
    $vote_query "call sp_get_votes($id, '$session_username');";

    // Should ALWAYS retunr true but just in case


    if ($vote_result $mysqli->query($vote_query))
    {
        
    $vote_data=$vote_result->fetch_assoc(); // get the stored procedure results
        //    Set up variables needed for voting
        
    $vote_user_id $vote_data['u_id'];     // current user's true id
        
    $vote_count_yay $vote_data['tup'];    // total yay votes (thumbs up)
        
    $vote_count_ney $vote_data['tdown'];  // total ney votes (thumbs down)
        
    $vote_mine $vote_data['my_vote'];     // current user's vote for this post
        
    $vote_governor $vote_data['vote_governor'];     // votes made in past 24 hours
        //echo "VGL: $voteGovernorLimit   VG: $vote_governor   ";    
        
    if ($session_username == $author) {
            
    // these classes will disable the buttons so
            // members cannot vote on their own threads
            
    $vote_id_ney '';
            
    $vote_id_yay '';
            
    $addl_thumb_class_ney 'thumbNoVote';
            
    $addl_thumb_class_yay 'thumbNoVote';
            
    $tag_ney 'You cannot vote on your own posts.';
            
    $tag_yay 'You cannot vote on your own posts.';
        }
        else
        {
            
    // id's are used in the javascript to determine ajax parameters
            
    $vote_id_ney_count 'lblNey' $id;
            
    $vote_id_yay_count 'lblYay' $id;
            
    $vote_id_ney_button '';
            
    $vote_id_yay_button '';
            
    // this class changes the image if the user
            // has already voted for this posting
            
    $addl_thumb_class_ney '';
            
    $addl_thumb_class_yay '';
            
    $tag_ney '';
            
    $tag_yay '';
            if (
    $vote_governor > ($voteGovernorLimit-1))
            {
                
    // At or over the limit
                
    $addl_thumb_class_ney 'thumbNoVote';
                
    $addl_thumb_class_yay 'thumbNoVote';
                
    $tag_ney "You may only vote on up to $voteGovernorLimit posts in a 24 hour period.";
                
    $tag_yay $tag_ney;
            }
            else
            {
                switch (
    $vote_mine)
                {
                    case -
    1// Ney Vote
                        
    $addl_thumb_class_ney 'thumbMyVote';
                        
    $addl_thumb_class_yay 'thumbNoVote';
                        
    $tag_ney 'You have already voted on this post.';
                        
    $tag_yay $tag_ney;
                        break;
                    case +
    1// Yay Vote
                        
    $addl_thumb_class_ney 'thumbNoVote';
                        
    $addl_thumb_class_yay 'thumbMyVote';
                        
    $tag_ney 'You have already voted on this post.';
                        
    $tag_yay $tag_ney;
                        break;
                    default: 
    // 0 - No Vote / Invalid
                        
    $tag_ney 'Click to vote NEY!';
                        
    $tag_yay 'Click to vote YAY!';
                        
    // these ids are dynamically set to the msg
                        // id and member's id and will be used by the
                        // ajax calls
                        
    $vote_id_ney_button 'NEY-' $vote_user_id '-'$id;
                        
    $vote_id_yay_button 'YAY-' $vote_user_id '-'$id;
                        break;
                }
            }
        }
        
        }
        echo 
    mysqli_error($mysqli);
        
        
    $vote_result->close(); // Close the data result
        
    $mysqli->close(); // close the database connection
        

    $mysqli = new mysqli("localhost""xxxx""xxxx"$db);
    // execute the stored procedure
    $rank_query "call sp_get_rank_info('$author');";
    if (
    $rank_result $mysqli->query($rank_query)){
        
    $rank_data=$rank_result->fetch_assoc(); // get the stored procedure results
        
    $post_rank_title $rank_data['post_rank_title'];
        
    $post_rank_index $rank_data['post_rank_index'];
        
    $post_rank_count $rank_data['post_rank_count'];
        
    $post_user_image_1 $rank_data['image1'];
        
    $post_user_image_2 $rank_data['image2'];
        
    $post_user_country $rank_data['country'];
        
    $agreementScore $rank_data['fm_agree_score'];
        
    $totalVotes $rank_data['fm_thumb_count'];
        if (empty(
    $post_user_image_1))
        {
            
    $post_user_image_1 '<td class=\'userImage\'>&nbsp;</td>';
        }
        else
        {
    $post_user_image_1 "<td class='userImage' rowspan='5'><img src='$images_dir/$post_user_image_1'></td>";
        }
        
        if (empty(
    $post_user_image_2))
        {
            
    $post_user_image_2 '<td class=\'userImage\'>&nbsp;</td>';
        }
        else
        {
    $post_user_image_2 "<td class='userImage' rowspan='5'><img src='$images_dir/$post_user_image_2'></td>";
        }
    }
    $rank_result->close(); // Close the data result
    $mysqli->close(); // close the database connection
        

    $subjectInjection "<b>Subject:&nbsp;$subject</b><br />";
    if (
    $reply_number != )
    {
        
    $temp_subject str_replace('Re: '''$subject); 
        if (
    strpos($orig_subject$temp_subject) === false)
            {
    $subjectInjection "<b>Subject:&nbsp;$subject</b><br />";
            }
        else
        {
    $subjectInjection "";}
    }


    //echo 'SRV: ' . $date . '<br />';
    //echo 'UTC: ' . gmdate('Y-m-d-H-i-s', strtotime($date));
    $date  gmdate('Y-m-d-H-i-s'strtotime($date));
    // Manipualte the time to UTC for javascript to recalculate it
    /*
    $origTimeZone = date_default_timezone_get();
    $the_date = date("Y-m-d-H-i-s", strtotime($date)); 
    date_default_timezone_set("UTC");
    $date = $the_date;
    $date = "UTC: " . date('Y-m-d-H-i-s', date($date." UTC")) . '<br />';
    echo $date;
    date_default_timezone_set($origTimeZone);
    */


    //ECHO "UTC: " . date('Y-m-d-H-i-s', date($date." UTC")) . '<br />';
    //echo "&gt;&gt;&gt;&gt;&gt;&gt;" . date(DATE_RFC822). '<br />';


    $countryFlag $icn_dir '/flags/flag_' strtolower(str_replace(' ''_'$post_user_country)) . '.png';

    print 
    "
        <tr 
    $format><td class='dullIt'>
        <!-- Start New Post Header -->
        
        <!-- Thumb / Share Voting Start -->
        <table class='thumbWrap' cellspacing='0' cellpadding='0' border='0'>
            <tr>
                <td id='
    $vote_id_yay_count' class='thumbUpCount'>$vote_count_yay</td>
                <td><div id='
    $vote_id_yay_button' alt='$tag_yay' title='$tag_yay' class='thumbUp $addl_thumb_class_yay'>&nbsp;</div></td>
                <td><div id='
    $vote_id_ney_button' alt='$tag_ney' title='$tag_ney' class='thumbDown $addl_thumb_class_ney'>&nbsp;</div></td>
                <td id='
    $vote_id_ney_count' class='thumbDownCount'>$vote_count_ney</td>
            </tr>
            <tr>
                <td colspan='4' align='center'>
                 <!-- 
    $subject_encoded -->
                    <a href='http://www.facebook.com/sharer.php?u=
    $message_url_encoded&i=http://beta.meetchristians.com/icn/mclogo.jpg&_={$cache_buster}' class='fbShare'><img src='../icn/fbshare.jpg' alt='Share on Facebook' title='Share on Facebook' /></a>

          </td>
       </tr>
    </table> 

        <!-- Thumb / Share Voting End -->
        <!-- Subject only displays if different from original subject -->
        <div>
    $subjectInjection$hits</div>
        <!-- Start Poster Info -->
        <div class='float:left'>

    <table  cellspacing='0' cellpadding='0' class='posterInfo'>
       <tr>
          <td>
    <table class='posterInfo rank rank
    $post_rank_index' cellspacing='0' cellpadding='0'>

        <tr><td><a href=focus.php?name=
    $author>$author</a></td></tr>
        <tr><td>
    $donated <a class='email' href=m_send_frm.php?m_to=$author&gto=$g><img src=../icn/mail.png border=0 alt='Send email to $author' title='Send email to $author'></a>&nbsp;$g $age 
    <img src='
    $countryFlag' alt=\"$post_user_country\" title=\"$post_user_country\" />

          </td>
       </tr>
       <tr><td>
    $post_rank_title</td></tr>
       <tr><td>
    $post_rank_count Posts</td></tr>
       <tr><td><div class='agreeMentScore' score='
    $agreementScore' votes='$totalVotes'><div></div></div>  
          </td>
       </tr>
     </table>
          </td>
    $post_user_image_1$post_user_image_2
       </tr>
    </table>
        <strong style='padding-right:15px;'>
    $orig $reply_number</strong> <span class='dateFix'>$date</span> $new

    <!-- Images -->
        
    <div style='float:right;'>
    $delete
    $report_tag
    $top
    $view_entire_thread
    $quote_reply_tag
    $reply_tag</div>

    <!-- End New Post Header -->


    <!-- Removed for now on 111707: 
    $reply_tag $author_rating -->
               </td>
            </tr>
        <tr 
    $format>
               <td class='postBody'><font face=arial size=2>
    $image1 $image2 $message
               </td>
            </tr>
            "
    ;

            
    $image1 "";
            
    $image2 "";
            }
                }

    table_footer();



    ######### Bottom reply count plus NEXT and REPLY tags begin below #########
    ######### ....................................................... #########


    print 
    Visit http://meetchristians.com. Not today tho - She's broken


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
  •