|
From: Jon O. <jon...@us...> - 2006-07-01 21:32:22
|
Update of /cvsroot/mxbb/mx_linkdb/linkdb/includes In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv10721/modules/mx_linkdb/linkdb/includes Modified Files: functions.php functions_linkdb.php linkdb_constants.php Added Files: functions_auth.php functions_cache.php functions_comment.php functions_field.php functions_mx.php Removed Files: functions_linkdb_field.php linkdb_common.php Log Message: Ok. Moving files. Renaming files. Adding code... Index: functions.php =================================================================== RCS file: /cvsroot/mxbb/mx_linkdb/linkdb/includes/functions.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** functions.php 17 Jun 2006 20:48:33 -0000 1.7 --- functions.php 1 Jul 2006 21:32:18 -0000 1.8 *************** *** 129,131 **** --- 129,1642 ---- } } + + /** + * linkdb_user_info + * + * This class is used to determin Browser and operating system info of the user + * + * @access public [...1486 lines suppressed...] + if ( $force_standalone_mode || !$is_block ) + { + $mxurl = $mx_root_path . 'modules/mx_linkdb/linkdb.' . $phpEx . ( $args == '' ? '' : '?' . $args ); + } + else + { + $mxurl = $mx_root_path . 'index.' . $phpEx; + if ( is_numeric( $page_id ) ) + { + $mxurl .= '?page=' . $page_id . ( $args == '' ? '' : ( $non_html_amp ? '&' : '&' ) . $args ); + } + else + { + $mxurl .= ( $args == '' ? '' : '?' . $args ); + } + } + return $mxurl; + } ?> \ No newline at end of file --- linkdb_common.php DELETED --- --- NEW FILE: functions_cache.php --- <?php /** * * @package mxBBmodule_mx_linkdb * @version $Id: functions_cache.php,v 1.1 2006/07/01 21:32:19 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_cache { var $vars = ''; var $vars_ts = array(); var $modified = false; /** * Enter description here... * * @return linkdb_cache */ function linkdb_cache() { global $phpbb_root_path; global $mx_root_path, $module_root_path, $is_block, $phpEx; $this->cache_dir = $module_root_path . 'linkdb/cache/'; } /** * Enter description here... * */ function load() { global $phpEx; @include( $this->cache_dir . 'data_global.' . $phpEx ); } /** * Enter description here... * */ function unload() { $this->save(); unset( $this->vars ); unset( $this->vars_ts ); } /** * Enter description here... * */ function save() { if ( !$this->modified ) { return; } global $phpEx; $file = '<?php $this->vars=' . $this->format_array( $this->vars ) . ";\n\$this->vars_ts=" . $this->format_array( $this->vars_ts ) . ' ?>'; if ( $fp = @fopen( $this->cache_dir . 'data_global.' . $phpEx, 'wb' ) ) { @flock( $fp, LOCK_EX ); fwrite( $fp, $file ); @flock( $fp, LOCK_UN ); fclose( $fp ); } } /** * Enter description here... * * @param unknown_type $expire_time */ function tidy( $expire_time = 0 ) { global $phpEx; $dir = opendir( $this->cache_dir ); while ( $entry = readdir( $dir ) ) { if ( $entry{0} == '.' || substr( $entry, 0, 4 ) != 'sql_' ) { continue; } if ( time() - $expire_time >= filemtime( $this->cache_dir . $entry ) ) { unlink( $this->cache_dir . $entry ); } } if ( file_exists( $this->cache_dir . 'data_global.' . $phpEx ) ) { foreach ( $this->vars_ts as $varname => $timestamp ) { if ( time() - $expire_time >= $timestamp ) { $this->destroy( $varname ); } } } else { $this->vars = $this->vars_ts = array(); $this->modified = true; } } /** * Enter description here... * * @param unknown_type $varname * @param unknown_type $expire_time * @return unknown */ function get( $varname, $expire_time = 0 ) { return ( $this->exists( $varname, $expire_time ) ) ? $this->vars[$varname] : null; } /** * Enter description here... * * @param unknown_type $varname * @param unknown_type $var */ function put( $varname, $var ) { $this->vars[$varname] = $var; $this->vars_ts[$varname] = time(); $this->modified = true; } /** * Enter description here... * * @param unknown_type $varname */ function destroy( $varname ) { if ( isset( $this->vars[$varname] ) ) { $this->modified = true; unset( $this->vars[$varname] ); unset( $this->vars_ts[$varname] ); } } /** * Enter description here... * * @param unknown_type $varname * @param unknown_type $expire_time * @return unknown */ function exists( $varname, $expire_time = 0 ) { if ( !is_array( $this->vars ) ) { $this->load(); } if ( $expire_time > 0 && isset( $this->vars_ts[$varname] ) ) { if ( $this->vars_ts[$varname] <= time() - $expire_time ) { $this->destroy( $varname ); return false; } } return isset( $this->vars[$varname] ); } /** * Enter description here... * * @param unknown_type $array * @return unknown */ function format_array( $array ) { $lines = array(); foreach ( $array as $k => $v ) { if ( is_array( $v ) ) { $lines[] = "'$k'=>" . $this->format_array( $v ); }elseif ( is_int( $v ) ) { $lines[] = "'$k'=>$v"; }elseif ( is_bool( $v ) ) { $lines[] = "'$k'=>" . ( ( $v ) ? 'TRUE' : 'FALSE' ); } else { $lines[] = "'$k'=>'" . str_replace( "'", "\'", str_replace( '\\', '\\\\', $v ) ) . "'"; } } return 'array(' . implode( ',', $lines ) . ')'; } } ?> --- NEW FILE: functions_mx.php --- <?php /** * * @package mxBBmodule_mx_kb * @version $Id: functions_mx.php,v 1.1 2006/07/01 21:32:19 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"); } if ( !function_exists( mx_smilies_pass ) ) { /** * Enter description here... * * @param unknown_type $message * @return unknown */ function mx_smilies_pass($message) { global $board_config; $smilies_path = $board_config['smilies_path']; $board_config['smilies_path'] = PHPBB_URL . $board_config['smilies_path']; $message = smilies_pass($message); $board_config['smilies_path'] = $smilies_path; return $message; } } if ( !function_exists( mx_generate_smilies ) ) { /** * Enter description here... * * @param unknown_type $mode * @param unknown_type $page_id */ function mx_generate_smilies($mode, $page_id) { global $board_config, $template, $phpEx; $smilies_path = $board_config['smilies_path']; $board_config['smilies_path'] = PHPBB_URL . $board_config['smilies_path']; generate_smilies($mode, $page_id); $board_config['smilies_path'] = $smilies_path; $template->assign_vars(array( 'U_MORE_SMILIES' => append_sid(PHPBB_URL . "posting.$phpEx?mode=smilies")) ); } } if ( !function_exists( mx_message_die ) ) { /** * Enter description here... * * @param unknown_type $msg_code * @param unknown_type $msg_text * @param unknown_type $msg_title * @param unknown_type $err_line * @param unknown_type $err_file * @param unknown_type $sql */ function mx_message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '') { global $db, $template, $board_config, $theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $gen_simple_header, $images; global $userdata, $user_ip, $session_length; global $starttime; message_die($msg_code, $msg_text, $msg_title, $err_line, $err_file, $sql); } } if ( !function_exists( mx_is_group_member ) ) { /** * Validates if user belongs to group included in group_ids list * Also, adds all usergroups to userdata array * * @param unknown_type $group_ids * @param unknown_type $group_mod_mode * @return unknown */ function mx_is_group_member( $group_ids = '', $group_mod_mode = false ) { global $userdata, $db; if ( $group_ids == '' ) { return false; } $group_ids_array = explode(",", $group_ids); // Try to reuse usergroups result. if ( $group_mod_mode ) { $userdata_key = 'mx_usergroups_mod' . $userdata['user_id']; if ( empty( $userdata[$userdata_key] ) ) { // Check if user is group moderator.. $sql = "SELECT gr.group_id FROM " . GROUPS_TABLE . " gr, " . USER_GROUP_TABLE . " ugr WHERE gr.group_id = ugr.group_id AND gr.group_moderator = '" . $userdata['user_id'] . "' AND ugr.user_pending = '0' "; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not query group rights information", '', '', '', '' ); } $group_row = $db->sql_fetchrowset( $result ); $userdata[$userdata_key_mod] = $group_row; } } else { $userdata_key = 'mx_usergroups' . $userdata['user_id']; if ( empty( $userdata[$userdata_key] ) ) { // Check if user is member of the proper group.. $sql = "SELECT group_id FROM " . USER_GROUP_TABLE . " WHERE user_id='" . $userdata['user_id'] . "' AND user_pending = 0"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Could not query group rights information", '', '', '', '' ); } $group_row = $db->sql_fetchrowset( $result ); $userdata[$userdata_key] = $group_row; } } for ( $i = 0; $i < count( $userdata[$userdata_key] ); $i++ ) { if ( in_array( $userdata[$userdata_key][$i]['group_id'], $group_ids_array ) ) { $is_member = true; return $is_member; } } return false; } } if ( !function_exists(mx_do_install_upgrade) ) { /** * Generating output. * * @param unknown_type $sql * @param unknown_type $main_install * @return unknown */ function mx_do_install_upgrade( $sql = '', $main_install = false ) { global $table_prefix, $mx_table_prefix, $userdata, $phpEx, $template, $lang, $db, $board_config, $HTTP_POST_VARS; $inst_error = false; $n = 0; $message = "<b>This is the result list of the SQL queries needed for the install/upgrade</b><br /><br />"; while ( $sql[$n] ) { if ( !$result = $db->sql_query( $sql[$n] ) ) { $message .= '<b><font color=#FF0000>[Error or Already added]</font></b> line: ' . ( $n + 1 ) . ' , ' . $sql[$n] . '<br />'; $inst_error = true; } else { $message .= '<b><font color=#0000fF>[Added/Updated]</font></b> line: ' . ( $n + 1 ) . ' , ' . $sql[$n] . '<br />'; } $n++; } $message .= '<br /> If you get some Errors, Already Added or Updated messages, relax, this is normal when updating modules'; if ( $main_install ) { if ( !$inst_error ) { $message .= '-> no db errors :-)<br /><br /><b>Portal installed successfully! </b><hr><br /><br />'; $message .= '1) Now, delete the /install and /contrib folders!!!<br /><br />'; $message .= '2) If you haven\'t already done a db backup, now is the time ;)<br /><br />'; $message .= '3) Then (after step 1), you HAVE to configure MX core and its modules from within the adminCP, simply \'upgrade\' MX portal Core and all modules in use!!!<br /><br />'; $message .= 'Click <a href=../admin/admin_mx_module.php>Here</a> to administer/upgrade the portal/modules. You will be promted for an admin username and pass. The upgrade process provide informative output...'; } else { $message .= '<br /><br /><b>Portal installed successfully (with some warnings)! </b><hr><br /><br />'; $message .= '1) Now, delete the /install and /contrib folders!!!<br /><br />'; $message .= '2) If you haven\'t already done a db backup, now is the time ;)<br /><br />'; $message .= '3) Now (after step 1), you HAVE to configure MX core and its modules from within the adminCP, simply \'upgrade\' MX portal Core and all modules in use!!!<br /><br />'; $message .= 'Click <a href=../admin/admin_mx_module.php>Here</a> to administer/upgrade the portal/modules. You will be promted for an admin username and pass. The upgrade process provide informative output...'; } } return $message; } } ?> --- NEW FILE: functions_comment.php --- <?php /** * * @package mxBBmodule_mx_linkdb * @version $Id: functions_comment.php,v 1.1 2006/07/01 21:32:19 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... * */ [...1316 lines suppressed...] $return_data = $this->delete_phpbb_post($this->forum_id, $this->topic_id, $cid ); $this->validate_topic_id(); break; case 'insert': $return_data = $this->insert_phpbb_post( $title, $comments_text, $this->forum_id, $user_id, $username, $user_attach_sig, $this->topic_id, '', $title_first, $comments_text_first, $comment_bbcode_uid ); break; case 'update': $return_data = $this->insert_phpbb_post( $title, $comments_text, $this->forum_id, $user_id, $username, $user_attach_sig, $this->topic_id, $cid, $title_first, $comments_text_first, $comment_bbcode_uid ); break; default: mx_message_die(GENERAL_ERROR, 'bad post mode'); } return $return_data; } } ?> --- NEW FILE: functions_auth.php --- <?php /** * * @package mxBBmodule_mx_kb * @version $Id: functions_auth.php,v 1.1 2006/07/01 21:32:19 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_auth { var $auth_user = array(); /** * Enter description here... * * @param unknown_type $type * @param unknown_type $cat_id * @param unknown_type $userdata * @param unknown_type $f_access * @param unknown_type $f_access_group * @return unknown */ function auth( $type, $cat_id, $userdata, $f_access = '', $f_access_group = '' ) { global $db, $lang; switch ( $type ) { case AUTH_ALL: $a_sql = 'a.auth_view, a.auth_post, a.auth_rate, a.auth_comment, a.auth_edit, a.auth_delete, a.auth_approval, a.auth_approval_edit'; $a_sql_groups = 'a.auth_view_groups, a.auth_post_groups, a.auth_rate_groups, a.auth_comment_groups, a.auth_edit_groups, a.auth_delete_groups, a.auth_approval_groups, a.auth_approval_edit_groups'; $auth_fields = array( 'auth_view', 'auth_post', 'auth_rate', 'auth_comment', 'auth_edit', 'auth_delete', 'auth_approval', 'auth_approval_edit' ); $auth_fields_groups = array( 'auth_view_groups', 'auth_post_groups', 'auth_rate_groups', 'auth_comment_groups', 'auth_edit_groups', 'auth_delete_groups', 'auth_approval_groups', 'auth_approval_edit_groups' ); break; case AUTH_VIEW: $a_sql = 'a.auth_view'; $a_sql_groups = 'a.auth_view_groups'; $auth_fields = array( 'auth_view' ); $auth_fields_groups = array( 'auth_view_groups' ); break; case AUTH_POST: $a_sql = 'a.auth_post'; $a_sql_groups = 'a.auth_post_groups'; $auth_fields = array( 'auth_post' ); $auth_fields_groups = array( 'auth_post_groups' ); break; case AUTH_RATE: $a_sql = 'a.auth_rate'; $a_sql_groups = 'a.auth_rate_groups'; $auth_fields = array( 'auth_rate' ); $auth_fields_groups = array( 'auth_rate_groups' ); break; case AUTH_COMMENT: $a_sql = 'a.auth_comment'; $a_sql_groups = 'a.auth_comment_groups'; $auth_fields = array( 'auth_comment' ); $auth_fields_groups = array( 'auth_comment_groups' ); break; case AUTH_EDIT: $a_sql = 'a.auth_edit'; $a_sql_groups = 'a.auth_edit_groups'; $auth_fields = array( 'auth_edit' ); $auth_fields_groups = array( 'auth_edit_groups' ); break; case AUTH_DELETE: $a_sql = 'a.auth_delete'; $a_sql_groups = 'a.auth_delete_groups'; $auth_fields = array( 'auth_delete' ); $auth_fields_groups = array( 'auth_delete_groups' ); break; case AUTH_APPROVAL: $a_sql = 'a.auth_approval'; $a_sql_groups = 'a.auth_approval_groups'; $auth_fields = array( 'auth_approval' ); $auth_fields_groups = array( 'auth_approval_groups' ); break; case AUTH_APPROVAL_EDIT: $a_sql = 'a.auth_approval_edit'; $a_sql_groups = 'a.auth_approval_edit_groups'; $auth_fields = array( 'auth_approval_edit' ); $auth_fields_groups = array( 'auth_approval_edit_groups' ); break; default: break; } $is_admin = ( $userdata['user_level'] == ADMIN && $userdata['session_logged_in'] ) ? true : 0; // // If f_access has not been passed, or auth is needed to return an array of forums // then we need to pull the auth information on the given forum (or all forums) // if ( empty($f_access) ) { $forum_match_sql = ( $cat_id != AUTH_LIST_ALL ) ? "WHERE a.category_id = $cat_id" : ''; $sql = "SELECT a.category_id, $a_sql FROM " . KB_CATEGORIES_TABLE . " a $forum_match_sql"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Failed obtaining forum access control lists', '', __LINE__, __FILE__, $sql); } $sql_fetchrow = ( $cat_id != AUTH_LIST_ALL ) ? 'sql_fetchrow' : 'sql_fetchrowset'; if ( !($f_access = $db->$sql_fetchrow($result)) ) { $db->sql_freeresult($result); return array(); } $db->sql_freeresult($result); } // // If f_access_group has not been passed, or auth is needed to return an array of forums // then we need to pull the auth information on the given forum (or all forums) // if ( empty($f_access_group) ) { $forum_match_sql = ( $cat_id != AUTH_LIST_ALL ) ? "WHERE a.category_id = $cat_id" : ''; $sql = "SELECT a.category_id, $a_sql_groups, a.auth_moderator_groups FROM " . KB_CATEGORIES_TABLE . " a $forum_match_sql"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Failed obtaining forum access control lists', '', __LINE__, __FILE__, $sql); } $sql_fetchrow = ( $cat_id != AUTH_LIST_ALL ) ? 'sql_fetchrow' : 'sql_fetchrowset'; if ( !($f_access_group = $db->$sql_fetchrow($result)) ) { $db->sql_freeresult($result); return array(); } $db->sql_freeresult($result); } $auth_user = array(); for( $i = 0; $i < count( $auth_fields ); $i++ ) { $key = $auth_fields[$i]; $key_groups = $auth_fields_groups[$i]; // If the user is logged on and the module type is either ALL or REG then the user has access // If the type if ACL, MOD or ADMIN then we need to see if the user has specific permissions // to do whatever it is they want to do ... to do this we pull relevant information for the // user (and any groups they belong to) // Now we compare the users access level against the modules. We assume here that a moderator // and admin automatically have access to an ACL module, similarly we assume admins meet an // auth requirement of MOD if ( $cat_id != AUTH_LIST_ALL ) { $value = $f_access[$key]; $value_groups = $f_access_group[$key_groups]; switch ( $value ) { case AUTH_ALL: $this->auth_user[$key] = true; $this->auth_user[$key . '_type'] = $lang['Auth_Anonymous_users']; break; case AUTH_REG: $this->auth_user[$key] = ( $userdata['session_logged_in'] ) ? true : 0; $this->auth_user[$key . '_type'] = $lang['Auth_Registered_Users']; break; case AUTH_ANONYMOUS: $this->auth_user[$key] = ( ! $userdata['session_logged_in'] ) ? true : 0; $this->auth_user[$key . '_type'] = $lang['Auth_Anonymous_users']; break; case AUTH_ACL: // PRIVATE $this->auth_user[$key] = ( $userdata['session_logged_in'] ) ? mx_is_group_member( $value_groups ) || $is_admin : 0; $this->auth_user[$key . '_type'] = $lang['Auth_Users_granted_access']; break; case AUTH_MOD: $this->auth_user[$key] = ( $userdata['session_logged_in'] ) ? mx_is_group_member( $f_access_group['auth_moderator_groups'] ) || $is_admin : 0; $this->auth_user[$key . '_type'] = $lang['Auth_Moderators']; break; case AUTH_ADMIN: $this->auth_user[$key] = $is_admin; $this->auth_user[$key . '_type'] = $lang['Auth_Administrators']; break; default: $this->auth_user[$key] = 0; break; } } else { for($k = 0; $k < count($f_access); $k++) { $value = $f_access[$k][$key]; $value_groups = $f_access_group[$k][$key_groups]; $f_cat_id = $f_access[$k]['category_id']; switch ( $value ) { case AUTH_ALL: $this->auth_user[$f_cat_id][$key] = true; $this->auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Anonymous_users']; break; case AUTH_REG: $this->auth_user[$f_cat_id][$key] = ( $userdata['session_logged_in'] ) ? true : 0; $this->auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Registered_Users']; break; case AUTH_ANONYMOUS: $this->auth_user[$f_cat_id][$key] = ( ! $userdata['session_logged_in'] ) ? true : 0; $this->auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Anonymous_users']; break; case AUTH_ACL: // PRIVATE $this->auth_user[$f_cat_id][$key] = ( $userdata['session_logged_in'] ) ? mx_is_group_member( $value_groups ) || $is_admin : 0; $this->auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Users_granted_access']; break; case AUTH_MOD: $this->auth_user[$f_cat_id][$key] = ( $userdata['session_logged_in'] ) ? mx_is_group_member( $f_access_group[$k]['auth_moderator_groups'] ) || $is_admin : 0; $this->auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Moderators']; break; case AUTH_ADMIN: $this->auth_user[$f_cat_id][$key] = $is_admin; $this->auth_user[$f_cat_id][$key . '_type'] = $lang['Auth_Administrators']; break; default: $this->auth_user[$f_cat_id][$key] = 0; break; } } } } // // Is user a moderator? // if ( $cat_id != AUTH_LIST_ALL ) { $this->auth_user['auth_mod'] = ( $userdata['session_logged_in'] ) ? mx_is_group_member( $f_access_group['auth_moderator_groups'] ) || $is_admin : 0; } else { for($k = 0; $k < count($f_access); $k++) { $f_cat_id = $f_access[$k]['category_id']; $this->auth_user[$f_cat_id]['auth_mod'] = ( $userdata['session_logged_in'] ) ? mx_is_group_member( $f_access_group[$k]['auth_moderator_groups'] ) || $is_admin : 0; } } return $this->auth_user; } /** * Enter description here... * * @param unknown_type $cat_id * @return unknown */ function ns_auth_cat( $cat_id ) { global $kb_type_select_data, $kb_config; if ( !MXBB_MODULE || MXBB_27x ) { return true; } $tmp_kb = $kb_type_select_data[$cat_id] == 1; return $tmp_kb; } } ?> Index: linkdb_constants.php =================================================================== RCS file: /cvsroot/mxbb/mx_linkdb/linkdb/includes/linkdb_constants.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** linkdb_constants.php 30 Jun 2006 19:54:14 -0000 1.8 --- linkdb_constants.php 1 Jul 2006 21:32:19 -0000 1.9 *************** *** 14,28 **** } ! define( 'LINKDB_ROOT_CAT', 0 ); ! // ! // Field Types ! // ! define( 'INPUT', 0 ); ! define( 'TEXTAREA', 1 ); ! define( 'RADIO', 2 ); ! define( 'SELECT', 3 ); ! define( 'SELECT_MULTIPLE', 4 ); ! define( 'CHECKBOX', 5 ); // --- 14,34 ---- } ! if ( !MXBB_MODULE ) ! { ! $server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://'; ! $server_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($board_config['server_name'])); ! $server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) : ''; ! $script_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($board_config['script_path'])); ! $script_name = ($script_name == '') ? $script_name : '/' . $script_name; ! define( 'PORTAL_URL', $server_protocol . $server_name . $server_port . $script_name . '/' ); ! define( 'PHPBB_URL', PORTAL_URL ); ! ! $kb_config['news_operate_mode'] = false; ! $mx_table_prefix = $table_prefix; ! $is_block = false; ! } ! ! define( 'LINKDB_ROOT_CAT', 0 ); // *************** *** 31,34 **** --- 37,41 ---- define( 'LINKS_TABLE', $mx_table_prefix . 'linkdb' ); define( 'LINK_CATEGORIES_TABLE', $mx_table_prefix . 'linkdb_categories' ); + define( 'LINK_COMMENTS_TABLE', $mx_table_prefix . 'linkdb_comments' ); define( 'LINK_CONFIG_TABLE', $mx_table_prefix . 'linkdb_config' ); define( 'LINK_VOTES_TABLE', $mx_table_prefix . 'linkdb_votes' ); *************** *** 36,52 **** define( 'LINK_CUSTOM_DATA_TABLE', $mx_table_prefix . 'linkdb_customdata' ); ! if (is_object($mx_page)) ! { ! // ------------------------------------------------------------------------- ! // Extend User Style with module lang and images ! // Usage: $mx_user->extend(LANG, IMAGES) ! // Switches: ! // - LANG: MX_LANG_MAIN (default), MX_LANG_ADMIN, MX_LANG_ALL, MX_LANG_NONE ! // - IMAGES: MX_IMAGES (default), MX_IMAGES_NONE ! // ------------------------------------------------------------------------- ! $mx_user->extend(); ! $mx_page->add_copyright( 'mxBB LinkDb Module' ); } ?> \ No newline at end of file --- 43,77 ---- define( 'LINK_CUSTOM_DATA_TABLE', $mx_table_prefix . 'linkdb_customdata' ); ! // ! // Field Types ! // ! define( 'INPUT', 0 ); ! define( 'TEXTAREA', 1 ); ! define( 'RADIO', 2 ); ! define( 'SELECT', 3 ); ! define( 'SELECT_MULTIPLE', 4 ); ! define( 'CHECKBOX', 5 ); ! if ( !MXBB_MODULE || MXBB_27x ) ! { ! $linkdb_module_version = "linkDB Manager v. 2.8.0"; ! $linkdb_module_author = "Jon"; ! $linkdb_module_orig_author = "CRLin"; } + else + { + if (is_object($mx_page)) + { + // ------------------------------------------------------------------------- + // Extend User Style with module lang and images + // Usage: $mx_user->extend(LANG, IMAGES) + // Switches: + // - LANG: MX_LANG_MAIN (default), MX_LANG_ADMIN, MX_LANG_ALL, MX_LANG_NONE + // - IMAGES: MX_IMAGES (default), MX_IMAGES_NONE + // ------------------------------------------------------------------------- + $mx_user->extend(); + $mx_page->add_copyright( 'mxBB linkDB Module' ); + } + } ?> \ No newline at end of file Index: functions_linkdb.php =================================================================== RCS file: /cvsroot/mxbb/mx_linkdb/linkdb/includes/functions_linkdb.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** functions_linkdb.php 30 Jun 2006 19:54:14 -0000 1.8 --- functions_linkdb.php 1 Jul 2006 21:32:19 -0000 1.9 *************** *** 22,28 **** var $module_name = ''; ! // load module ! // $module name : send module name to load it ! function adminmodule( $module_name ) { --- 22,30 ---- var $module_name = ''; ! /** ! * Enter description here... ! * ! * @param unknown_type $module_name ! */ function adminmodule( $module_name ) { *************** *** 43,46 **** --- 45,53 ---- } + /** + * Enter description here... + * + * @param unknown_type $module_name + */ function module( $module_name ) { *************** *** 83,103 **** } ! // ! // linkdb class ! // ! class linkdb { var $cat_rowset = array(); var $subcat_rowset = array(); var $modified = false; var $auth = array(); var $auth_global = array(); ! var $total_cat = 0; ! // var $depth_info = array(); ! var $error = array(); ! function init() { --- 90,127 ---- } ! /** ! * linkdb class ! * ! */ ! class linkdb extends linkdb_auth { var $cat_rowset = array(); var $subcat_rowset = array(); + var $total_cat = 0; + + var $comments = array(); + var $ratings = array(); + var $information = array(); + var $notification = array(); var $modified = false; + var $error = array(); + var $page_title = ''; + var $jumpbox = ''; + var $auth_can_list = ''; + var $navigation = ''; + + var $debug = true; + var $debug_msg = array(); + + // Specific for linkdb var $auth = array(); var $auth_global = array(); ! /** ! * Prepare data ! * ! */ function init() { *************** *** 106,109 **** --- 130,137 ---- unset( $this->cat_rowset ); unset( $this->subcat_rowset ); + unset( $this->comments ); + unset( $this->ratings ); + unset( $this->information ); + unset( $this->notification ); $sql = 'SELECT * *************** *** 111,115 **** ORDER BY cat_order ASC'; ! if ( !( $result = $db->sql_query( $sql, 300 ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt Query categories info', '', __LINE__, __FILE__, $sql ); --- 139,143 ---- ORDER BY cat_order ASC'; ! if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt Query categories info', '', __LINE__, __FILE__, $sql ); *************** *** 119,128 **** $db->sql_freeresult( $result ); for( $i = 0; $i < count( $cat_rowset ); $i++ ) { ! $this->cat_rowset[$cat_rowset[$i]['cat_id']] = $cat_rowset[$i]; ! $this->subcat_rowset[$cat_rowset[$i]['cat_parent']][$cat_rowset[$i]['cat_id']] = $cat_rowset[$i]; ! $this->total_cat++; } } --- 147,345 ---- $db->sql_freeresult( $result ); + //$this->auth( AUTH_ALL, AUTH_LIST_ALL, $userdata, $cat_rowset ); + for( $i = 0; $i < count( $cat_rowset ); $i++ ) { ! if ( $this->auth_user[$cat_rowset[$i]['category_id']]['auth_view'] || true) ! { ! $this->cat_rowset[$cat_rowset[$i]['cat_id']] = $cat_rowset[$i]; ! $this->subcat_rowset[$cat_rowset[$i]['cat_parent']][$cat_rowset[$i]['cat_id']] = $cat_rowset[$i]; ! $this->total_cat++; ! } ! ! /* ! // ! // Comments ! // Note: some settings are category dependent, but may use default config settings ! // ! $this->comments[$cat_rowset[$i]['category_id']]['activated'] = $cat_rowset[$i]['cat_allow_comments'] == -1 ? ($kb_config['use_comments'] == 1 ? true : false ) : ( $cat_rowset[$i]['cat_allow_comments'] == 1 ? true : false ); ! $this->comments[$cat_rowset[$i]['category_id']]['internal_comments'] = $cat_rowset[$i]['internal_comments'] == -1 ? ($kb_config['internal_comments'] == 1 ? true : false ) : ( $cat_rowset[$i]['internal_comments'] == 1 ? true : false ); // phpBB or internal comments ! $this->comments[$cat_rowset[$i]['category_id']]['autogenerate_comments'] = $cat_rowset[$i]['autogenerate_comments'] == -1 ? ($kb_config['autogenerate_comments'] == 1 ? true : false ) : ( $cat_rowset[$i]['autogenerate_comments'] == 1 ? true : false ); // autocreate comments when updated ! $this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id'] = $cat_rowset[$i]['comments_forum_id'] < 1 ? ( intval($kb_config['comments_forum_id']) ) : ( intval($cat_rowset[$i]['comments_forum_id']) ); // phpBB target forum (only used for phpBB comments) ! ! if (!$this->comments[$cat_rowset[$i]['category_id']]['internal_comments'] && intval($this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id']) < 1) ! { ! mx_message_die(GENERAL_ERROR, 'Init Failure, phpBB comments with no target forum_id :(<br> Category: ' . $cat_rowset[$i]['category_name'] . ' Forum_id: ' . $this->comments[$cat_rowset[$i]['category_id']]['comments_forum_id']); ! } ! ! // ! // Ratings ! // ! $this->ratings[$cat_rowset[$i]['category_id']]['activated'] = $cat_rowset[$i]['cat_allow_ratings'] == -1 ? ($kb_config['use_ratings'] == 1 ? true : false ) : ( $cat_rowset[$i]['cat_allow_ratings'] == 1 ? true : false ); ! ! // ! // Information ! // ! $this->information[$cat_rowset[$i]['category_id']]['activated'] = $cat_rowset[$i]['show_pretext'] == -1 ? ($kb_config['show_pretext'] == 1 ? true : false ) : ( $cat_rowset[$i]['show_pretext'] == 1 ? true : false ); // phpBB or internal ratings ! ! // ! // Notification ! // ! $this->notification[$cat_rowset[$i]['category_id']]['activated'] = $cat_rowset[$i]['notify'] == -1 ? (intval($kb_config['notify'])) : ( intval($cat_rowset[$i]['notify']) ); // -1, 0, 1, 2 ! $this->notification[$cat_rowset[$i]['category_id']]['notify_group'] = $cat_rowset[$i]['notify_group'] == -1 || $cat_rowset[$i]['notify_group'] == 0 ? (intval($kb_config['notify_group'])) : ( intval($cat_rowset[$i]['notify_group']) ); // Group_id ! */ ! } ! } ! ! /** ! * Enter description here... ! * ! */ ! function _linkdb() ! { ! if ( $this->modified ) ! { ! $this->sync_all(); ! } ! } ! ! /** ! * Add debug message. ! * ! * @param unknown_type $debug_msg ! * @param unknown_type $file ! * @param unknown_type $line_break ! */ ! function debug($debug_msg, $file = '', $line_break = true) ! { ! if ($this->debug) ! { ! $module_name = !empty($this->module_name) ? $this->module_name . ' :: ' : ''; ! $file = !empty($file) ? ' (' . $file . ')' : ''; ! $line_break = $line_break ? '<br>' : ''; ! $this->debug_msg[] = $line_break . $module_name . $debug_msg . $file ; ! } ! } ! ! /** ! * Display debug message. ! * ! * @return unknown ! */ ! function display_debug() ! { ! if ($this->debug) ! { ! $debug_message = ''; ! foreach ($this->debug_msg as $key => $value) ! { ! $debug_message .= $value; ! } ! ! return $debug_message; ! } ! } ! ! function sync_all() ! { ! foreach( $this->cat_rowset as $cat_id => $void ) ! { ! $this->sync( $cat_id, false ); ! } ! $this->init(); ! } ! ! function sync( $cat_id, $init = true ) ! { ! global $db; ! ! $cat_nav = array(); ! $this->category_nav( $this->cat_rowset[$cat_id]['cat_parent'], &$cat_nav ); ! ! $sql = 'UPDATE ' . LINK_CATEGORIES_TABLE . " ! SET parents_data = '' ! WHERE cat_parent = " . $this->cat_rowset[$cat_id]['cat_parent']; ! ! if ( !( $db->sql_query( $sql ) ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Couldnt Query categories info', '', __LINE__, __FILE__, $sql ); } + + $sql = 'UPDATE ' . LINK_CATEGORIES_TABLE . " + SET cat_links = '-1' + WHERE cat_id = '" . $cat_id . "'"; + + if ( !( $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt Query Files info', '', __LINE__, __FILE__, $sql ); + } + if ( $init ) + { + $this->init(); + } + return; + } + + function category_nav( $parent_id, &$cat_nav ) + { + if ( !empty( $this->cat_rowset[$parent_id] ) ) + { + $this->category_nav( $this->cat_rowset[$parent_id]['cat_parent'], &$cat_nav ); + $cat_nav[$parent_id] = $this->cat_rowset[$parent_id]['cat_name']; + } + return; + } + + // + // if there is no cat + // + function cat_empty() + { + return ( $this->total_cat == 0 ) ? true : false; + } + + function modified( $true_false = false ) + { + $this->modified = $true_false; + } + + function file_in_cat( $cat_id ) + { + if ( $this->cat_rowset[$cat_id]['cat_links'] == -1 || $this->modified ) + { + global $db; + + $sql = 'SELECT COUNT(link_id) as total_files + FROM ' . LINKS_TABLE . " + WHERE link_approved = '1' + AND link_catid IN (" . $this->gen_cat_ids( $cat_id ) . ') + ORDER BY link_time DESC'; + + if ( !( $result = $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt Query Files info', '', __LINE__, __FILE__, $sql ); + } + + $files_no = 0; + if ( $row = $db->sql_fetchrow( $result ) ) + { + $files_no = $row['total_files']; + } + + $sql = 'UPDATE ' . LINK_CATEGORIES_TABLE . " + SET cat_links = $files_no + WHERE cat_id = $cat_id"; + + if ( !( $result = $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt Query Files info', '', __LINE__, __FILE__, $sql ); + } + } + else + { + $files_no = $this->cat_rowset[$cat_id]['cat_links']; + } + + return $files_no; } *************** *** 135,139 **** // $check_upload: if true permission for upload will be checked // ! function jumpmenu_option( $cat_id = 0, $depth = 0, $default = '', $for_file = false, $check_upload = false ) { static $cat_rowset = false; --- 352,356 ---- // $check_upload: if true permission for upload will be checked // ! function generate_jumpbox( $cat_id = 0, $depth = 0, $default = '', $for_file = false, $check_upload = false ) { static $cat_rowset = false; *************** *** 186,190 **** $cat_class = ( !$cat['cat_allow_file'] ) ? 'class="greyed"' : ''; $cat_list .= '<option value="' . $sub_cat_id . '"' . $sel . ' ' . $cat_class . ' />' . $pre . $cat_pre . $cat['cat_name'] . '</option>'; ! $cat_list .= $this->jumpmenu_option( $cat['cat_id'], $depth + 1, $default, $for_file, $check_upload ); } } --- 403,407 ---- $cat_class = ( !$cat['cat_allow_file'] ) ? 'class="greyed"' : ''; $cat_list .= '<option value="' . $sub_cat_id . '"' . $sel . ' ' . $cat_class . ' />' . $pre . $cat_pre . $cat['cat_name'] . '</option>'; ! $cat_list .= $this->generate_jumpbox( $cat['cat_id'], $depth + 1, $default, $for_file, $check_upload ); } } *************** *** 198,214 **** // - // if there is no cat - // - function cat_empty() - { - return ( $this->total_cat == 0 ) ? true : false; - } - - function modified( $true_false = false ) - { - $this->modified = $true_false; - } - - // // get all sub category in side certain category // $cat_id : category id --- 415,418 ---- *************** *** 216,219 **** --- 420,425 ---- function get_sub_cat( $cat_id ) { + global $mx_root_path, $module_root_path, $is_block, $phpEx; + $cat_sub .= ''; if ( !empty( $this->subcat_rowset[$cat_id] ) ) *************** *** 245,294 **** } ! /*function last_file_in_cat($cat_id, &$file_info) ! { ! if((empty($this->cat_rowset[$cat_id]['cat_last_file_id']) && empty($this->cat_rowset[$cat_id]['cat_last_file_name']) && empty($this->cat_rowset[$cat_id]['cat_last_file_time'])) || $this->modified) ! { ! global $db; ! ! $sql = 'SELECT file_time, file_id, file_name, file_catid ! FROM ' . LINKS_TABLE . " ! WHERE file_approved = '1' ! AND file_catid IN (" . $this->gen_cat_ids($cat_id) . ") ! ORDER BY file_time DESC"; ! ! if ( !($result = $db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_ERROR, 'Couldnt Query Files info', '', __LINE__, __FILE__, $sql); ! } ! ! while($row = $db->sql_fetchrow($result)) ! { ! $temp_cat[] = $row; ! } ! ! $file_info = $temp_cat[0]; ! if(!empty($file_info)) ! { ! $sql = 'UPDATE ' . LINK_CATEGORIES_TABLE . " ! SET cat_last_file_id = " . intval($file_info['file_id']) . ", ! cat_last_file_name = '" . addslashes($file_info['file_name']) . "', ! cat_last_file_time = " . intval($file_info['file_time']) . " ! WHERE cat_id = $cat_id"; ! ! if ( !($db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_ERROR, 'Couldnt Query Files info', '', __LINE__, __FILE__, $sql); ! } ! } ! } ! else ! { ! $file_info['file_id'] = $this->cat_rowset[$cat_id]['cat_last_file_id']; ! $file_info['file_name'] = $this->cat_rowset[$cat_id]['cat_last_file_name']; ! $file_info['file_time'] = $this->cat_rowset[$cat_id]['cat_last_file_time']; ! } ! }*/ ! ! function generate_category_nav( $cat_id ) { global $template, $db; --- 451,455 ---- } ! function generate_navigation( $cat_id ) { global $template, $db; *************** *** 332,384 **** } ! function category_nav( $parent_id, &$cat_nav ) { ! if ( !empty( $this->cat_rowset[$parent_id] ) ) { ! $this->category_nav( $this->cat_rowset[$parent_id]['cat_parent'], &$cat_nav ); ! $cat_nav[$parent_id] = $this->cat_rowset[$parent_id]['cat_name']; } ! return; } ! function file_in_cat( $cat_id ) { ! if ( $this->cat_rowset[$cat_id]['cat_links'] == -1 || $this->modified ) { global $db; ! $sql = 'SELECT COUNT(link_id) as total_files FROM ' . LINKS_TABLE . " ! WHERE link_approved = '1' ! AND link_catid IN (" . $this->gen_cat_ids( $cat_id ) . ') ! ORDER BY link_time DESC'; ! if ( !( $result = $db->sql_query( $sql ) ) ) { ! mx_message_die( GENERAL_ERROR, 'Couldnt Query Files info', '', __LINE__, __FILE__, $sql ); } ! $files_no = 0; ! if ( $row = $db->sql_fetchrow( $result ) ) { ! $files_no = $row['total_files']; } ! $sql = 'UPDATE ' . LINK_CATEGORIES_TABLE . " ! SET cat_links = $files_no WHERE cat_id = $cat_id"; ! if ( !( $result = $db->sql_query( $sql ) ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Couldnt Query Files info', '', __LINE__, __FILE__, $sql ); } } else { ! $files_no = $this->cat_rowset[$cat_id]['cat_links']; } ! ! return $files_no; ! } function gen_cat_ids( $cat_id, $cat_ids = '' ) --- 493,569 ---- } ! /** ! * Enter description here... ! * ! * @param unknown_type $cat_id ! * @return unknown ! */ ! /* ! function new_file_in_cat( $cat_id ) { ! global $pafiledb_config, $board_config, $db, $_COOKIE; ! ! $cat_array = explode(',', $this->gen_cat_ids( $cat_id )); ! ! $files_new = 0; ! ! $time = time() - ( $pafiledb_config['settings_newdays'] * 24 * 60 * 60 ); ! ! foreach ( $cat_array as $key => $cat_id ) { ! if ( $this->auth[$cat_id]['auth_read'] && $this->cat_rowset[$cat_id]['cat_last_file_time'] > $time) ! { ! $files_new++; ! } } ! ! return $files_new; } + */ ! /*function last_file_in_cat($cat_id, &$file_info) { ! if((empty($this->cat_rowset[$cat_id]['cat_last_file_id']) && empty($this->cat_rowset[$cat_id]['cat_last_file_name']) && empty($this->cat_rowset[$cat_id]['cat_last_file_time'])) || $this->modified) { global $db; ! $sql = 'SELECT file_time, file_id, file_name, file_catid FROM ' . LINKS_TABLE . " ! WHERE file_approved = '1' ! AND file_catid IN (" . $this->gen_cat_ids($cat_id) . ") ! ORDER BY file_time DESC"; ! if ( !($result = $db->sql_query($sql)) ) { ! mx_message_die(GENERAL_ERROR, 'Couldnt Query Files info', '', __LINE__, __FILE__, $sql); } ! while($row = $db->sql_fetchrow($result)) { ! $temp_cat[] = $row; } ! $file_info = $temp_cat[0]; ! if(!empty($file_info)) ! { ! $sql = 'UPDATE ' . LINK_CATEGORIES_TABLE . " ! SET cat_last_file_id = " . intval($file_info['file_id']) . ", ! cat_last_file_name = '" . addslashes($file_info['file_name']) . "', ! cat_last_file_time = " . intval($file_info['file_time']) . " WHERE cat_id = $cat_id"; ! if ( !($db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_ERROR, 'Couldnt Query Files info', '', __LINE__, __FILE__, $sql); ! } } } else { ! $file_info['file_id'] = $this->cat_rowset[$cat_id]['cat_last_file_id']; ! $file_info['file_name'] = $this->cat_rowset[$cat_id]['cat_last_file_name']; ! $file_info['file_time'] = $this->cat_rowset[$cat_id]['cat_last_file_time']; } ! }*/ function gen_cat_ids( $cat_id, $cat_ids = '' ) *************** *** 399,403 **** } ! function category_display( $cat_id = LINKDB_ROOT_CAT ) { global $db, $template, $lang, $userdata, $phpEx, $images; --- 584,588 ---- } ! function display_categories( $cat_id = LINKDB_ROOT_CAT ) { global $db, $template, $lang, $userdata, $phpEx, $images; *************** *** 987,1030 **** } - function sync( $cat_id, $init = true ) - { - global $db; - - $cat_nav = array(); - $this->category_nav( $this->cat_rowset[$cat_id]['cat_parent'], &$cat_nav ); - - $sql = 'UPDATE ' . LINK_CATEGORIES_TABLE . " - SET parents_data = '' - WHERE cat_parent = " . $this->cat_rowset[$cat_id]['cat_parent']; - - if ( !( $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldnt Query categories info', '', __LINE__, __FILE__, $sql ); - } - - $sql = 'UPDATE ' . LINK_CATEGORIES_TABLE . " - SET cat_links = '-1' - WHERE cat_id = '" . $cat_id . "'"; - - if ( !( $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldnt Query Files info', '', __LINE__, __FILE__, $sql ); - } - if ( $init ) - { - $this->init(); - } - return; - } - - function sync_all() - { - foreach( $this->cat_rowset as $cat_id => $void ) - { - $this->sync( $cat_id, false ); - } - $this->init(); - } - function update_add_link( $file_id = false ) { --- 1172,1175 ---- *************** *** 1125,1133 **** } ! function _linkdb() { ! if ( $this->modified ) { ! $this->sync_all(); } } --- 1270,1438 ---- } ! /** ! * Enter description here... ! * ! * @param unknown_type $article_data ! * @param unknown_type $item_id ! * @param unknown_type $cid ! * @param unknown_type $subject ! * @param unknown_type $message ! * @param unknown_type $html_on ! * @param unknown_type $bbcode_on ! * @param unknown_type $smilies_on ! */ ! function update_add_comment($file_data = '', $item_id, $cid, $subject = '', $message = '', $html_on = false, $bbcode_on = true, $smilies_on = false) { ! global $pafiledb_template, $pafiledb_functions, $lang, $board_config, $phpEx, $pafiledb_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; ! ! // ! // Ensure we have article_data defined ! // ! if (!is_array($article_data) && !empty($item_id) && $item_id > 0) { ! $sql = "SELECT * ! FROM " . PA_FILES_TABLE . " ! WHERE file_id = '" . $item_id . "'"; ! ! if ( !( $result = $db->sql_query( $sql ) ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Couldnt select download', '', __LINE__, __FILE__, $sql ); ! } ! ! if ( !$article_data = $db->sql_fetchrow( $result ) ) ! { ! mx_message_die( GENERAL_MESSAGE, $lang['Article_not_exsist'] ); ! } ! ! $db->sql_freeresult( $result ); ! } ! ! // ! // vars (can both be POSTed or send through the function) ! // ! $update_comment = $cid > 0 ? true : false; ! $subject = !empty($subject) ? $subject : $_POST['subject']; ! $message = !empty($message) ? $message : $_POST['message']; ! ! $length = strlen( $message ); ! ! // ! // Instantiate the mx_text class ! // ! include_once($mx_root_path . 'includes/mx_functions_tools.'.$phpEx); ! $mx_text = new mx_text(); ! $mx_text->init($html_on, $bbcode_on, $smilies_on); ! //$mx_text->allow_all_html_tags = $parameter_data['parameter_type'] = 'WysiwygTextBlock' ? true : false; ! ! // ! // Encode for db storage ! // ! $title = $mx_text->encode_simple($subject); ! $comments_text = $mx_text->encode($message); ! $comment_bbcode_uid = $mx_text->bbcode_uid; ! ! if ( $length > $pafiledb_config['max_comment_chars'] ) ! { ! mx_message_die( GENERAL_ERROR, 'Your comment is too long!<br/>The maximum length allowed in characters is ' . $pafiledb_config['max_comment_chars'] . '' ); ! } ! ! if ( $update_comment ) ! { ! if ( $this->comments[$file_data['file_catid']]['internal_comments'] ) ! { ! $sql = "UPDATE " . PA_COMMENTS_TABLE . " ! SET comments_text = '" . str_replace( "\'", "''", $comments_text ) . "', ! comments_title = '" . str_replace( "\'", "''", $title ) . "', ! comment_bbcode_uid = '" . $comment_bbcode_uid . "' ! WHERE comments_id = " . $cid . " ! AND file_id = ". $item_id; ! ! if ( !( $db->sql_query( $sql ) ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Couldnt update comments', '', __LINE__, __FILE__, $sql ); ! } ! } ! else ! { ! include( $module_root_path . 'pafiledb/includes/functions_comment.' . $phpEx ); ! $pafiledb_comments = new pafiledb_comments(); ! $pafiledb_comments->init( $item_id ); ! ! $return_data = $pafiledb_comments->post( 'update', $cid, $title, $comments_text, $userdata['user_id'], $userdata['username'], 0, '', '', $comment_bbcode_uid); ! } ! ! } ! else ! { ! if ( $this->comments[$file_data['file_catid']]['internal_comments'] ) ! { ! $time = time(); ! $poster_id = intval( $userdata['user_id'] ); ! $sql = "INSERT INTO " . PA_COMMENTS_TABLE . "(file_id, comments_text, comments_title, comments_time, comment_bbcode_uid, poster_id) ! VALUES('$item_id','" . str_replace( "\'", "''", $comments_text ) . "','" . str_replace( "\'", "''", $title ) . "','$time', '$comment_bbcode_uid','$poster_id')"; ! ! if ( !( $db->sql_query( $sql ) ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Couldnt insert comments', '', __LINE__, __FILE__, $sql ); ! } ! } ! else ! { ! include( $module_root_path . 'pafiledb/includes/functions_comment.' . $phpEx ); ! $pafiledb_comments = new pafiledb_comments(); ! $pafiledb_comments->init( $item_id ); ! ! $return_data = $pafiledb_comments->post( 'insert', '', $title, $comments_text, $userdata['user_id'], $userdata['username'], 0, '', '', $comment_bbcode_uid); ! } ! } ! ! if ( !$this->comments[$file_data['file_catid']]['internal_comments'] ) ! { ! ! // ! // Update the item data itself ! // ! if ($file_data['topic_id'] == 0 ) ! { ! // ! // Update item with new topic_id ! // ! $sql = "UPDATE " . PA_FILES_TABLE . " ! SET topic_id = '" . $return_data['topic_id'] . "' ! WHERE file_id = ". $item_id; ! ! if ( !( $result = $db->sql_query( $sql ) ) ) ! { ! mx_message_die( GENERAL_ERROR, 'Couldnt update item', '', __LINE__, __FILE__, $sql ); ! } ! ! $db->sql_freeresult( $result ); ! } ! } ! } ! ! /** ! * Enter description here... ! * ! * @param unknown_type $cat_id ! */ ! function auth_can($cat_id) ! { ! global $lang; ! ! $this->auth_can_list = '<br />' . ( ( $this->auth[$cat_id]['auth_upload'] ) ? $lang['PA_Rules_upload_can'] : $lang['PA_Rules_upload_cannot'] ) . '<br />'; ! $this->auth_can_list .= ( ( $this->auth[$cat_id]['auth_view_file'] ) ? $lang['PA_Rules_view_file_can'] : $lang['PA_Rules_view_file_cannot'] ) . '<br />'; ! $this->auth_can_list .= ( ( $this->auth[$cat_id]['auth_edit_file'] ) ? $lang['PA_Rules_edit_file_can'] : $lang['PA_Rules_edit_file_cannot'] ) . '<br />'; ! $this->auth_can_list .= ( ( $this->auth[$cat_id]['auth_delete_file'] ) ? $lang['PA_Rules_delete_file_can'] : $lang['PA_Rules_delete_file_cannot'] ) . '<br />'; ! $this->auth_can_list .= ( ( $this->comments[$cat_id]['activated'] ? ( ( $this->auth[$cat_id]['auth_view_comment'] ? $lang['PA_Rules_view_comment_can'] : $lang['PA_Rules_view_comment_cannot'] ) . '<br />') : '')); ! $this->auth_can_list .= ( ( $this->comments[$cat_id]['activated'] ? ( ( $this->auth[$cat_id]['auth_post_comment'] ? $lang['PA_Rules_post_comment_can'] : $lang['PA_Rules_post_comment_cannot'] ) . '<br />') : '')); ! $this->auth_can_list .= ( ( $this->ratings[$cat_id]['activated'] ? ( ( $this->auth[$cat_id]['auth_rate'] ? $lang['PA_Rules_rate_can'] : $lang['PA_Rules_rate_cannot'] ) . '<br />') : '')); ! $this->auth_can_list .= ( ( $this->auth[$cat_id]['auth_download'] ) ? $lang['PA_Rules_download_can'] : $lang['PA_Rules_download_cannot'] ) . '<br />'; ! ! if ( $this->auth[$cat_id]['auth_mod'] ) ! { ! $this->auth_can_list .= $lang['PA_Rules_moderate_can']; } } --- functions_linkdb_field.php DELETED --- --- NEW FILE: functions_field.php --- <?php /** * * @package mxBB Portal Module - mx_linkdb * @version $Id: functions_field.php,v 1.1 2006/07/01 21:32:19 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" ); } class custom_field { var $field_rowset = array(); var $field_data_rowset = array(); // // prepare data // function init() { global $db; $sql = "SELECT * FROM " . LINK_CUSTOM_TABLE . " ORDER BY field_order ASC"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt Query Custom field', '', __LINE__, __FILE__, $sql ); } while ( $row = $db->sql_fetchrow( $result ) ) { $this->field_rowset[$row['custom_id']] = $row; } unset( $row ); $db->sql_freeresult( $result ); $sql = "SELECT * FROM " . LINK_CUSTOM_DATA_TABLE; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt Query Custom field', '', __LINE__, __FILE__, $sql ); } while ( $row = $db->sql_fetchrow( $result ) ) { $this->field_data_rowset[$row['customdata_file']][$row['customdata_custom']] = $row; } unset( $row ); $db->sql_freeresult( $result ); } // // check if there is a data in the database // function field_data_exist() { if ( !empty( $this->field_data_rowset ) ) { return true; } return false; } function field_exist() { if ( !empty( $this->field_rowset ) ) { return true; } return false; } // // display data in the file page // function display_data( $file_id ) { global $template; if ( $this->field_data_exist() ) { if ( isset( $this->field_data_rowset[$file_id] ) ) { foreach( $this->field_data_rowset[$file_id] as $field_id => $data ) { if ( !empty( $data['data'] ) ) { switch ( $this->field_rowset[$field_id]['field_type'] ) { case INPUT: case TEXTAREA: case RADIO: case SELECT: $field_data = $data['data']; break; case SELECT_MULTIPLE: case CHECKBOX: $field_data = @implode( ', ', unserialize( $data['data'] ) ); break; } $template->assign_block_vars( 'custom_field', array( 'CUSTOM_NAME' => $this->field_rowset[$field_id]['custom_name'], 'DATA' => $field_data ) ); } else { global $db; $sql = "DELETE FROM " . LINK_CUSTOM_DATA_TABLE . " WHERE customdata_file = '$file_id' AND customdata_custom = '$field_id'"; if ( !( $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Could not delete custom data', '', __LINE__, __FILE__, $sql ); } } } } else { return false; } } else { return false; } } // display custom field and data in the add/edit page function display_edit( $file_id = false ) { $return = false; if ( $this->field_exist() ) { foreach( $this->field_rowset as $field_id => $field_data ) { switch ( $field_data['field_type'] ) { case INPUT: $this->display_edit_input( $file_id, $field_id, $field_data ); break; case TEXTAREA: $this->display_edit_textarea( $file_id, $field_id, $field_data ); break; case RADIO: $this->display_edit_radio( $file_id, $field_id, $field_data ); break; case SELECT: $this->display_edit_select( $file_id, $field_id, $field_data ); break; case SELECT_MULTIPLE: $this->display_edit_select_multiple( $file_id, $field_id, $field_data ); break; case CHECKBOX: $this->display_edit_checkbox( $file_id, $field_id, $field_data ); break; } $return = true; } } return $return; } function display_edit_input( $file_id, $field_id, $field_data ) { global $template; $template->assign_block_vars( 'input', array( 'FIELD_NAME' => $field_data['custom_name'], 'FIELD_ID' => $field_data['custom_id'], 'FIELD_DESCRIPTION' => $field_data['custom_description'], 'FIELD_VALUE' => ( !empty( $this->field_data_rowset[$file_id][$field_id]['data'] ) ) ? $this->field_data_rowset[$file_id][$field_id]['data'] : '' ) ); } function display_edit_textarea( $file_id, $field_id, $field_data ) { global $template; $template->assign_block_vars( 'textarea', array( 'FIELD_NAME' => $field_data['custom_name'], 'FIELD_ID' => $field_data['custom_id'], 'FIELD_DESCRIPTION' => $field_data['custom_description'], 'FIELD_VALUE' => ( !empty( $this->field_data_rowset[$file_id][$field_id]['data'] ) ) ? $this->field_data_rowset[$file_id][$field_id]['data'] : '' ) ); } function display_edit_radio( $file_id, $field_id, $field_data ) { global $template; $template->assign_block_vars( 'radio', array( 'FIELD_NAME' => $field_data['custom_name'], 'FIELD_ID' => $field_data['custom_id'], 'FIELD_DESCRIPTION' => $field_data['custom_description'] ) ); $data = ( !empty( $this->field_data_rowset[$file_id][$field_id]['data'] ) ) ? $this->field_data_rowset[$file_id][$field_id]['data'] : array(); $field_datas = ( !empty( $field_data['data'] ) ) ? unserialize( stripslashes( $field_data['data'] ) ) : array(); if ( !empty( $field_datas ) ) { foreach( $field_datas as $key => $value ) { $template->assign_block_vars( 'radio.row', array( 'FIELD_VALUE' => $value, 'FIELD_SELECTED' => ( $data == $value ) ? ' checked="checked"' : '' ) ); } } } function display_edit_select( $file_id, $field_id, $field_data ) { global $template; $template->assign_block_vars( 'select', array( 'FIELD_NAME' => $field_data['custom_name'], 'FIELD_ID' => $field_data['custom_id'], 'FIELD_DESCRIPTION' => $field_data['custom_description'] ) ); $data = ( !empty( $this->field_data_rowset[$file_id][$field_id]['data'] ) ) ? $this->field_data_rowset[$file_id][$field_id]['data'] : ''; $field_datas = ( !empty( $field_data['data'] ) ) ? unserialize( stripslashes( $field_data['data'] ) ) : array(); if ( !empty( $field_datas ) ) { foreach( $field_datas as $key => $value ) { $template->assign_block_vars( 'select.row', array( 'FIELD_VALUE' => $value, 'FIELD_SELECTED' => ( $data == $value ) ? ' selected="selected"' : '' ) ); } } } function display_edit_select_multiple( $file_id, $field_id, $field_data ) { global $template; $template->assign_block_vars( 'select_multiple', array( 'FIELD_NAME' => $field_data['custom_name'], 'FIELD_ID' => $field_data['custom_id'], 'FIELD_DESCRIPTION' => $field_data['custom_description'] ) ); $data = ( !empty( $this->field_data_rowset[$file_id][$field_id]['data'] ) ) ? unserialize( $this->field_data_rowset[$file_id][$field_id]['data'] ) : array(); $field_datas = ( !empty( $field_data['data'] ) ) ? unserialize( stripslashes( $field_data['data'] ) ) : array(); if ( !empty( $field_datas ) ) { foreach( $field_datas as $key => $value ) { $selected = ''; foreach( $data as $field_value ) { if ( $field_value == $value ) { $selected = ' selected="selected"'; break; } } $template->assign_block_vars( 'select_multiple.row', array( 'FIELD_VALUE' => $value, 'FIELD_SELECTED' => $selected ) ); } } } function display_edit_checkbox( $file_id, $field_id, $field_data ) { global $template; $template->assign_block_vars( 'checkbox', array( 'FIELD_NAME' => $field_data['custom_name'], 'FIELD_ID' => $field_data['custom_id'], 'FIELD_DESCRIPTION' => $field_data['custom_description'] ) ); $data = ( !empty( $this->field_data_rowset[$file_id][$field_id]['data'] ) ) ? unserialize( $this->field_data_rowset[$file_id][$field_id]['data'] ) : array(); $field_datas = ( !empty( $field_data['data'] ) ) ? unserialize( stripslashes( $field_data['data'] ) ) : array(); if ( !empty( $field_datas ) ) { foreach( $field_datas as $key => $value ) { $checked = ''; foreach( $data as $field_value ) { if ( $field_value == $value ) { $checked = ' checked'; break; } } $template->assign_block_vars( 'checkbox.row', array( 'FIELD_VALUE' => $value, 'FIELD_CHECKED' => $checked ) ); } } } function update_add_field( $field_type, $field_id = false ) { global $db, $db, $_POST, $lang; $field_name = ( isset( $_POST['field_name'] ) ) ? htmlspecialchars( $_POST['field_name'] ) : ''; $field_desc = ( isset( $_POST['field_desc'] ) ) ? htmlspecialchars( $_POST['field_desc'] ) : ''; $regex = ( isset( $_POST['regex'] ) ) ? $_POST['regex'] : ''; $data = ( isset( $_POST['data'] ) ) ? $_POST['data'] : ''; $field_order = ( isset( $_POST['field_order'] ) ) ? $_POST['field_order'] : ''; if ( $field_id ) { $field_order = ( isset( $_POST['field_... [truncated message content] |