|
From: Jon O. <jon...@us...> - 2006-08-01 21:02:23
|
Update of /cvsroot/mxbb/mx_linkdb/linkdb/modules In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv22573/modules/mx_linkdb/linkdb/modules Modified Files: link_category.php link_link.php link_main.php link_search.php link_user_upload.php link_viewall.php Added Files: link_jump.php link_mcp.php link_post_comment.php Log Message: massive update --- NEW FILE: link_mcp.php --- <?php /** * * @package mxBB Portal Module - mx_linkdb * @version $Id: link_mcp.php,v 1.1 2006/08/01 21:02:20 jonohlsson Exp $ * @copyright (c) 2002-2006 [Mohd Basri, PHP Arena, linkdb, Jon Ohlsson] mxBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } /** * Enter description here... * */ class linkdb_mcp extends linkdb_public { /** * Enter description here... * * @param unknown_type $action */ function main( $action ) { global $db, $lang, $userdata, $board_config, $phpEx, $images, $debug; global $mx_root_path, $phpbb_root_path, $module_root_path, $is_block, $phpEx; global $linkdb_functions, $template, $linkdb_config; $cat_id = ( isset( $_REQUEST['cat_id'] ) ) ? intval( $_REQUEST['cat_id'] ) : 0; $id = ( isset( $_REQUEST['id'] ) ) ? intval( $_REQUEST['id'] ) : 0; $ids = ( isset( $_POST['ids'] ) ) ? array_map( 'intval', $_POST['ids'] ) : array(); $start = ( isset( $_REQUEST['start'] ) ) ? intval( $_REQUEST['start'] ) : 0; $mode = $mode_notification = ( isset( $_REQUEST['mode_mcp'] ) ) ? htmlspecialchars( $_REQUEST['mode_mcp'] ) : 'all'; $do_mode = ( isset( $_REQUEST['do_mode'] ) ) ? htmlspecialchars( $_REQUEST['do_mode'] ) : ''; $do_mode = ( isset( $_POST['do_approve'] ) ) ? 'do_approve' : $do_mode; $do_mode = ( isset( $_POST['do_unapprove'] ) ) ? 'do_unapprove' : $do_mode; $do_mode = ( isset( $_POST['do_delete'] ) ) ? 'do_delete' : $do_mode; // =================================================== // Auth for mcp // =================================================== if ( !($this->auth_user[$cat_id]['auth_mod']) && $mode == 'cat') { $message = sprintf( $lang['Sorry_auth_mcp'], $this->auth_user[$cat_id]['auth_mod'] ); mx_message_die( GENERAL_MESSAGE, $message ); } // // Determine all categories in which user is moderator // $moderator_cat_ids = ''; if ( isset( $this->cat_rowset ) ) { foreach( $this->cat_rowset as $auth_cat_id => $cat_row ) { if ($this->auth_user[$auth_cat_id]['auth_mod']) { $moderator_cat_ids .= !empty($moderator_cat_ids) ? ',' . $auth_cat_id : $auth_cat_id; } } } if (empty($moderator_cat_ids)) { mx_message_die( GENERAL_MESSAGE, 'Sorry, you have no moderator permissions...' ); } if ( isset( $_REQUEST['sort_method'] ) ) { switch ( $_REQUEST['sort_method'] ) { case 'Alphabetic': $sort_method = 'link_name'; break; case 'Latest': $sort_method = 'link_time'; break; case 'Hits': $sort_method = 'link_hits'; break; case 'Rating': $sort_method = 'rating'; break; default: $sort_method = $linkdb_config['sort_method']; } } else { $sort_method = $linkdb_config['sort_method']; } if ( isset( $_REQUEST['sort_order'] ) ) { switch ( $_REQUEST['sort_order'] ) { case 'ASC': $sort_order = 'ASC'; break; case 'DESC': $sort_order = 'DESC'; break; default: $sort_order = $linkdb_config['sort_order']; } } else { $sort_order = $linkdb_config['sort_order']; } $s_actions = array( 'unapproved' => $lang['Unapproved_items'], 'cat' => $lang['Item_cat'], 'all' => $lang['All_items'] ); switch ( $mode ) { case '': case 'unapproved': case 'cat': case 'all': default: $template_item = 'link_mcp.tpl'; $l_title = $lang['MCP_title']; $l_explain = $lang['MCP_title_explain']; break; } // // Approve/Unapprove // if ( $do_mode == 'do_approve' || $do_mode == 'do_unapprove' ) { if ( is_array( $ids ) && !empty( $ids ) ) { foreach( $ids as $temp_id ) { $this->approve_item( $do_mode, $temp_id ); } // // Notification // $this->update_add_item_notify($ids, $do_mode); } else { $this->approve_item( $do_mode, $id ); // // Notification // $this->update_add_item_notify($id, $do_mode); } $this->_linkdb(); } // // Delete // else if ( $do_mode == 'do_delete' ) { if ( is_array( $ids ) && !empty( $ids ) ) { foreach( $ids as $temp_id ) { $sql = 'SELECT * FROM ' . LINKS_TABLE . " WHERE link_id = $temp_id"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get item info', '', __LINE__, __FILE__, $sql ); } $item_info = $db->sql_fetchrow( $result ); // // Notification // $this->update_add_item_notify($temp_id, 'delete'); // // Comments // if ($this->comments[$item_info['link_catid']]['activated'] && $linkdb_config['del_topic']) { if ( $this->comments[$item_info['link_catid']]['internal_comments'] ) { $sql = 'DELETE FROM ' . LINK_COMMENTS_TABLE . " WHERE link_id = '" . $temp_id . "'"; if ( !( $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt delete comments', '', __LINE__, __FILE__, $sql ); } } else { if ( $item_info['topic_id'] ) { include( $module_root_path . 'linkdb/includes/functions_comment.' . $phpEx ); $linkdb_comments = new linkdb_comments(); $linkdb_comments->init( $item_info, 'phpbb'); $linkdb_comments->post('delete_all', $item_info['topic_id']); } } } $this->delete_items( $temp_id ); } } else { $sql = 'SELECT * FROM ' . LINKS_TABLE . " WHERE link_id = $id"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info', '', __LINE__, __FILE__, $sql ); } $item_info = $db->sql_fetchrow( $result ); // // Notification // $this->update_add_item_notify($id, 'delete'); // // Comments // if ($this->comments[$item_info['link_catid']]['activated'] && $linkdb_config['del_topic']) { if ( $this->comments[$item_info['link_catid']]['internal_comments'] ) { $sql = 'DELETE FROM ' . LINKS_COMMENTS_TABLE . " WHERE link_id = '" . $id . "'"; if ( !( $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt delete comments', '', __LINE__, __FILE__, $sql ); } } else { if ( $item_info['topic_id'] ) { include( $module_root_path . 'linkdb/includes/functions_comment.' . $phpEx ); $linkdb_comments = new linkdb_comments(); $linkdb_comments->init( $item_info, 'phpbb'); $linkdb_comments->post('delete_all', $item_info['topic_id']); } } } $this->delete_items( $id ); } $this->_linkdb(); } $template->set_filenames( array( 'admin' => $template_item ) ); if ($mode == 'cat') { //$s_hidden_fields = '<input type="hidden" name="cat_id" value="' . $cat_id . '">'; } $template->assign_vars( array( 'LINKS' => $linkdb_config['module_name'], 'U_LINKS' => append_sid( $this->this_mxurl() ), 'L_MCP_TITLE' => $l_title, 'L_MCP_EXPLAIN' => $l_explain, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ACTION' => append_sid( $this->this_mxurl( "action=mcp" ) ) )); // // Lets start displaying... // if ( in_array( $mode, array( 'unapproved', 'cat', 'all' ) ) ) { // // All items (or all items in cat) // if ( $mode == 'all' || $mode == 'cat' ) { $where_sql = ($mode == 'cat') ? "AND link_catid = '$cat_id'" : ''; $sql = "SELECT link_name, link_approved, link_id FROM " . LINKS_TABLE . " as f1 WHERE link_approved = '1' ".$where_sql." AND link_catid IN (".$moderator_cat_ids.") ORDER BY link_time DESC"; if ( ( !$result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get item info', '', __LINE__, __FILE__, $sql ); } $total_num = $db->sql_numrows( $result ); if ( !( $result = $linkdb_functions->sql_query_limit( $sql, $linkdb_config['pagination'], $start ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get item info', '', __LINE__, __FILE__, $sql ); } while ( $row = $db->sql_fetchrow( $result ) ) { $all_rowset[] = $row; } } // // Unapproved files only // if ( $mode == 'unapproved' || $mode == 'all' || $mode == 'cat') { $sql = "SELECT link_name, link_approved, link_id FROM " . LINKS_TABLE . " WHERE link_approved = '0' AND link_catid IN (".$moderator_cat_ids.") ORDER BY link_time DESC"; if ($mode == 'unapproved') { if ( !( $result = $linkdb_functions->sql_query_limit( $sql, $linkdb_config['pagination'], $start ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get item info', '', __LINE__, __FILE__, $sql ); } $total_num = $db->sql_numrows( $result ); } else { if ( ( !$result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get item info', '', __LINE__, __FILE__, $sql ); } } while ( $row = $db->sql_fetchrow( $result ) ) { $unapproved_rowset[] = $row; } } // // Ensure $total_num nonzero to validate pagination // $total_num = empty($total_num) ? 1 : $total_num; // // Define display sets // if ( $mode == '' ) { $global_array = array( 0 => array( 'lang_var' => $lang['Unapproved_items'], 'row_set' => $unapproved_rowset, 'approval' => 'approve' ), 1 => array( 'lang_var' => $lang['Approved_items'], 'row_set' => $all_rowset, 'approval' => 'unapprove' ) ); } elseif ( $mode == 'all' ) { $global_array = array( 0 => array( 'lang_var' => $lang['Unapproved_items'], 'row_set' => $unapproved_rowset, 'approval' => 'approve' ), 1 => array( 'lang_var' => $lang['Approved_items'], 'row_set' => $all_rowset, 'approval' => 'unapprove' ) ); } elseif ( $mode == 'cat' ) { $global_array = array( 0 => array( 'lang_var' => $lang['Unapproved_items'], 'row_set' => $unapproved_rowset, 'approval' => 'approve' ), 1 => array( 'lang_var' => $lang['Approved_items'], 'row_set' => $all_rowset, 'approval' => 'unapprove' ) ); } elseif ( $mode == 'unapproved' ) { $global_array = array( 0 => array( 'lang_var' => $lang['Unapproved_items'], 'row_set' => $unapproved_rowset, 'approval' => 'approve' ) ); } // // Generate Select dropdown navigation // $s_list = ''; foreach( $s_actions as $item_mode => $lang_var ) { $s = ''; if ( $mode == $item_mode ) { $s = ' selected="selected"'; } $s_list .= '<option value="' . $item_mode . '"' . $s . '>' . $lang_var . '</option>'; } $cat_list = '<select name="cat_id">'; if ( !$this->cat_rowset[$cat_id]['cat_parent'] ) { $cat_list .= '<option value="0" selected>' . $lang['None'] . '</option>\n'; } else { $cat_list .= '<option value="0">' . $lang['None'] . '</option>\n'; } $cat_list .= $this->generate_jumpbox( 0, 0, array( $cat_id => 1 ), false, true, 'auth_mod' ); $cat_list .= '</select>'; $template->assign_vars( array( 'L_EDIT' => $lang['Elinktitle'], // Module specific 'L_DELETE' => $lang['Dlinktitle'], // Module specific 'L_CATEGORY' => $lang['Category'], 'L_MODE' => $lang['View'], 'L_GO' => $lang['Go'], 'L_DELETE_ITEM' => $lang['Delete_selected'], 'L_APPROVE' => $lang['Approve'], 'L_UNAPPROVE' => $lang['Unapprove'], 'L_APPROVE_ITEM' => $lang['Approve_selected'], 'L_UNAPPROVE_ITEM' => $lang['Unapprove_selected'], 'L_NO_ITEMS' => $lang['No_item'], 'PAGINATION' => generate_pagination( append_sid( $this->this_mxurl( "action=mcp&mode_mcp=$mode&sort_method=$sort_method&sort_order=$sort_order" ) . ($mode == 'cat' ? "&cat_id=$cat_id" : '') ), $total_num, $linkdb_config['pagination'], $start ), 'PAGE_NUMBER' => sprintf( $lang['Page_of'], ( floor( $start / $linkdb_config['pagination'] ) + 1 ), ceil( $total_num / $linkdb_config['pagination'] ) ), 'S_CAT_LIST' => $cat_list, 'S_MODE_SELECT' => $s_list ) ); foreach( $global_array as $data ) { $approve = false; $unapprove = false; if ( $data['approval'] == 'both' ) { $approve = $unapprove = true; } elseif ( $data['approval'] == 'approve' ) { $approve = true; } elseif ( $data['approval'] == 'unapprove' ) { $unapprove = true; } $template->assign_block_vars( 'mcp_mode', array( 'L_MODE' => $data['lang_var'], 'DATA' => ( isset( $data['row_set'] ) ) ? true : false, 'APPROVE' => $approve, 'UNAPPROVE' => $unapprove ) ); if ( isset( $data['row_set'] ) ) { $i = ( $mode == 'unapproved' || ( count($global_array) > 1 && $data['approval'] == 'unapprove' ) ) ? $start + 1 : '1'; foreach( $data['row_set'] as $item_data ) { $approve_mode = ( $item_data['link_approved'] ) ? 'do_unapprove' : 'do_approve'; $template->assign_block_vars( 'mcp_mode.row', array( 'NAME' => $item_data['link_name'], 'NUMBER' => $i++, 'ID' => $item_data['link_id'], 'U_EDIT' => append_sid( $this->this_mxurl( "action=user_upload&mode_mcp=edit&link_id={$item_data['link_id']}" ) ), 'U_DELETE' => append_sid( $this->this_mxurl( "action=mcp&mode_mcp=$mode&do_mode=do_delete&id={$item_data['link_id']}" ) ), 'U_APPROVE' => append_sid( $this->this_mxurl( "action=mcp&mode_mcp=$mode&do_mode=$approve_mode&id={$item_data['link_id']}" ) . ($mode == 'cat' ? "&cat_id=$cat_id" : '') ), 'L_APPROVE' => ( $item_data['link_approved'] ) ? $lang['Unapprove'] : $lang['Approve'] ) ); } } else { $template->assign_block_vars( 'mcp_mode.no_data', array()); } } } // // Notification // $itemId = !empty($id) ? $id : $ids; $this->update_add_item_notify($itemId, $mode_notification); $template->assign_vars( array( 'ERROR' => ( sizeof( $this->error ) ) ? implode( '<br />', $this->error ) : '' ) ); $this->display( $lang['MCP'], $template_item ); $this->_linkdb(); } } ?> Index: link_category.php =================================================================== RCS file: /cvsroot/mxbb/mx_linkdb/linkdb/modules/link_category.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** link_category.php 5 Jul 2006 22:49:20 -0000 1.10 --- link_category.php 1 Aug 2006 21:02:19 -0000 1.11 *************** *** 27,46 **** function main( $action ) { ! global $template, $lang, $phpEx, $linkdb_config, $_REQUEST, $userdata; ! // ! // Get the id ! // ! if ( isset( $_REQUEST['cat_id'] ) ) ! { ! $cat_id = intval( $_REQUEST['cat_id'] ); ! } ! else { mx_message_die( GENERAL_MESSAGE, $lang['Cat_not_exist'] ); } ! $start = ( isset( $_REQUEST['start'] ) ) ? intval( $_REQUEST['start'] ) : 0; ! if ( isset( $_REQUEST['sort_method'] ) ) { --- 27,47 ---- function main( $action ) { ! global $template, $lang, $phpEx, $linkdb_config, $userdata; ! global $mx_root_path, $module_root_path, $is_block, $phpEx, $mx_request_vars; ! // ======================================================= ! // Request vars ! // ======================================================= ! $start = $mx_request_vars->request('start', MX_TYPE_INT, 0); ! $cat_id = $mx_request_vars->request('cat_id', MX_TYPE_INT, ''); ! ! if ( empty( $cat_id ) ) { mx_message_die( GENERAL_MESSAGE, $lang['Cat_not_exist'] ); } ! // ! // Sorting of items ! // if ( isset( $_REQUEST['sort_method'] ) ) { *************** *** 84,87 **** --- 85,116 ---- } + // ======================================================= + // If user not allowed to view article listing (read) and there is no sub Category + // or the user is not allowed to view these category we gave him a nice message. + // ======================================================= + $show_category = false; + if ( isset( $this->subcat_rowset[$cat_id] ) ) + { + foreach( $this->subcat_rowset[$cat_id] as $sub_cat_id => $sub_cat_row ) + { + if ( $this->auth_user[$sub_cat_id]['auth_view'] ) + { + $show_category = true; + break; + } + } + } + + if ( ( !$this->auth_user[$cat_id]['auth_view'] ) && ( !$show_category ) ) + { + if ( !$userdata['session_logged_in'] ) + { + // mx_redirect(append_sid($mx_root_path . "login.$phpEx?redirect=". $this->this_mxurl("mode=cat&cat=" . $cat_id, true), true)); + } + + $message = $lang['Not_authorized']; + mx_message_die( GENERAL_MESSAGE, $message ); + } + if ( !isset( $this->cat_rowset[$cat_id] ) ) { *************** *** 90,93 **** --- 119,134 ---- // + // Validate Comments Setup + // + if ( $this->comments[$cat_id]['activated'] && !$this->comments[$cat_id]['internal_comments'] && $this->comments[$cat_id]['comments_forum_id'] < 1 ) + { + // + // Commenting is enabled but no category forum id specified + // + $message = $lang['No_cat_comments_forum_id']; + mx_message_die(GENERAL_MESSAGE, $message); + } + + // // assign var for naviagation // *************** *** 95,103 **** $template->assign_vars( array( - 'L_INDEX' => sprintf( $lang['Forum_Index'], $board_config['sitename'] ), - - 'U_INDEX' => append_sid( 'index.' . $phpEx ), 'U_LINK' => append_sid( $this->this_mxurl() ), - 'LINKS' => $lang['Links_Title'] ) ); --- 136,140 ---- *************** *** 114,118 **** } ! $this->display_files( $sort_method, $sort_order, $start, $no_file_message, $cat_id ); $this->display( $lang['Links_Title'], 'link_category_body.tpl' ); --- 151,155 ---- } ! $this->display_items( $sort_method, $sort_order, $start, $no_file_message, $cat_id ); $this->display( $lang['Links_Title'], 'link_category_body.tpl' ); Index: link_user_upload.php =================================================================== RCS file: /cvsroot/mxbb/mx_linkdb/linkdb/modules/link_user_upload.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** link_user_upload.php 5 Jul 2006 22:49:20 -0000 1.9 --- link_user_upload.php 1 Aug 2006 21:02:20 -0000 1.10 *************** *** 27,169 **** function main( $action ) { ! global $_REQUEST, $_POST, $linkdb_config, $phpbb_root_path, $module_root_path, $board_config; ! global $template, $db, $lang, $userdata, $user_ip, $phpEx, $linkdb_functions; // ! // Get Vars // ! $cat_id = ( isset( $_REQUEST['cat_id'] ) ) ? intval( $_REQUEST['cat_id'] ) : 0; ! $edit_link_id = ( isset( $_REQUEST['link_id'] ) ) ? intval( $_REQUEST['link_id'] ) : 0; ! ! include( $module_root_path . 'linkdb/includes/functions_field.' . $phpEx ); ! $custom_field = new custom_field(); ! $custom_field->init(); ! if ( $linkdb_config['lock_submit_site'] && $userdata['user_level'] != ADMIN ) { ! $message = $lang['Lock_submit_site']; ! $message .= '<br /><br />' . sprintf( $lang['Click_return_links'], '<a href="' . append_sid( $this->this_mxurl() ) . '">', '</a>' ); ! ! $template->assign_vars( array( 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid( $this->this_mxurl() ) . '">' ! ) ); ! mx_message_die( GENERAL_MESSAGE, $message ); } // ! // Check allow guset submit site // ! if ( UPDATEUPDATE ) { ! $redirect = $this->this_mxurl( "action=user_upload" ); ! if ( !empty( $cat_id ) ) { ! $redirect .= "&cat_id=" . $cat_id; } ! $s_login_fields = '<input type="hidden" name="redirect" value="' . $redirect . '" />'; ! $template->assign_vars( array( ! 'ALLOW_GUEST' => '1', ! 'LINK_GUEST_REG' => $lang['Link_guest_reg'], ! 'L_ENTER_PASSWORD' => $lang['Enter_password'], ! 'S_LOGIN_FIELDS' => $s_login_fields ! ) ); ! $template->assign_block_vars( 'guestname', array() ); } ! elseif ( !$userdata['session_logged_in'] ) { ! $redirect = $this->this_mxurl( "action=user_upload" ); ! if ( !empty( $cat_id ) ) ! { ! $redirect .= "&cat_id=" . $cat_id; ! } ! redirect( append_sid( "login.$phpEx?redirect=" . $redirect, true ) ); } ! else { ! $template->assign_vars( array( 'ALLOW_GUEST' => '0' ) ); } ! // IF submit then upload the link and update the sql for it ! if ( isset( $_POST['submit'] ) ) { ! if ( !$edit_link_id ) { ! $temp_id = $this->update_add_link(); ! $custom_field->file_update_data( $temp_id ); ! $this->_linkdb(); ! if ( $userdata['user_level'] != ADMIN ) { ! $link_url = ( !empty( $_POST['download_url'] ) ) ? $_POST['download_url'] : ''; ! ! if ( UPDATEUPDATE ) { ! $sql = "SELECT user_email, user_lang ! FROM " . USERS_TABLE . " ! WHERE user_level = " . ADMIN; ! if ( !$admin_result = $db->sql_query( $sql ) ) { ! mx_message_die( GENERAL_ERROR, "Could not query users table", "", __LINE__, __FILE__, $sql ); } ! ! include( $phpbb_root_path . 'includes/emailer.' . $phpEx ); ! while ( $to_userdata = $db->sql_fetchrow( $admin_result ) ) { ! if ( $to_userdata['user_email'] ) ! { ! $emailer = new emailer( $board_config['smtp_delivery'] ); ! ! $emailer->from( $board_config['board_email'] ); ! $emailer->replyto( $board_config['board_email'] ); ! // ! // set to linkdb/lauguage ! // ! $phpbb_root_path_tmp = $phpbb_root_path; ! $phpbb_root_path = 'linkdb/'; ! $emailer->use_template( 'link_add', $to_userdata['user_lang'] ); ! $phpbb_root_path = $phpbb_root_path_tmp; ! $emailer->email_address( $to_userdata['user_email'] ); ! $emailer->assign_vars( array( ! 'LINK_URL' => $link_url, ! 'SITENAME' => $board_config['sitename'] ! )); ! $emailer->send(); ! $emailer->reset(); ! } ! } } ! ! if ( !$board_config['privmsg_disable'] && $linkdb_config['pm_notify'] ) { ! pm_to_admin( $this->$link_url ); } - } ! $message = $lang['Linkadded'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( $this->this_mxurl( "action=user_upload" ) ) . '">', '</a>' ); } else { ! $temp_id = $this->update_add_link( $edit_link_id ); ! $custom_field->file_update_data( $temp_id ); ! $this->_linkdb(); ! $message = $lang['Linkedited'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( $this->this_mxurl( "action=user_upload" ) ) . '">', '</a>' ); } ! $template->assign_vars( array( ! 'META' => '<meta http-equiv="refresh" content="3;url=' . $this->this_mxurl( "action=category&cat_id=$cat_id" ) . '">' ! ) ); mx_message_die( GENERAL_MESSAGE, $message ); } ! ! if ( !isset( $_POST['submit'] ) ) { ! if ( $edit_link_id == 0 ) { if ( $userdata['user_level'] == ADMIN ) $template->assign_block_vars( 'ADMIN', array() ); --- 27,238 ---- function main( $action ) { ! global $linkdb_config, $phpbb_root_path, $module_root_path, $board_config; ! global $template, $db, $lang, $userdata, $user_ip, $phpEx, $linkdb_functions, $mx_request_vars; // ! // Request vars // ! $cat_id = $mx_request_vars->request('cat_id', MX_TYPE_INT, 0); ! $link_id = $mx_request_vars->request('link_id', MX_TYPE_INT, 0); ! $do = ( isset( $_REQUEST['do'] ) ) ? intval( $_REQUEST['do'] ) : ''; ! // ! // Main Auth ! // ! if ( !empty( $cat_id ) ) { ! if ( !$this->auth_user[$cat_id]['auth_post'] ) ! { ! mx_message_die( GENERAL_MESSAGE, $lang['Sorry_auth_post'] ); ! } ! } ! else ! { ! $dropmenu = ( !$cat_id ) ? $this->generate_jumpbox( 0, 0, '', true, true, 'auth_post' ) : $this->generate_jumpbox( 0, 0, array( $cat_id => 1 ), true, true, 'auth_post' ); ! if ( empty( $dropmenu ) ) ! { ! mx_message_die( GENERAL_MESSAGE, $lang['Sorry_auth_post'] ); ! } } // ! // Load link info...if link_id is set // ! if ( $link_id ) { ! $sql = 'SELECT * ! FROM ' . LINKS_TABLE . " ! WHERE link_id = '".$link_id."'"; ! ! if ( !( $result = $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Couldnt query Link data', '', __LINE__, __FILE__, $sql ); } ! ! $link_data = $db->sql_fetchrow( $result ); ! ! $db->sql_freeresult( $result ); } ! ! // ! // Further security. ! // Reset vars if no related data exist. ! // ! if ( $link_id && !$link_data['link_catid'] ) { ! $link_id = 0; } ! ! if ( $cat_id && !$this->cat_rowset[$cat_id]['cat_id'] ) { ! $cat_id = 0; } ! // ! // Instatiate custom fields ! // ! $linkdb_custom_field = new mx_custom_field(LINK_CUSTOM_TABLE, LINK_CUSTOM_DATA_TABLE); ! $linkdb_custom_field->init(); ! // ======================================================= ! // Delete ! // ======================================================= ! if ( $do == 'delete' && $link_id) { ! if ( ( $this->auth_user[$link_data['link_catid']]['auth_delete'] && $link_data['user_id'] == $userdata['user_id'] ) || $this->auth_user[$link_data['link_catid']]['auth_mod'] ) { ! // ! // Notification ! // ! $this->update_add_item_notify($link_id, 'delete'); ! // ! // Comments ! // ! if ($this->comments[$link_data['link_catid']]['activated'] && $linkdb_config['del_topic']) { ! if ( $this->comments[$link_data['link_catid']]['internal_comments'] ) { ! $sql = 'DELETE FROM ' . LINK_COMMENTS_TABLE . " ! WHERE link_id = '" . $link_id . "'"; ! ! if ( !( $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Couldnt delete comments', '', __LINE__, __FILE__, $sql ); } ! } ! else ! { ! if ( $link_data['topic_id'] ) { ! include( $module_root_path . 'linkdb/includes/functions_comment.' . $phpEx ); ! $linkdb_comments = new linkdb_comments(); ! $linkdb_comments->init( $link_data, 'phpbb'); ! $linkdb_comments->post('delete_all', $link_data['topic_id']); ! } ! } ! } ! $this->delete_items( $link_id ); ! $this->_linkdb(); ! $message = $lang['Linkdeleted'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( $this->this_mxurl( "action=category&cat_id=" . $link_data['link_catid'] ) ) . '">', '</a>' ); ! mx_message_die( GENERAL_MESSAGE, $message ); ! } ! else ! { ! mx_message_die( GENERAL_MESSAGE, $lang['Sorry_auth_delete'] ); ! } ! } ! // ! // IF submit then upload the link and update the sql for it ! // ! if ( isset( $_POST['submit'] ) && $cat_id ) ! { ! if ( !$link_id ) ! { ! if ( $this->auth_user[$cat_id]['auth_post'] || $this->auth_user[$cat_id]['auth_mod'] ) ! { ! $link_post_mode = 'add'; ! $temp_id = $this->update_add_item(); ! $linkdb_custom_field->file_update_data( $temp_id ); ! if ( $this->auth_user[$cat_id]['auth_approval'] || $this->auth_user[$cat_id]['auth_mod'] ) ! { ! $message = $lang['Linkadded'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( $this->this_mxurl( "action=link&link_id=" . $link_id ) ) . '">', '</a>' ); } ! else { ! $message = $lang['Linkadded_not_validated'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( $this->this_mxurl( "action=category&cat_id=" . $cat_id ) ) . '">', '</a>' ); } ! $this->_linkdb(); ! } ! else ! { ! $message = $lang['Sorry_auth_post']; ! } } else { ! if ( ($this->auth_user[$cat_id]['auth_edit'] && $link_data['user_id'] == $userdata['user_id'] ) || $this->auth_user[$cat_id]['auth_mod'] ) ! { ! $link_post_mode = 'edit'; ! ! $temp_id = $this->update_add_item( $link_id ); ! $linkdb_custom_field->file_update_data( $temp_id ); ! ! if ( $this->auth_user[$cat_id]['auth_approval_edit'] || $this->auth_user[$cat_id]['auth_mod'] ) ! { ! $message = $lang['Linkedited'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( $this->this_mxurl( "action=link&link_id=" . $link_id ) ) . '">', '</a>' ); ! } ! else ! { ! $message = $lang['Linkedited_not_validated'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( $this->this_mxurl( "action=category&cat_id=" . $cat_id ) ) . '">', '</a>' ); ! ! } ! ! $this->_linkdb(); ! } ! else ! { ! $message = $lang['Sorry_auth_edit']; ! } } ! // ! // Notification ! // ! $this->update_add_item_notify($link_id, $link_post_mode); ! ! // ! // Auto comment ! // ! if ( $this->comments[$cat_id]['activated'] && $this->comments[$cat_id]['autogenerate_comments'] ) ! { ! // ! // Autogenerate comment (duplicate the notification message) ! // ! $mx_pa_notification = new mx_pa_notification(); ! $mx_pa_notification->init( $link_id ); ! $mx_pa_notification->_compose_auto_note($link_post_mode == 'add' ? MX_NEW_NOTIFICATION : MX_EDITED_NOTIFICATION); ! ! // ! // Generate comment ! // ! $this->update_add_comment('', $link_id, 0, addslashes(trim($mx_pa_notification->subject)), addslashes(trim($mx_pa_notification->message))); ! } mx_message_die( GENERAL_MESSAGE, $message ); } ! else ! // ======================================================= ! // IF not submit then load data MAIN form ! // ======================================================= { ! if ( !$link_id ) { if ( $userdata['user_level'] == ADMIN ) $template->assign_block_vars( 'ADMIN', array() ); *************** *** 192,196 **** $link_url = 'http://'; $link_logo_src = 'http://'; ! $custom_exist = $custom_field->display_edit(); $s_hidden_fields = '<input type="hidden" name="action" value="user_upload">'; --- 261,265 ---- $link_url = 'http://'; $link_logo_src = 'http://'; ! $custom_exist = $linkdb_custom_field->display_edit(); $s_hidden_fields = '<input type="hidden" name="action" value="user_upload">'; *************** *** 198,214 **** else { - $sql = 'SELECT * - FROM ' . LINKS_TABLE . " - WHERE link_id = $edit_link_id"; - if ( !( $result = $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info', '', __LINE__, __FILE__, $sql ); - } - $link_info = $db->sql_fetchrow( $result ); - // // Auth check // ! if ( $userdata['user_id'] == $link_info['user_id'] || $userdata['user_level'] == ADMIN ) { if ( $userdata['user_level'] == ADMIN ) $template->assign_block_vars( 'ADMIN', array() ); --- 267,274 ---- else { // // Auth check // ! if ( ( $this->auth_user[$link_data['link_catid']]['auth_edit'] && $link_data['user_id'] == $userdata['user_id'] ) || $this->auth_user[$link_data['link_catid']]['auth_mod'] ) { if ( $userdata['user_level'] == ADMIN ) $template->assign_block_vars( 'ADMIN', array() ); *************** *** 229,244 **** } ! $link_name = $link_info['link_name']; ! $link_longdesc = $link_info['link_longdesc']; ! $link_cat_list = $this->generate_jumpbox( 0, 0, array( $link_info['link_catid'] => 1 ), true, true ); ! $link_download = $link_info['link_hits']; ! $approved_checked_yes = $link_info['link_approved'] == 1 ? ' checked' : ''; ! $approved_checked_no = $link_info['link_approved'] == 0 ? ' checked' : '';; ! $link_url = $link_info['link_url']; ! $link_logo_src = $link_info['link_logo_src']; ! $custom_exist = $custom_field->display_edit(); $s_hidden_fields = '<input type="hidden" name="action" value="user_upload">'; ! $s_hidden_fields .= '<input type="hidden" name="link_id" value="' . $edit_link_id . '">'; } else --- 289,304 ---- } ! $link_name = $link_data['link_name']; ! $link_longdesc = $link_data['link_longdesc']; ! $link_cat_list = $this->generate_jumpbox( 0, 0, array( $link_data['link_catid'] => 1 ), true, true ); ! $link_download = $link_data['link_hits']; ! $approved_checked_yes = $link_data['link_approved'] == 1 ? ' checked' : ''; ! $approved_checked_no = $link_data['link_approved'] == 0 ? ' checked' : '';; ! $link_url = $link_data['link_url']; ! $link_logo_src = $link_data['link_logo_src']; ! $custom_exist = $linkdb_custom_field->display_edit($link_id); $s_hidden_fields = '<input type="hidden" name="action" value="user_upload">'; ! $s_hidden_fields .= '<input type="hidden" name="link_id" value="' . $link_id . '">'; } else *************** *** 303,414 **** } } - } ! function pm_to_admin( $link_url ) ! { ! global $board_config, $db, $lang, $user_ip; ! ! $html_on = 0; ! $bbcode_on = 0; ! $smilies_on = 0; ! $attach_sig = 0; ! ! $sql = "SELECT user_id, user_allow_pm ! FROM " . USERS_TABLE . " ! WHERE user_level = " . ADMIN; ! if ( !$admin_result = $db->sql_query( $sql ) ) { ! mx_message_die( GENERAL_ERROR, "Could not query users table", "", __LINE__, __FILE__, $sql ); ! } ! while ( $to_userdata = $db->sql_fetchrow( $admin_result ) ) ! { ! // ! // Has admin prevented user from sending PM's? ! // ! if ( $to_userdata['user_allow_pm'] ) { ! $bbcode_uid = 0; ! $msg_time = time(); // ! // See if recipient is at their inbox limit // ! $sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time ! FROM " . PRIVMSGS_TABLE . " ! WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " ! OR privmsgs_type = " . PRIVMSGS_READ_MAIL . " ! OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " ) ! AND privmsgs_to_userid = " . $to_userdata['user_id']; ! if ( !( $result = $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_MESSAGE, $lang['No_such_user'] ); ! } ! $sql_priority = ( SQL_LAYER == 'mysql' ) ? 'LOW_PRIORITY' : ''; ! if ( $inbox_info = $db->sql_fetchrow( $result ) ) ! { ! if ( $inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs'] ) { ! $sql = "SELECT privmsgs_id FROM " . PRIVMSGS_TABLE . " ! WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " ! OR privmsgs_type = " . PRIVMSGS_READ_MAIL . " ! OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " ) ! AND privmsgs_date = " . $inbox_info['oldest_post_time'] . " ! AND privmsgs_to_userid = " . $to_userdata['user_id']; ! if ( !$result = $db->sql_query( $sql ) ) { ! mx_message_die( GENERAL_ERROR, 'Could not find oldest privmsgs (inbox)', '', __LINE__, __FILE__, $sql ); ! } ! $old_privmsgs_id = $db->sql_fetchrow( $result ); ! $old_privmsgs_id = $old_privmsgs_id['privmsgs_id']; ! $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . " ! WHERE privmsgs_id = $old_privmsgs_id"; ! if ( !$db->sql_query( $sql ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Could not delete oldest privmsgs (inbox)' . $sql, '', __LINE__, __FILE__, $sql ); ! } ! $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TEXT_TABLE . " ! WHERE privmsgs_text_id = $old_privmsgs_id"; ! if ( !$db->sql_query( $sql ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql ); } } - } ! $privmsg_subject = $lang['Link_pm_notify_subject']; ! $sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig) ! VALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace( "\'", "''", $privmsg_subject ) . "', " . $to_userdata['user_id'] . ", " . $to_userdata['user_id'] . ", $msg_time, '$user_ip', $html_on, $bbcode_on, $smilies_on, $attach_sig)"; ! if ( !( $result = $db->sql_query( $sql_info, BEGIN_TRANSACTION ) ) ) ! { ! mx_message_die( GENERAL_ERROR, "Could not insert/update private message sent info.", "", __LINE__, __FILE__, $sql_info ); ! } ! $privmsg_sent_id = $db->sql_nextid(); ! $privmsg_message = sprintf( $lang['Link_pm_notify_message'], $link_url ); ! $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text) ! VALUES ($privmsg_sent_id, '" . $bbcode_uid . "', '" . str_replace( "\'", "''", $privmsg_message ) . "')"; ! if ( !$db->sql_query( $sql, END_TRANSACTION ) ) ! { ! mx_message_die( GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql_info ); ! } ! // ! // Add to the users new pm counter ! // ! $sql = "UPDATE " . USERS_TABLE . " ! SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . " ! WHERE user_id = " . $to_userdata['user_id']; ! if ( !$status = $db->sql_query( $sql ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql ); } } --- 363,477 ---- } } ! // ! // Old function. Kept for a while...to study...later ;) ! // ! function pm_to_admin( $link_url ) { ! global $board_config, $db, $lang, $user_ip; ! $html_on = 0; ! $bbcode_on = 0; ! $smilies_on = 0; ! $attach_sig = 0; ! ! $sql = "SELECT user_id, user_allow_pm ! FROM " . USERS_TABLE . " ! WHERE user_level = " . ADMIN; ! if ( !$admin_result = $db->sql_query( $sql ) ) { ! mx_message_die( GENERAL_ERROR, "Could not query users table", "", __LINE__, __FILE__, $sql ); ! } + while ( $to_userdata = $db->sql_fetchrow( $admin_result ) ) + { // ! // Has admin prevented user from sending PM's? // ! if ( $to_userdata['user_allow_pm'] ) { ! $bbcode_uid = 0; ! $msg_time = time(); ! // ! // See if recipient is at their inbox limit ! // ! $sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time ! FROM " . PRIVMSGS_TABLE . " ! WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " ! OR privmsgs_type = " . PRIVMSGS_READ_MAIL . " ! OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " ) ! AND privmsgs_to_userid = " . $to_userdata['user_id']; ! if ( !( $result = $db->sql_query( $sql ) ) ) ! { ! mx_message_die( GENERAL_MESSAGE, $lang['No_such_user'] ); ! } ! $sql_priority = ( SQL_LAYER == 'mysql' ) ? 'LOW_PRIORITY' : ''; ! ! if ( $inbox_info = $db->sql_fetchrow( $result ) ) { ! if ( $inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs'] ) { ! $sql = "SELECT privmsgs_id FROM " . PRIVMSGS_TABLE . " ! WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " ! OR privmsgs_type = " . PRIVMSGS_READ_MAIL . " ! OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " ) ! AND privmsgs_date = " . $inbox_info['oldest_post_time'] . " ! AND privmsgs_to_userid = " . $to_userdata['user_id']; ! if ( !$result = $db->sql_query( $sql ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Could not find oldest privmsgs (inbox)', '', __LINE__, __FILE__, $sql ); ! } ! $old_privmsgs_id = $db->sql_fetchrow( $result ); ! $old_privmsgs_id = $old_privmsgs_id['privmsgs_id']; ! $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . " ! WHERE privmsgs_id = $old_privmsgs_id"; ! if ( !$db->sql_query( $sql ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Could not delete oldest privmsgs (inbox)' . $sql, '', __LINE__, __FILE__, $sql ); ! } ! $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TEXT_TABLE . " ! WHERE privmsgs_text_id = $old_privmsgs_id"; ! if ( !$db->sql_query( $sql ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql ); ! } } } ! $privmsg_subject = $lang['Link_pm_notify_subject']; ! $sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig) ! VALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace( "\'", "''", $privmsg_subject ) . "', " . $to_userdata['user_id'] . ", " . $to_userdata['user_id'] . ", $msg_time, '$user_ip', $html_on, $bbcode_on, $smilies_on, $attach_sig)"; ! if ( !( $result = $db->sql_query( $sql_info, BEGIN_TRANSACTION ) ) ) ! { ! mx_message_die( GENERAL_ERROR, "Could not insert/update private message sent info.", "", __LINE__, __FILE__, $sql_info ); ! } ! $privmsg_sent_id = $db->sql_nextid(); ! $privmsg_message = sprintf( $lang['Link_pm_notify_message'], $link_url ); ! $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text) ! VALUES ($privmsg_sent_id, '" . $bbcode_uid . "', '" . str_replace( "\'", "''", $privmsg_message ) . "')"; ! if ( !$db->sql_query( $sql, END_TRANSACTION ) ) ! { ! mx_message_die( GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql_info ); ! } ! // ! // Add to the users new pm counter ! // ! $sql = "UPDATE " . USERS_TABLE . " ! SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . " ! WHERE user_id = " . $to_userdata['user_id']; ! if ( !$status = $db->sql_query( $sql ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql ); ! } } } --- NEW FILE: link_jump.php --- <?php /** * * @package mxBB Portal Module - mx_linkdb * @version $Id: link_jump.php,v 1.1 2006/08/01 21:02:20 jonohlsson Exp $ * @copyright (c) 2002-2006 [CRLin, Jon Ohlsson] mxBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if( !defined('IN_PORTAL') ) { die("Hacking attempt"); } /** * Enter description here... * */ class linkdb_jump extends linkdb_public { /** * Enter description here... * * @param unknown_type $action */ function main( $action ) { global $template, $lang, $board_config, $phpEx, $link_config, $db, $images, $user_ip; global $phpbb_root_path, $userdata, $db, $linkdb_functions; global $mx_root_path, $module_root_path, $is_block, $phpEx, $mx_request_vars; // ======================================================= // Request vars // ======================================================= $link_id = $mx_request_vars->request('link_id', MX_TYPE_INT, ''); if ( empty( $link_id ) ) { mx_message_die( GENERAL_MESSAGE, $lang['Link_not_exist'] ); } // // Main query // switch ( SQL_LAYER ) { case 'oracle': $sql = "SELECT f1.*, f1.link_id, f1.post_username, AVG(r.rate_point) AS rating, COUNT(r.votes_link) AS total_votes, u.user_id, u.username FROM " . LINKS_TABLE . " AS f1, " . LINK_VOTES_TABLE . " AS r, " . USERS_TABLE . " AS u, " . LINK_CATEGORIES_TABLE . " AS cat WHERE f1.link_id = r.votes_link(+) AND f1.user_id = u.user_id(+) AND f1.link_id = $link_id AND f1.link_approved = 1 AND f1.link_catid = cat.cat_id GROUP BY f1.link_id"; break; default: $sql = "SELECT f1.*, f1.link_id, f1.post_username, IF(COUNT(r.rate_point)>0,AVG(r.rate_point),0) AS rating, COUNT(r.votes_link) AS total_votes, u.user_id, u.username FROM " . LINKS_TABLE . " AS f1 LEFT JOIN " . LINK_VOTES_TABLE . " AS r ON f1.link_id = r.votes_link LEFT JOIN " . USERS_TABLE . " AS u ON f1.user_id = u.user_id LEFT JOIN " . LINK_CATEGORIES_TABLE . " AS cat ON f1.link_catid = cat.cat_id WHERE f1.link_id = $link_id AND f1.link_approved = 1 GROUP BY f1.link_id"; break; } if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt Query file info', '', __LINE__, __FILE__, $sql ); } // // Id doesn't match with any link in the database another nice error message // if ( !$link_data = $db->sql_fetchrow( $result ) ) { mx_message_die( GENERAL_MESSAGE, $lang['Link_not_exist'] ); } $db->sql_freeresult( $result ); // =================================================== // Linkdb auth for viewing link // =================================================== if ( ( !$this->auth_user[$link_data['link_catid']]['auth_view'] ) ) { /* if ( !$userdata['session_logged_in'] ) { mx_redirect(append_sid($mx_root_path . "login.$phpEx?redirect=".$this->this_mxurl("action=file&file_id=" . $link_id), true)); } */ $message = sprintf( $lang['Sorry_auth_view'], $this->auth_user[$link_data['link_catid']]['auth_view_link_type'] ); mx_message_die( GENERAL_MESSAGE, $message ); } $link_url = $link_data['link_url']; // // Update counter // $link_hits = intval( $link_data['link_hits'] ) + 1; $sql = 'UPDATE ' . LINKS_TABLE . " SET link_hits = $link_hits, last_user_ip = '$user_ip' WHERE link_id = $link_id"; if ( !( $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt Update Files table', '', __LINE__, __FILE__, $sql ); } // header("Location: $link_url"); echo '<script>location.replace("' . $link_url . '")</script>'; exit(); } } ?> Index: link_link.php =================================================================== RCS file: /cvsroot/mxbb/mx_linkdb/linkdb/modules/link_link.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** link_link.php 4 Jul 2006 18:09:40 -0000 1.7 --- link_link.php 1 Aug 2006 21:02:19 -0000 1.8 *************** *** 27,49 **** function main( $action ) { ! global $_REQUEST, $lang, $db, $user_ip; ! if ( isset( $_REQUEST['link_id'] ) ) ! { ! $link_id = intval( $_REQUEST['link_id'] ); ! } ! else { mx_message_die( GENERAL_MESSAGE, $lang['Link_not_exist'] ); } ! $sql = 'SELECT * ! FROM ' . LINKS_TABLE . " ! WHERE link_id = $link_id ! AND link_approved = 1"; if ( !( $result = $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Couldnt select linkdb', '', __LINE__, __FILE__, $sql ); } --- 27,77 ---- function main( $action ) { ! global $template, $lang, $board_config, $phpEx, $link_config, $db, $images, $user_ip; ! global $phpbb_root_path, $userdata, $db, $linkdb_functions; ! global $mx_root_path, $module_root_path, $is_block, $phpEx, $mx_request_vars; ! // ======================================================= ! // Request vars ! // ======================================================= ! $start = $mx_request_vars->get('start', MX_TYPE_INT, 0); ! $link_id = $mx_request_vars->request('link_id', MX_TYPE_INT, ''); ! $page_num = $mx_request_vars->request('page_num', MX_TYPE_INT, 1) - 1; ! ! if ( empty( $link_id ) ) { mx_message_die( GENERAL_MESSAGE, $lang['Link_not_exist'] ); } ! // ! // Main query ! // ! switch ( SQL_LAYER ) ! { ! case 'oracle': ! $sql = "SELECT f1.*, f1.link_id, f1.post_username, AVG(r.rate_point) AS rating, COUNT(r.votes_link) AS total_votes, u.user_id, u.username ! FROM " . LINKS_TABLE . " AS f1, " . LINK_VOTES_TABLE . " AS r, " . USERS_TABLE . " AS u, " . LINK_CATEGORIES_TABLE . " AS cat ! WHERE f1.link_id = r.votes_link(+) ! AND f1.user_id = u.user_id(+) ! AND f1.link_id = $link_id ! AND f1.link_approved = 1 ! AND f1.link_catid = cat.cat_id ! GROUP BY f1.link_id"; ! break; ! ! default: ! $sql = "SELECT f1.*, f1.link_id, f1.post_username, IF(COUNT(r.rate_point)>0,AVG(r.rate_point),0) AS rating, COUNT(r.votes_link) AS total_votes, u.user_id, u.username ! FROM " . LINKS_TABLE . " AS f1 ! LEFT JOIN " . LINK_VOTES_TABLE . " AS r ON f1.link_id = r.votes_link ! LEFT JOIN " . USERS_TABLE . " AS u ON f1.user_id = u.user_id ! LEFT JOIN " . LINK_CATEGORIES_TABLE . " AS cat ON f1.link_catid = cat.cat_id ! WHERE f1.link_id = $link_id ! AND f1.link_approved = 1 ! GROUP BY f1.link_id"; ! break; ! } if ( !( $result = $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Couldnt Query file info', '', __LINE__, __FILE__, $sql ); } *************** *** 51,55 **** // Id doesn't match with any link in the database another nice error message // ! if ( !$file_data = $db->sql_fetchrow( $result ) ) { mx_message_die( GENERAL_MESSAGE, $lang['Link_not_exist'] ); --- 79,83 ---- // Id doesn't match with any link in the database another nice error message // ! if ( !$link_data = $db->sql_fetchrow( $result ) ) { mx_message_die( GENERAL_MESSAGE, $lang['Link_not_exist'] ); *************** *** 58,81 **** $db->sql_freeresult( $result ); ! $link_url = $file_data['link_url']; ! // if($user_ip != $file_data['last_user_ip']) ! // { // ! // Update counter // ! $link_hits = intval( $file_data['link_hits'] ) + 1; ! $sql = 'UPDATE ' . LINKS_TABLE . " ! SET link_hits = $link_hits, last_user_ip = '$user_ip' ! WHERE link_id = $link_id"; ! if ( !( $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Couldnt Update Files table', '', __LINE__, __FILE__, $sql ); } ! // } ! // header("Location: $link_url"); ! echo '<script>location.replace("' . $link_url . '")</script>'; ! exit(); } } --- 86,219 ---- $db->sql_freeresult( $result ); ! // =================================================== ! // Linkdb auth for viewing link ! // =================================================== ! if ( ( !$this->auth_user[$link_data['link_catid']]['auth_view'] ) ) ! { ! /* ! if ( !$userdata['session_logged_in'] ) ! { ! mx_redirect(append_sid($mx_root_path . "login.$phpEx?redirect=".$this->this_mxurl("action=file&link_id=" . $link_id), true)); ! } ! */ ! $message = sprintf( $lang['Sorry_auth_view'], $this->auth_user[$link_data['link_catid']]['auth_view_link_type'] ); ! mx_message_die( GENERAL_MESSAGE, $message ); ! } ! ! ! $template->assign_vars( array( ! 'U_LINK' => append_sid( $this->this_mxurl() ), ! 'LINKS' => $lang['Links_Title'] ! )); ! ! // =================================================== ! // Prepare link info to display them ! // =================================================== ! $link_time = create_date( $board_config['default_dateformat'], $link_data['link_time'], $board_config['board_timezone'] ); ! $link_update_time = ( $link_data['link_update_time'] ) ? create_date( $board_config['default_dateformat'], $link_data['link_update_time'], $board_config['board_timezone'] ) : $lang['never']; ! $link_author = trim( $link_data['link_creator'] ); ! ! $link_poster = ( $link_data['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid( $phpbb_root_path . 'profile.' . $phpEx . '?mode=viewprofile&' . POST_USERS_URL . '=' . $link_data['user_id'] ) . '">' : ''; ! $link_poster .= ( $link_data['user_id'] != ANONYMOUS ) ? $link_data['username'] : $lang['Guest']; ! $link_poster .= ( $link_data['user_id'] != ANONYMOUS ) ? '</a>' : ''; ! ! $template->assign_vars( array( ! 'L_CLICK_HERE' => $lang['Click_here'], ! 'L_AUTHOR' => $lang['Creator'], ! 'L_SITENAME' => $lang['Sitename'], ! 'L_DESC' => $lang['Desc'], ! 'L_DATE' => $lang['Date'], ! 'L_HITS' => $lang['Hits'], ! 'L_EDIT' => $lang['Elinktitle'], ! 'L_DELETE' => $lang['Dlinktitle'], ! 'L_JUMP' => $lang['Link_jump'], ! 'L_SUBMITED_BY' => $lang['Submiter'], ! ! 'SHOW_AUTHOR' => ( !empty( $file_author ) ) ? true : false, ! 'LINK_NAME' => $link_data['link_name'], ! 'LINK_LONGDESC' => nl2br( $link_data['link_longdesc'] ), ! 'LINK_SUBMITED_BY' => $link_poster, ! ! 'DELETE_IMG' => $images['linkdb_icon_delpost'], ! 'EDIT_IMG' => $images['linkdb_icon_edit'], ! ! 'TIME' => $link_time, ! 'LINK_HITS' => intval( $link_data['link_hits'] ), ! 'PIN_IMAGE' => $this->display_banner( $link_data ), ! ! 'U_JUMP' => append_sid( $this->this_mxurl( 'action=jump&link_id=' . $link_id ) ), ! 'U_DELETE' => append_sid( $this->this_mxurl( 'action=user_upload&do=delete&link_id=' . $link_id ) ), ! 'U_EDIT' => append_sid( $this->this_mxurl( 'action=user_upload&link_id=' . $link_id ) ), ! )); ! ! if ($this->auth_user[$link_data['link_catid']]['auth_mod'] || ($this->auth_user[$link_data['link_catid']]['auth_edit'] && $link_data['user_id'] == $userdata['user_id'])) ! { ! $template->assign_block_vars( 'AUTH_EDIT', array()); ! } ! ! if ($this->auth_user[$link_data['link_catid']]['auth_mod'] || ($this->auth_user[$link_data['link_catid']]['auth_delete'] && $link_data['user_id'] == $userdata['user_id'])) ! { ! $template->assign_block_vars( 'AUTH_DELETE', array()); ! } // ! // Instantiate custom fields // ! $linkdb_custom_field = new mx_custom_field(LINK_CUSTOM_TABLE, LINK_CUSTOM_DATA_TABLE); ! $linkdb_custom_field->init(); ! $linkdb_custom_field->display_data( $link_id ); ! // ! // Ratings ! // ! if ( $this->ratings[$link_data['link_catid']]['activated'] ) { ! $link_rating = ( $link_data['rating'] != 0 ) ? round( $link_data['rating'], 2 ) . '/10' : $lang['Not_rated']; ! ! if ( $this->auth_user[$link_data['link_catid']]['auth_rate'] ) ! { ! $rate_img = $images['link_rate']; ! } ! ! $template->assign_block_vars( 'use_ratings', array( ! 'L_RATING' => $lang['LinkRating'], ! 'L_RATE' => $lang['Rate'], ! 'L_VOTES' => $lang['Votes'], ! 'FILE_VOTES' => $link_data['total_votes'], ! 'RATING' => $link_rating, ! ! // ! // Allowed to rate ! // ! 'RATE_IMG' => $rate_img, ! 'U_RATE' => append_sid( $this->this_mxurl( 'action=rate&link_id=' . $link_id ) ), ! )); } ! ! // ! // Comments ! // ! if ( $this->comments[$link_data['link_catid']]['activated'] && $this->auth_user[$link_data['link_catid']]['auth_view_comment']) ! { ! $comments_type = $this->comments[$link_data['link_catid']]['internal_comments'] ? 'internal' : 'phpbb'; ! ! // ! // Instatiate comments ! // ! include_once( $module_root_path . 'linkdb/includes/functions_comment.' . $phpEx ); ! $linkdb_comments = new linkdb_comments(); ! $linkdb_comments->init( $link_data, $comments_type ); ! $linkdb_comments->display_comments(); ! } ! ! // ! // assign var for naviagation ! // ! $this->generate_navigation( $link_data['link_catid'] ); ! ! // ! // Output all ! // ! $this->display( $lang['Links'], 'link_link_body.tpl' ); } } Index: link_search.php =================================================================== RCS file: /cvsroot/mxbb/mx_linkdb/linkdb/modules/link_search.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** link_search.php 5 Jul 2006 22:49:20 -0000 1.11 --- link_search.php 1 Aug 2006 21:02:20 -0000 1.12 *************** *** 102,106 **** } ! $limit_sql = ( $start == 0 ) ? $linkdb_config['settings_link_page'] : $start . ',' . $linkdb_config['settings_link_page']; // encoding match for workaround --- 102,106 ---- } ! $limit_sql = ( $start == 0 ) ? $linkdb_config['pagination'] : $start . ',' . $linkdb_config['pagination']; // encoding match for workaround *************** *** 506,511 **** $template->assign_vars( array( ! 'PAGINATION' => generate_pagination( $base_url, $total_match_count, $linkdb_config['settings_link_page'], $start ), ! 'PAGE_NUMBER' => sprintf( $lang['Page_of'], ( floor( $start / $linkdb_config['settings_link_page'] ) + 1 ), ceil( $total_match_count / $linkdb_config['settings_link_page'] ) ), 'LINKS' => $lang['Links_Title'], --- 506,511 ---- $template->assign_vars( array( ! 'PAGINATION' => generate_pagination( $base_url, $total_match_count, $linkdb_config['pagination'], $start ), ! 'PAGE_NUMBER' => sprintf( $lang['Page_of'], ( floor( $start / $linkdb_config['pagination'] ) + 1 ), ceil( $total_match_count / $linkdb_config['pagination'] ) ), 'LINKS' => $lang['Links_Title'], --- NEW FILE: link_post_comment.php --- <?php /** * * @package mxBB Portal Module - mx_linkdb * @version $Id: link_post_comment.php,v 1.1 2006/08/01 21:02:20 jonohlsson Exp $ * @copyright (c) 2002-2006 [wGEric, Jon Ohlsson] mxBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } /** * Enter description here... * */ class linkdb_post_comment extends linkdb_public { /** * Enter description here... * * @param unknown_type $action */ function main( $action ) { global $template, $linkdb_functions, $lang, $board_config, $phpEx, $link_config, $db, $images, $userdata; global $html_entities_match, $html_entities_replace, $unhtml_specialchars_match, $unhtml_specialchars_replace; global $mx_root_path, $module_root_path, $phpbb_root_path, $is_block, $phpEx, $mx_request_vars; // // Request vars // $cid = $mx_request_vars->request('cid', MX_TYPE_INT, 0); if ( $mx_request_vars->is_request('item_id') && $mx_request_vars->is_request('cat_id') ) { $item_id = $mx_request_vars->request('item_id', MX_TYPE_INT, 0); $cat_id = $mx_request_vars->request('cat_id', MX_TYPE_INT, 0); } else { mx_message_die( GENERAL_MESSAGE, $lang['Link_not_exist'] ); } $delete = $mx_request_vars->request('delete', MX_TYPE_NO_TAGS, ''); $submit = $mx_request_vars->is_request('submit'); $preview = $mx_request_vars->is_request('preview'); $sql = "SELECT * FROM " . LINKS_TABLE . " WHERE link_id = '" . $item_id . "'"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt select download', '', __LINE__, __FILE__, $sql ); } if ( !$link_data = $db->sql_fetchrow( $result ) ) { mx_message_die( GENERAL_MESSAGE, $lang['Link_not_exsist'] ); } $db->sql_freeresult( $result ); if ( ( !$this->auth_user[$link_data['link_catid']]['auth_post_comment'] ) ) { if ( !$userdata['session_logged_in'] ) { // mx_redirect(append_sid($mx_root_path . "login.$phpEx?redirect=".$this->this_mxurl("action=post_comment&item_id=" . $item_id), true)); } $message = $lang['Sorry_auth_comment']; mx_message_die( GENERAL_MESSAGE, $message ); } if ( $mx_request_vars->is_get('cid') ) { if ( $this->comments[$link_data['link_catid']]['internal_comments'] ) { // // Query internal comment to edit // $sql = 'SELECT c.*, u.* FROM ' . LINK_COMMENTS_TABLE . ' AS c LEFT JOIN ' . USERS_TABLE . " AS u ON c.poster_id = u.user_id WHERE c.link_id = '" . $item_id . "' AND c.comments_id = '" . $mx_request_vars->request('cid', MX_TYPE_INT, '') . "'"; $comment_arg_title = 'comments_title'; $comment_arg_message = 'comments_text'; $comment_arg_bbcode_uid = 'comment_bbcode_uid'; } else { // // Query internal comment to edit // Note: cid = post_id // $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt WHERE pt.post_id = p.post_id AND u.user_id = p.poster_id AND p.post_id = '" . $mx_request_vars->request('cid', MX_TYPE_INT, '') . "'"; $comment_arg_title = 'po... [truncated message content] |