Replaced old install script with autoinstall.php and set version number to 2.1
authorDirk Haun <dirk@haun-online.de>
Sat, 24 Jul 2010 11:13:55 +0200
changeset 1f4e3dd2df73d
parent 0 8e7bdb0b560f
child 2 7c7ca1ea6717
Replaced old install script with autoinstall.php and set version number to 2.1
admin/install.html
admin/install.php
autoinstall.php
     1.1 --- a/admin/install.html	Sat Jul 24 11:11:41 2010 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,38 +0,0 @@
     1.4 -<pre>
     1.5 -Install/Uninstall instruction for the Geeklog Net Tools plugin.
     1.6 -
     1.7 -INSTALL:
     1.8 -
     1.9 -Step 1:  Back up your Geeklog Database.  The Net Tools plugin adds tables to your Geeklog database.  You can do
    1.10 -this with the built in admin backup facility.
    1.11 -
    1.12 -Step 2:  Uncompress the Net Tools plugin archive while in the <geeklog_dir>/plugins directory.  The archive will
    1.13 -create a directory called Net Tools in the plugins directory.
    1.14 -
    1.15 -Step 3:  Create the public_html and admin directories.  Under your html directory (usually public_html) 
    1.16 -create a directory called Net Tools.  Under your admin/plugins/ directory create a directory called Net Tools.
    1.17 -
    1.18 -Step 4:  Change to your <geeklog_dir>/plugins/Net Tools/ directory.  Copy the files in the admin directory 
    1.19 -to the admin/plugins/Net Tools/ directory your created in step 3.  Copy the files and directories in the 
    1.20 -public_html directory to the public_html/Net Tools/ directory your created in step 3.
    1.21 -
    1.22 -Step 5:  Log in to your Geeklog as a root user and run install.php in your admin/plugins/Net Tools/ directory.
    1.23 -The install page will tell you if the install was successful or not.  If not examine Geeklog system errorlog
    1.24 -for possible problems.
    1.25 -
    1.26 -The Net Tools plugin should now be installed and functioning.  Clicking on the Net Tools Icon will
    1.27 -take you to the admin page.  
    1.28 -
    1.29 -Step 7: Set up security.  On install only the root users have access to Net Tools Viewing.  
    1.30 -You can delegate control for either of these functions through the user and group editors.
    1.31 -
    1.32 -UNINSTALL:
    1.33 -
    1.34 -Step 1:  Run the install.php page in your admin/plugins/Net Tools directory.  This will remove all the data from
    1.35 -your database.
    1.36 -
    1.37 -Step 2:  Delete the three plugin directories created in the install process:  <geeklog-dir>plugins/Net Tools/ 
    1.38 -<public_html>/Net Tools/ and <admin>/plugins/Net Tools/
    1.39 -
    1.40 -Thats it.
    1.41 -</pre>
    1.42 \ No newline at end of file
     2.1 --- a/admin/install.php	Sat Jul 24 11:11:41 2010 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,240 +0,0 @@
     2.4 -<?php
     2.5 -
     2.6 -// +---------------------------------------------------------------------------+
     2.7 -// | NetTools  Plugin 1.0 for Geeklog - The Ultimate Weblog                    |
     2.8 -// | NetTools  Plugin 2.0 for Geeklog - Updated to phpWhois 4.1.2              |
     2.9 -// +---------------------------------------------------------------------------+
    2.10 -// | install.php                                                               |
    2.11 -// |                                                                           |
    2.12 -// | This file installs and removes the data structures for the                |
    2.13 -// | plugin for Geeklog.                                                       |
    2.14 -// | This is a complete functioning install routine.  All you have to do is    |
    2.15 -// | remove the sample data from the arrays and fill in the $NEWTABLE,         |
    2.16 -// | $DEFVALUES, and $NEWFEATURE arrays with your data.  Then replace all      |
    2.17 -// | occurances of {plugin} with the name of your plugin and you will have a   |
    2.18 -// | functioning install page for your plugin.  Then customize the install     |
    2.19 -// | display language in english.php and you are ready to distribute your      |
    2.20 -// | plugin.                                                                   |
    2.21 -// | Simply put here is what this install does:                                |
    2.22 -// | 1) It creates the tables                                                  |
    2.23 -// | 2) It creates an admin security group for you plugin                      |
    2.24 -// | 3) It adds the security features and adds them to the admin group         |
    2.25 -// | 4) It adds the plugin to the gl_plugins table                             |
    2.26 -// | 5) It adds any default data you have provided                             |
    2.27 -// +---------------------------------------------------------------------------+
    2.28 -// | Copyright (C) 2002 by the following authors:                              |
    2.29 -// |                                                                           |
    2.30 -// | Author:                                                                   |
    2.31 -// | Constructed with the Universal Plugin                                     |
    2.32 -// | Copyright (C) 2002 by the following authors:                              |
    2.33 -// | Tom Willett                 -    twillett@users.sourceforge.net           |
    2.34 -// | Blaine Lang                 -    langmail@sympatico.ca                    |
    2.35 -// | The Universal Plugin is based on prior work by:                           |
    2.36 -// | Tony Bibbs                  -    tony@tonybibbs.com                       |
    2.37 -// +---------------------------------------------------------------------------+
    2.38 -// |                                                                           |
    2.39 -// | This program is free software; you can redistribute it and/or             |
    2.40 -// | modify it under the terms of the GNU General Public License               |
    2.41 -// | as published by the Free Software Foundation; either version 2            |
    2.42 -// | of the License, or (at your option) any later version.                    |
    2.43 -// |                                                                           |
    2.44 -// | This program is distributed in the hope that it will be useful,           |
    2.45 -// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
    2.46 -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
    2.47 -// | GNU General Public License for more details.                              |
    2.48 -// |                                                                           |
    2.49 -// | You should have received a copy of the GNU General Public License         |
    2.50 -// | along with this program; if not, write to the Free Software Foundation,   |
    2.51 -// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
    2.52 -// |                                                                           |
    2.53 -// +---------------------------------------------------------------------------+
    2.54 -//
    2.55 -
    2.56 -require_once('../../../lib-common.php');
    2.57 -require_once($_CONF['path'] . 'plugins/nettools/config.php');
    2.58 -require_once($_CONF['path'] . 'plugins/nettools/functions.inc');
    2.59 -
    2.60 -//
    2.61 -// Universal plugin install variables
    2.62 -// Change these to match your plugin
    2.63 -//
    2.64 -$pi_name = 'nettools';                  // Plugin name  Must be 15 chars or less
    2.65 -$pi_version = '2.0';                    // Plugin Version
    2.66 -$gl_version = '1.4.1';                  // GL Version plugin for
    2.67 -$pi_url = 'http://gplugs.sf.net';      // Plugin Homepage
    2.68 -
    2.69 -//
    2.70 -// $NEWTABLE contains table name(s) and sql to create it(them)
    2.71 -// Fill it in and you are ready to go.
    2.72 -// Note: you must put the table names in the uninstall routine in functions.inc 
    2.73 -// and in the $_TABLES array in config.php.
    2.74 -// Note: Be sure to replace table1, table2 with the actual names of your tables.
    2.75 -// and the table definition with the definition of your table
    2.76 -//
    2.77 -
    2.78 -$NEWTABLE = array();
    2.79 -//
    2.80 -// Default data
    2.81 -// Insert table name and sql to insert default data for your plugin.
    2.82 -//
    2.83 -$DEFVALUES = array();
    2.84 -
    2.85 -// Example default data
    2.86 -
    2.87 -//
    2.88 -// Security Feature to add
    2.89 -// Fill in your security features here
    2.90 -// Note you must add these features to the uninstall routine in function.inc so that they will
    2.91 -// be removed when the uninstall routine runs.
    2.92 -// You do not have to use these particular features.  You can edit/add/delete them
    2.93 -// to fit your plugins security model
    2.94 -//
    2.95 -
    2.96 -$NEWFEATURE = array();
    2.97 -$NEWFEATURE['Whois.view']="Whois Viewer";
    2.98 -$NEWFEATURE['NSLookup.view']="NSLookup Viewer";
    2.99 -$NEWFEATURE['Ping.view']="Ping Viewer";
   2.100 -$NEWFEATURE['Tracert.view']="Tracert Viewer";
   2.101 -
   2.102 -
   2.103 -// Only let Root users access this page
   2.104 -if (!SEC_inGroup('Root')) {
   2.105 -    // Someone is trying to illegally access this page
   2.106 -    COM_errorLog("Someone has tried to illegally access the nettools install/uninstall page.  User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: $REMOTE_ADDR",1);
   2.107 -    $display = COM_siteHeader();
   2.108 -    $display .= COM_startBlock($LANG_NT00['access_denied']);
   2.109 -    $display .= $LANG_NT00['access_denied_msg'];
   2.110 -    $display .= COM_endBlock();
   2.111 -    $display .= COM_siteFooter(true);
   2.112 -    echo $display;
   2.113 -    exit;
   2.114 -}
   2.115 - 
   2.116 -/**
   2.117 -* Puts the datastructures for this plugin into the Geeklog database
   2.118 -*
   2.119 -* Note: Corresponding uninstall routine is in functions.inc
   2.120 -* 
   2.121 -* @return   boolean True if successful False otherwise
   2.122 -*
   2.123 -*/
   2.124 -function plugin_install_nettools()
   2.125 -{
   2.126 -    global $pi_name, $pi_version, $gl_version, $pi_url, $NEWTABLE, $DEFVALUES, $NEWFEATURE;
   2.127 -    global $_TABLES, $_CONF;
   2.128 -
   2.129 -    COM_errorLog("Attempting to install the $pi_name Plugin",1);
   2.130 -
   2.131 -    // Create the Plugins Tables
   2.132 -    
   2.133 -    // Create the plugin admin security group
   2.134 -    COM_errorLog("Attempting to create $pi_name admin group", 1);
   2.135 -    DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr) "
   2.136 -        . "VALUES ('$pi_name Admin', 'Users in this group can administer the $pi_name plugin')",1);
   2.137 -    if (DB_error()) {
   2.138 -        plugin_uninstall_nettools();
   2.139 -        return false;
   2.140 -        exit;
   2.141 -    }
   2.142 -    COM_errorLog('...success',1);
   2.143 -    $group_id = DB_insertId();
   2.144 -    
   2.145 -    // Save the grp id for later uninstall
   2.146 -    COM_errorLog('About to save group_id to vars table for use during uninstall',1);
   2.147 -    DB_query("INSERT INTO {$_TABLES['vars']} VALUES ('{$pi_name}_gid', $group_id)",1);
   2.148 -    if (DB_error()) {
   2.149 -        plugin_uninstall_nettools();
   2.150 -        return false;
   2.151 -        exit;
   2.152 -    }
   2.153 -    COM_errorLog('...success',1);
   2.154 -    
   2.155 -    // Add plugin Features
   2.156 -    foreach ($NEWFEATURE as $feature => $desc) {
   2.157 -        COM_errorLog("Adding $feature feature",1);
   2.158 -        DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr) "
   2.159 -            . "VALUES ('$feature','$desc')",1);
   2.160 -        if (DB_error()) {
   2.161 -            COM_errorLog("Failure adding $feature feature",1);
   2.162 -            plugin_uninstall_nettools();
   2.163 -            return false;
   2.164 -            exit;
   2.165 -        }
   2.166 -        $feat_id = DB_insertId();
   2.167 -        COM_errorLog("Success",1);
   2.168 -        COM_errorLog("Adding $feature feature to admin group",1);
   2.169 -        DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ($feat_id, $group_id)");
   2.170 -        if (DB_error()) {
   2.171 -            COM_errorLog("Failure adding $feature feature to admin group",1);
   2.172 -            plugin_uninstall_nettools();
   2.173 -            return false;
   2.174 -            exit;
   2.175 -        }
   2.176 -        COM_errorLog("Success",1);
   2.177 -    }        
   2.178 -    
   2.179 -    // OK, now give Root users access to this plugin now! NOTE: Root group should always be 1
   2.180 -    COM_errorLog("Attempting to give all users in Root group access to $pi_name admin group",1);
   2.181 -    DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES ($group_id, NULL, 1)");
   2.182 -    if (DB_error()) {
   2.183 -        plugin_uninstall_nettools();
   2.184 -        return false;
   2.185 -        exit;
   2.186 -    }
   2.187 -
   2.188 -    // Register the plugin with Geeklog
   2.189 -    COM_errorLog("Registering $pi_name plugin with Geeklog", 1);
   2.190 -    DB_delete($_TABLES['plugins'],'pi_name','nettools');
   2.191 -    DB_query("INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_homepage, pi_enabled) "
   2.192 -        . "VALUES ('$pi_name', '$pi_version', '$gl_version', '$pi_url', 1)");
   2.193 -
   2.194 -    if (DB_error()) {
   2.195 -        plugin_uninstall_nettools();
   2.196 -        return false;
   2.197 -        exit;
   2.198 -    }
   2.199 -
   2.200 -    COM_errorLog("Succesfully installed the $pi_name Plugin!",1);
   2.201 -    return true;
   2.202 -}
   2.203 -
   2.204 -/* 
   2.205 -* Main Function
   2.206 -*/
   2.207 -
   2.208 -$display = COM_siteHeader();
   2.209 -$T = new Template($_CONF['path'] . 'plugins/nettools/templates');
   2.210 -$T->set_file('install', 'install.thtml');
   2.211 -$T->set_var('install_header', $LANG_NT00['install_header']);
   2.212 -$T->set_var('img',$_CONF['site_url'] . '/nettools/net.gif');
   2.213 -$T->set_var('cgiurl', $_CONF['site_admin_url'] . '/plugins/nettools/install.php');
   2.214 -$T->set_var('admin_url', $_CONF['site_url'] . '/nettools/nettools.php');
   2.215 -
   2.216 -if ($action == 'install') {
   2.217 -    if (plugin_install_nettools()) {
   2.218 -        $T->set_var('installmsg1',$LANG_NT00['install_success']);
   2.219 -    } else {
   2.220 -        $T->set_var('installmsg1',$LANG_NT00['install_failed']);
   2.221 -    }
   2.222 -} else if ($action == "uninstall") {
   2.223 -   plugin_uninstall_nettools('installed');
   2.224 -   $T->set_var('installmsg1',$LANG_NT00['uninstall_msg']);
   2.225 -}
   2.226 -
   2.227 -if (DB_count($_TABLES['plugins'], 'pi_name', 'nettools') == 0) {
   2.228 -    $T->set_var('installmsg2', $LANG_NT00['uninstalled']);
   2.229 -    $T->set_var('readme', $LANG_NT00['readme']);
   2.230 -    $T->set_var('installdoc', $LANG_NT00['installdoc']);
   2.231 -	$T->set_var('btnmsg', $LANG_NT00['install']);
   2.232 -	$T->set_var('action','install');
   2.233 -} else {
   2.234 -    $T->set_var('installmsg2', $LANG_NT00['installed']);
   2.235 -	$T->set_var('btnmsg', $LANG_NT00['uninstall']);
   2.236 -	$T->set_var('action','uninstall');
   2.237 -}
   2.238 -$T->parse('output','install');
   2.239 -$display .= $T->finish($T->get_var('output'));
   2.240 -$display .= COM_siteFooter(true);
   2.241 -echo $display;
   2.242 -
   2.243 -?>
   2.244 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/autoinstall.php	Sat Jul 24 11:13:55 2010 +0200
     3.3 @@ -0,0 +1,91 @@
     3.4 +<?php
     3.5 +
     3.6 +/* Reminder: always indent with 4 spaces (no tabs). */
     3.7 +// +---------------------------------------------------------------------------+
     3.8 +// | NetTools Plugin 2.1                                                       |
     3.9 +// +---------------------------------------------------------------------------+
    3.10 +// | autoinstall.php                                                           |
    3.11 +// |                                                                           |
    3.12 +// | This file provides helper functions for the automatic plugin install.     |
    3.13 +// +---------------------------------------------------------------------------+
    3.14 +// | Copyright (C) 2008-2010 by the following authors:                         |
    3.15 +// |                                                                           |
    3.16 +// | Authors: Dirk Haun         - dirk AT haun-online DOT de                   |
    3.17 +// |          Tom Willett       - twillett AT users DOT sourceforge DOT net    |
    3.18 +// +---------------------------------------------------------------------------+
    3.19 +// |                                                                           |
    3.20 +// | This program is free software; you can redistribute it and/or             |
    3.21 +// | modify it under the terms of the GNU General Public License               |
    3.22 +// | as published by the Free Software Foundation; either version 2            |
    3.23 +// | of the License, or (at your option) any later version.                    |
    3.24 +// |                                                                           |
    3.25 +// | This program is distributed in the hope that it will be useful,           |
    3.26 +// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
    3.27 +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
    3.28 +// | GNU General Public License for more details.                              |
    3.29 +// |                                                                           |
    3.30 +// | You should have received a copy of the GNU General Public License         |
    3.31 +// | along with this program; if not, write to the Free Software Foundation,   |
    3.32 +// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
    3.33 +// |                                                                           |
    3.34 +// +---------------------------------------------------------------------------+
    3.35 +
    3.36 +/**
    3.37 +* Autoinstall API functions for the NetTools plugin
    3.38 +*
    3.39 +* @package NetTools
    3.40 +*/
    3.41 +
    3.42 +/**
    3.43 +* Plugin autoinstall function
    3.44 +*
    3.45 +* @param    string  $pi_name    Plugin name
    3.46 +* @return   array               Plugin information
    3.47 +*
    3.48 +*/
    3.49 +function plugin_autoinstall_nettools($pi_name)
    3.50 +{
    3.51 +    $pi_name         = 'nettools';
    3.52 +    $pi_display_name = 'Nettools';
    3.53 +    $pi_admin        = $pi_display_name . ' Admin';
    3.54 +
    3.55 +    $info = array(
    3.56 +        'pi_name'         => $pi_name,
    3.57 +        'pi_display_name' => $pi_display_name,
    3.58 +        'pi_version'      => '2.1.0',
    3.59 +        'pi_gl_version'   => '1.6.0',
    3.60 +        'pi_homepage'     => 'http://www.geeklog.net/'
    3.61 +    );
    3.62 +
    3.63 +    $groups = array(
    3.64 +        $pi_admin => 'Users in this group can administer the ' . $pi_display_name . ' plugin'
    3.65 +    );
    3.66 +
    3.67 +    $features = array(
    3.68 +        'Whois.view'    => "Whois Viewer",
    3.69 +        'NSLookup.view' => "NSLookup Viewer",
    3.70 +        'Ping.view'     => "Ping Viewer",
    3.71 +        'Tracert.view'  => "Tracert Viewer"
    3.72 +    );
    3.73 +
    3.74 +    $mappings = array(
    3.75 +        'Whois.view'    => array($pi_admin),
    3.76 +        'NSLookup.view' => array($pi_admin),
    3.77 +        'Ping.view'     => array($pi_admin),
    3.78 +        'Tracert.view'  => array($pi_admin)
    3.79 +    );
    3.80 +
    3.81 +    $tables = array(
    3.82 +    );
    3.83 +
    3.84 +    $inst_parms = array(
    3.85 +        'info'      => $info,
    3.86 +        'groups'    => $groups,
    3.87 +        'features'  => $features,
    3.88 +        'mappings'  => $mappings
    3.89 +    );
    3.90 +
    3.91 +    return $inst_parms;
    3.92 +}
    3.93 +
    3.94 +?>