|
From: Jon O. <jon...@us...> - 2005-10-22 12:40:50
|
Update of /cvsroot/mxbb/mx_dev_startkit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4328 Added Files: db_install.php db_uninstall.php db_upgrade.php mx_dev_startkit.php Log Message: adding this module --- NEW FILE: db_upgrade.php --- <?php /** * * ------------------------------------------------------------------------ * subject : mxBB-Portal - CMS & portal * begin : june, 2002 * copyright : (C) 2002-2005 mxBB-Portal * email : jon...@ho... * project site : www.mx-system.com * * ------------------------------------------------------------------------- * * $Id: db_upgrade.php,v 1.1 2005/10/22 12:40:33 jonohlsson Exp $ */ /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ define( 'IN_PORTAL', true ); if ( !defined( 'IN_ADMIN' ) ) { $mx_root_path = './../../'; include( $mx_root_path . 'extension.inc' ); include( $mx_root_path . 'common.' . $phpEx ); // Start session management $userdata = session_pagestart( $user_ip, PAGE_INDEX ); mx_init_userprefs( $userdata ); if ( !$userdata['session_logged_in'] ) { die( "Hacking attempt(1)" ); } if ( $userdata['user_level'] != ADMIN ) { die( "Hacking attempt(2)" ); } // End session management } $mx_module_version = 'mxBB - phpBB Integration Module 1.0.3'; $mx_module_copy = 'Based on <a href="http://www.phpbb.com/" target="_phpbb" >phpBB</a>'; $sql = array(); // // Precheck // if ( $result = $db->sql_query( "SELECT config_name from " . $mx_table_prefix . "phpbb_plugin_config" ) ) { // // Upgrade checks // $upgrade_101 = 0; $upgrade_102 = 0; $upgrade_103 = 0; $upgrade_104 = 0; $upgrade_105 = 0; $upgrade_106 = 0; $upgrade_107 = 0; // // validate before 1.01 // $result = $db->sql_query( "SELECT config_value from " . $mx_table_prefix . "phpbb_plugin_config WHERE config_name = 'override_default_pages'" ); if ( $db->sql_numrows( $result ) == 0 ) { $upgrade_101 = 1; } $result = $db->sql_query( "SELECT config_value from " . $mx_table_prefix . "phpbb_plugin_config WHERE config_name = 'enable_module'" ); if ( $db->sql_numrows( $result ) == 0 ) { $upgrade_102 = 1; } $message = "<b>Upgrading!</b><br/><br/>"; if ( $upgrade_101 == 1 ) { $message .= "<b>Upgrading to v. 1.01...</b><br/><br/>"; $sql[] = "CREATE TABLE " . $mx_table_prefix . "phpbb_plugin_config ( config_name VARCHAR(255) NOT NULL default '', config_value varchar(255) NOT NULL default '', PRIMARY KEY (config_name) ) TYPE=MyISAM"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('override_default_pages', 'Block_setup')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('faq', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('groupcp', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('index', '2')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('login', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('memberlist', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('modcp', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('posting', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('privmsg', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('profile', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('search', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('viewonline', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('other', '0')"; } else if ( $upgrade_102 == 1 ) { $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('enable_module', '1')"; } else { $message .= "<b>Nothing to upgrade...</b><br/><br/>"; } $sql[] = "UPDATE " . $mx_table_prefix . "module" . " SET module_version = '" . $mx_module_version . "', module_copy = '" . $mx_module_copy . "' WHERE module_id = '" . $mx_module_id . "'"; $message .= mx_do_install_upgrade( $sql ); } else { // // If not installed // $message = "<b>Module is not installed...and thus cannot be upgraded ;)</b><br/><br/>"; } echo "<br /><br />"; echo "<table width=\"90%\" align=\"center\" cellpadding=\"4\" cellspacing=\"1\" border=\"0\" class=\"forumline\">"; echo "<tr><th class=\"thHead\" align=\"center\">Module Installation/Upgrading/Uninstalling Information - module specific db tables</th></tr>"; echo "<tr><td class=\"row1\" align=\"left\"><span class=\"gen\">" . $message . "</span></td></tr>"; echo "</table><br />"; ?> --- NEW FILE: db_uninstall.php --- <?php /** * * ------------------------------------------------------------------------ * subject : mxBB-Portal - CMS & portal * begin : june, 2002 * copyright : (C) 2002-2005 mxBB-Portal * email : jon...@ho... * project site : www.mx-system.com * * ------------------------------------------------------------------------- * * $Id: db_uninstall.php,v 1.1 2005/10/22 12:40:33 jonohlsson Exp $ */ /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ define( 'IN_PORTAL', true ); if ( !defined( 'IN_ADMIN' ) ) { $mx_root_path = './../../'; include( $mx_root_path . 'extension.inc' ); include( $mx_root_path . 'common.' . $phpEx ); // Start session management $userdata = session_pagestart( $user_ip, PAGE_INDEX ); mx_init_userprefs( $userdata ); if ( !$userdata['session_logged_in'] ) { die( "Hacking attempt(1)" ); } if ( $userdata['user_level'] != ADMIN ) { die( "Hacking attempt(2)" ); } // End session management } $sql = array( "DROP TABLE IF EXISTS " . $mx_table_prefix . "phpbb_plugin_config", ); echo "<br /><br />"; echo "<table width=\"90%\" align=\"center\" cellpadding=\"4\" cellspacing=\"1\" border=\"0\" class=\"forumline\">"; echo "<tr><th class=\"thHead\" align=\"center\">Module Installation/Upgrading/Uninstalling Information - module specific db tables</th></tr>"; echo "<tr><td class=\"row1\" align=\"left\"><span class=\"gen\">" . mx_do_install_upgrade( $sql ) . "</span></td></tr>"; echo "</table><br />"; ?> --- NEW FILE: db_install.php --- <?php /** * * ------------------------------------------------------------------------ * subject : mxBB-Portal - CMS & portal * begin : june, 2002 * copyright : (C) 2002-2005 mxBB-Portal * email : jon...@ho... * project site : www.mx-system.com * * ------------------------------------------------------------------------- * * $Id: db_install.php,v 1.1 2005/10/22 12:40:33 jonohlsson Exp $ */ /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ define( 'IN_PORTAL', true ); if ( !defined( 'IN_ADMIN' ) ) { $mx_root_path = './../../'; include( $mx_root_path . 'extension.inc' ); include( $mx_root_path . 'common.' . $phpEx ); // Start session management $userdata = session_pagestart( $user_ip, PAGE_INDEX ); mx_init_userprefs( $userdata ); if ( !$userdata['session_logged_in'] ) { die( "Hacking attempt(1)" ); } if ( $userdata['user_level'] != ADMIN ) { die( "Hacking attempt(2)" ); } // End session management } $mx_module_version = 'mxBB - phpBB Integration Module 1.0.3'; $mx_module_copy = 'Based on <a href="http://www.phpbb.com/" target="_phpbb">phpBB</a>'; // If fresh install if ( !$result = $db->sql_query( "SELECT config_name from " . $mx_table_prefix . "phpbb_plugin_config" ) ) { $message = "<b>This is a fresh install!</b><br/><br/>"; $sql = array(); $sql[] = "DROP TABLE IF EXISTS " . $mx_table_prefix . "phpbb_plugin_config"; $sql[] = "CREATE TABLE " . $mx_table_prefix . "phpbb_plugin_config ( config_name VARCHAR(255) NOT NULL default '', config_value varchar(255) NOT NULL default '', PRIMARY KEY (config_name) ) TYPE=MyISAM"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('override_default_pages', 'Block_setup')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('enable_module', '1')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('faq', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('groupcp', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('index', '2')"; //$sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('viewforum', '0')"; //$sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('viewtopic', '0')"; //$sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('modcp', '0')"; //$sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('posting', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('login', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('memberlist', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('privmsg', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('profile', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('search', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('viewonline', '0')"; $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('other', '0')"; $sql[] = "UPDATE " . $mx_table_prefix . "module" . " SET module_version = '" . $mx_module_version . "', module_copy = '" . $mx_module_copy . "' WHERE module_id = '" . $mx_module_id . "'"; $message .= mx_do_install_upgrade( $sql ); } else { // If already installed $message = "<b>Module is already installed...consider upgrading ;)</b><br/><br/>"; } echo "<br /><br />"; echo "<table width=\"90%\" align=\"center\" cellpadding=\"4\" cellspacing=\"1\" border=\"0\" class=\"forumline\">"; echo "<tr><th class=\"thHead\" align=\"center\">Module Installation/Upgrading/Uninstalling Information - module specific db tables</th></tr>"; echo "<tr><td class=\"row1\" align=\"left\"><span class=\"gen\">" . $message . "</span></td></tr>"; echo "</table><br />"; ?> --- NEW FILE: mx_dev_startkit.php --- <?php /*************************************************************************** * mx_index.php * ------------------- * begin : Saturday, Feb 13, 2001 * copyright : (C) 2001 The phpBB Group * email : su...@ph... * * $Id: mx_dev_startkit.php,v 1.1 2005/10/22 12:40:33 jonohlsson Exp $ * * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ /********************************************************************************\ | Developers Startkit Module |******************************************************************************** | | General Core resources | ------------------ | Every block inherit a basic set of block and page attributes. These are obtained from the mx_block and mx_page objects. | Core also defines a set of basic variables | | | Examples: | | Block attributes: $mx_block->block_id, $mx_block->block_title|block_desc, $mx_block->auth_view|auth_edit|auth_mod | Page attributes: $mx_page->info['page_name'] | Basic variables: $mx_root_path (string), $phpbb_root_path (string), $template (object), $db (object) | | The full list of object attributes are available in the classes technical notes (see includes/mx_functions_core.php). | The full set of portal predefined variables are defined in includes/mx_constants.php | | Handy Core methods | ------------------ | When porting phpBB MODs to mxBB, typically you need a few standard rewrites. The mx_modules class provides a handy set of methods. | | | Examples: | | $mx_module->append_sid() | $mx_module->redirect() | $mx_module->make_jumpbox() | $mx_module->generate_pagination() | $mx_module->smilies_pass() | $mx_module->generate_smilies() | | | Remember: All instances of page_header and page_tail inclusions should be removed, not to interfer with mxBB headers | | | Module Parameters Api | ------------------ | Core provides a rich set of parameter types. Additional block specific types are defined in module_root/admin/mx_module_defs.php. | Block parameters are accessed with the mx_block->get_parameters() method. | | mx_block->get_parameters() Api | | Available switches: MX_GET_ALL_PARS, MX_GET_PAR_VALUE (default), MX_GET_PAR_OPTIONS | | Examples: | | $mx_block->get_parameters( MX_GET_ALL_PARS ) | - returns an array with all parameters :: array('par_name1' => $par1_value, 'par_name2' => $par2_value, ...) | | $mx_block->get_parameters( 'parameter_name' ) | - returns value for 'parameter_name' | | $mx_block->get_parameters( 'parameter_name', MX_GET_PAR_OPTIONS ) | - returns options for 'parameter_name', eg bbcodes etc | | | Module Settings using additional db tables | ------------------ | More advanced modules need additional settings, intended for ALL module blocks. | For example, a image album module needs a defined pics folder and other modules may use global settings | NOTE: Block specific parameters should never use additional (non portal) db tables, since such data is NOT included in the portal cache engine and therefore speed will be affected. | | Example: | | Data should be managed in an axtra module adminCP panel | Db tables to be used should be defined in the includes/mx_module_constants.php file | Data should be accessed using the standard $db api. | \********************************************************************************/ if( !defined('IN_PORTAL') ) { die("Hacking attempt !!!"); } // // Load POST/GET vars // - When php.ini is set with Register Globals Off (highly recommended due to security), you need to declare all GET/POST vars // - The $mx_request_vars api is documented in includes/mx_functions.php. // $test_get_var = $mx_request_vars->request('test', MX_TYPE_INT, 1); // In this example the GET var is validated for integer and set to '1' as default (if no GET var is given) // Load main module configs (using an additional db tables) // Consider if this is really needed for the module, since it requeres one additinal db query per page block instance // $sql = "SELECT * FROM " . STARTKIT_CONFIG_TABLE; if ( !$result = $db->sql_query( $sql ) ) { message_die( CRITICAL_ERROR, "Could not query config information in kb_config", "", __LINE__, __FILE__, $sql ); } else { $mx_module_config = array(); while ( $results = $db->sql_fetchrow( $result ) ) { $config_name = $results['config_name']; $config_value = $results['config_value']; $mx_module_configs[$config_name] = $config_value; } } // // Load module block parameters // - be careful not to use too common variable names - to avoid conflicts with other blocks // // If possible, do this instead // // $mx_startkit_pars['test_string'] = $mx_block->get_parameters( 'startkit_test_string' ); // $mx_startkit_pars['test_number'] = $mx_block->get_parameters( 'startkit_test_number' ); // $mx_par_test_string = $mx_block->get_parameters( 'startkit_test_string' ); $mx_par_test_number = $mx_block->get_parameters( 'startkit_test_number' ); // // Load module constants and functions // include_once($mx_root_path . $mx_block->module_root_path . "includes/mx_module_constants.$phpEx"); // Will load additional module lang keys, definitions, copyrights and theme data include_once($mx_root_path . $mx_block->module_root_path . "includes/mx_module_functions.$phpEx"); // Will load additional module functions (be sure to prefix with 'mx_' to avoid function conflicts) // // Load module functions // $mx_startkit = new mx_startkit; // // Start output of Block // $template->set_filenames( array( 'body' => 'kb_index_body.tpl' )); // // Block Body // - not much to do in this simple block // /* ... */ // // Use a module function // $mx_manipulated_test_number = $mx_startkit->double($mx_par_test_number); // // Pass Block data to template // $template->assign_vars( array( 'L_STARTKIT_INFO' => $lang['Startkit_info'], 'L_TEST_STRING' => $lang['Test_string'], 'L_TEST_NUMBER' => $lang['Test_number'], 'L_TEST_NUMBER' => $lang['Test_config1'], 'L_TEST_NUMBER' => $lang['Test_config2'], 'L_TEST_GET_PAR' => $lang['Test_get_par'], 'TEST_STRING' => $mx_par_test_string, 'TEST_NUMBER' => $mx_par_test_number, 'MANIPULATED_TEST_NUMBER' => $mx_manipulated_test_number, 'TEST_CONFIG1' => $mx_module_configs['startkit_config1'], 'TEST_CONFIG2' => $mx_module_configs['startkit_config2'], 'TEST_GET_PAR' => $par_test_get_par )); // // Generate Block // $template->pparse( 'body' ); ?> |