|
From: Jon O. <jon...@us...> - 2006-07-04 22:35:17
|
Update of /cvsroot/mxbb/mx_pafiledb/pafiledb/includes In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13662/modules/mx_pafiledb/pafiledb/includes Modified Files: functions.php functions_pafiledb.php Log Message: fixes Index: functions.php =================================================================== RCS file: /cvsroot/mxbb/mx_pafiledb/pafiledb/includes/functions.php,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** functions.php 4 Jul 2006 18:02:11 -0000 1.25 --- functions.php 4 Jul 2006 22:35:12 -0000 1.26 *************** *** 797,808 **** function update_voter_info( $file_id, $rating ) { ! global $user_ip, $db, $userdata, $lang; ! $where_sql = ( $userdata['user_id'] != ANONYMOUS ) ? "user_id = '" . $userdata['user_id'] . "'" : "votes_ip = '" . $user_ip . "'"; $sql = "SELECT user_id, votes_ip FROM " . PA_VOTES_TABLE . " WHERE $where_sql - AND votes_file = '" . $file_id . "' LIMIT 1"; --- 797,825 ---- function update_voter_info( $file_id, $rating ) { ! global $db, $userdata, $lang, $pafiledb_config; ! $ipaddy = getenv ( "REMOTE_ADDR" ); ! ! if ($pafiledb_config['votes_check_ip'] && $pafiledb_config['votes_check_userid']) ! { ! $where_sql = ( $userdata['user_id'] != ANONYMOUS ) ? "(user_id = '" . $userdata['user_id'] . "' OR votes_ip = '" . $ipaddy . "')": "votes_ip = '" . $ipaddy . "'"; ! } ! else if($pafiledb_config['votes_check_ip']) ! { ! $where_sql = ( $pafiledb_config['votes_check_ip'] ) ? "votes_ip = '" . $ipaddy . "'" : ''; ! } ! else if($pafiledb_config['votes_check_userid']) ! { ! $where_sql = ( $userdata['user_id'] != ANONYMOUS ) ? "user_id = '" . $userdata['user_id'] . "'" : ''; ! } ! else ! { ! $where_sql = "user_id = '-99'"; ! } ! $where_sql .= !empty($where_sql) ? " AND votes_file = '" . $file_id . "'" : "votes_file = '" . $file_id . "'"; $sql = "SELECT user_id, votes_ip FROM " . PA_VOTES_TABLE . " WHERE $where_sql LIMIT 1"; *************** *** 812,819 **** } if ( !$db->sql_numrows( $result ) ) { ! $sql = "INSERT INTO " . PA_VOTES_TABLE . " (user_id, votes_ip, votes_file, rate_point, voter_os, voter_browser, browser_version) ! VALUES('" . $userdata['user_id'] . "', '" . $user_ip . "', '" . $file_id . "','" . $rating . "', '" . $this->platform . "', '" . $this->agent . "', '" . $this->ver . "')"; if ( !( $db->sql_query( $sql ) ) ) { --- 829,840 ---- } + // + // Has already voted. Should we care? + // if ( !$db->sql_numrows( $result ) ) { ! $sql = "INSERT INTO " . PA_VOTES_TABLE . " (user_id, votes_ip, votes_file, rate_point) ! VALUES('" . $userdata['user_id'] . "', '" . $ipaddy . "', '" . $file_id . "','" . $rating . "')"; ! if ( !( $db->sql_query( $sql ) ) ) { *************** *** 823,827 **** else { ! mx_message_die( GENERAL_MESSAGE, $lang['Rerror'] ); } --- 844,849 ---- else { ! $message = $lang['Rerror'] . "<br /><br />" . sprintf( $lang['Click_return'], "<a href=\"" . append_sid( linkdb_this_mxurl( "action=link&link_id=$file_id" ) ) . "\">", "</a>" ); ! mx_message_die( GENERAL_MESSAGE, $message ); } Index: functions_pafiledb.php =================================================================== RCS file: /cvsroot/mxbb/mx_pafiledb/pafiledb/includes/functions_pafiledb.php,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** functions_pafiledb.php 4 Jul 2006 18:02:11 -0000 1.32 --- functions_pafiledb.php 4 Jul 2006 22:35:12 -0000 1.33 *************** *** 1115,1121 **** --- 1115,1167 ---- } + switch ( SQL_LAYER ) + { + case 'oracle': + $sql = "SELECT f1.*, f1.file_id, r.votes_file, AVG(r.rate_point) AS rating, COUNT(r.votes_file) AS total_votes, u.user_id, u.username, COUNT(c.comments_id) AS total_comments, cat.cat_allow_ratings, cat.cat_allow_comments + FROM " . PA_FILES_TABLE . " AS f1, " . PA_VOTES_TABLE . " AS r, " . USERS_TABLE . " AS u, " . PA_COMMENTS_TABLE . " AS c, " . PA_CATEGORY_TABLE . " AS cat + WHERE f1.file_id = r.votes_file(+) + AND f1.user_id = u.user_id(+) + AND f1.file_id = c.file_id(+) + AND f1.file_pin = " . FILE_PINNED . " + AND f1.file_approved = 1 + AND f1.file_catid = cat.cat_id + $cat_where + GROUP BY f1.file_id + ORDER BY $sort_method $sort_order"; + break; + + default: + $sql = "SELECT f1.*, f1.file_id, r.votes_file, AVG(r.rate_point) AS rating, COUNT(r.votes_file) AS total_votes, u.user_id, u.username, COUNT(c.comments_id) AS total_comments, cat.cat_allow_ratings, cat.cat_allow_comments + FROM " . PA_FILES_TABLE . " AS f1 + LEFT JOIN " . PA_VOTES_TABLE . " AS r ON f1.file_id = r.votes_file + LEFT JOIN " . USERS_TABLE . " AS u ON f1.user_id = u.user_id + LEFT JOIN " . PA_COMMENTS_TABLE . " AS c ON f1.file_id = c.file_id + LEFT JOIN " . PA_CATEGORY_TABLE . " AS cat ON f1.file_catid = cat.cat_id + WHERE f1.file_pin = " . FILE_PINNED . " + AND f1.file_approved = 1 + $cat_where + GROUP BY f1.file_id + ORDER BY $sort_method $sort_order"; + break; + } + + if ( !( $result = $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info for this category', '', __LINE__, __FILE__, $sql ); + } + $file_rowset = array(); $total_file = 0; + while ( $row = $db->sql_fetchrow( $result ) ) + { + if ( $this->auth[$row['file_catid']]['auth_read'] ) + { + $file_rowset[] = $row; + } + } + + $db->sql_freeresult( $result ); + switch ( SQL_LAYER ) { *************** *** 1350,1353 **** --- 1396,1448 ---- { case 'oracle': + $sql = "SELECT f1.*, f1.file_id, r.votes_file, AVG(r.rate_point) AS rating, COUNT(r.votes_file) AS total_votes, u.user_id, u.username, COUNT(c.comments_id) AS total_comments, cat.cat_allow_ratings, cat.cat_allow_comments + FROM " . PA_FILES_TABLE . " AS f1, " . PA_VOTES_TABLE . " AS r, " . USERS_TABLE . " AS u, " . PA_COMMENTS_TABLE . " AS c, " . PA_CATEGORY_TABLE . " AS cat + WHERE f1.file_id = r.votes_file(+) + AND f1.user_id = u.user_id(+) + AND f1.file_id = c.file_id(+) + AND f1.file_pin = " . FILE_PINNED . " + AND f1.file_approved = 1 + AND f1.file_catid = cat.cat_id + $cat_where + GROUP BY f1.file_id + ORDER BY $sort_method $sort_order"; + break; + + default: + $sql = "SELECT f1.*, f1.file_id, r.votes_file, AVG(r.rate_point) AS rating, COUNT(r.votes_file) AS total_votes, u.user_id, u.username, COUNT(c.comments_id) AS total_comments, cat.cat_allow_ratings, cat.cat_allow_comments + FROM " . PA_FILES_TABLE . " AS f1 + LEFT JOIN " . PA_VOTES_TABLE . " AS r ON f1.file_id = r.votes_file + LEFT JOIN " . USERS_TABLE . " AS u ON f1.user_id = u.user_id + LEFT JOIN " . PA_COMMENTS_TABLE . " AS c ON f1.file_id = c.file_id + LEFT JOIN " . PA_CATEGORY_TABLE . " AS cat ON f1.file_catid = cat.cat_id + WHERE f1.file_pin = " . FILE_PINNED . " + AND f1.file_approved = 1 + $cat_where + GROUP BY f1.file_id + ORDER BY $sort_method $sort_order"; + break; + } + + if ( !( $result = $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info for this category', '', __LINE__, __FILE__, $sql ); + } + + $file_rowset = array(); + $total_file = 0; + + while ( $row = $db->sql_fetchrow( $result ) ) + { + if ( $this->auth[$row['file_catid']]['auth_read'] ) + { + $file_rowset[] = $row; + } + } + + $db->sql_freeresult( $result ); + + switch ( SQL_LAYER ) + { + case 'oracle': $sql = "SELECT f1.*, f1.file_id, r.votes_file, AVG(r.rate_point) AS rating, COUNT(r.votes_file) AS total_votes, u.user_id, u.username, COUNT(c.comments_id) AS total_comments FROM " . PA_FILES_TABLE . " AS f1, " . PA_VOTES_TABLE . " AS r, " . USERS_TABLE . " AS u, " . PA_COMMENTS_TABLE . " AS c |