includes/pageprocess.php
changeset 47 d6361ccbd2bd
parent 46 6ddaa9bd7977
child 61 e9708657875a
equal deleted inserted replaced
46:6ddaa9bd7977 47:d6361ccbd2bd
   523     $q = $db->sql_query('SELECT u.username, u.user_id AS authoritative_uid, u.real_name, u.email, u.reg_time, x.*, COUNT(c.comment_id) AS n_comments
   523     $q = $db->sql_query('SELECT u.username, u.user_id AS authoritative_uid, u.real_name, u.email, u.reg_time, x.*, COUNT(c.comment_id) AS n_comments
   524                            FROM '.table_prefix.'users u
   524                            FROM '.table_prefix.'users u
   525                            LEFT JOIN '.table_prefix.'users_extra AS x
   525                            LEFT JOIN '.table_prefix.'users_extra AS x
   526                              ON ( u.user_id = x.user_id OR x.user_id IS NULL ) 
   526                              ON ( u.user_id = x.user_id OR x.user_id IS NULL ) 
   527                            LEFT JOIN '.table_prefix.'comments AS c
   527                            LEFT JOIN '.table_prefix.'comments AS c
   528                              ON ( ( c.user_id=authoritative_uid AND c.approved=1 ) OR ( c.comment_id IS NULL AND c.approved IS NULL ) )
   528                              ON ( ( c.user_id=u.user_id AND c.name=u.username AND c.approved=1 ) OR ( c.comment_id IS NULL AND c.approved IS NULL ) )
   529                            WHERE u.username=\'' . $db->escape($target_username) . '\'
   529                            WHERE u.username=\'' . $db->escape($target_username) . '\'
   530                            GROUP BY u.user_id;');
   530                            GROUP BY u.user_id;');
   531     if ( !$q )
   531     if ( !$q )
   532       $db->_die();
   532       $db->_die();
   533     
   533     
   581     }
   581     }
   582     
   582     
   583     // Comments
   583     // Comments
   584     
   584     
   585     echo '<tr><th class="subhead">' . htmlspecialchars($target_username) . '\'s latest comments</th></tr>';
   585     echo '<tr><th class="subhead">' . htmlspecialchars($target_username) . '\'s latest comments</th></tr>';
   586     $q = $db->sql_query('SELECT page_id, namespace, subject, time FROM '.table_prefix.'comments WHERE name=\'' . $db->escape($target_username) . '\' AND approved=1 ORDER BY time DESC LIMIT 5;');
   586     $q = $db->sql_query('SELECT page_id, namespace, subject, time FROM '.table_prefix.'comments WHERE name=\'' . $db->escape($target_username) . '\' AND user_id=' . $userdata['authoritative_uid'] . ' AND approved=1 ORDER BY time DESC LIMIT 5;');
   587     if ( !$q )
   587     if ( !$q )
   588       $db->_die();
   588       $db->_die();
   589     
   589     
   590     $comments = Array();
   590     $comments = Array();
   591     $no_comments = false;
   591     $no_comments = false;