function plugin_install_captcha() { global $pi_name, $pi_version, $gl_version, $pi_url, $NEWTABLE, $DEFVALUES, $NEWFEATURE; global $_TABLES, $_CONF, $LANG_CP00, $_DB_dbms; COM_errorLog("Attempting to install the {$pi_name} Plugin", 1); $_SQL['cp_config'] = "CREATE TABLE {$_TABLES['cp_config']} ( " . " `config_name` varchar(255) NOT NULL default '', " . " `config_value` varchar(255) NOT NULL default '', " . " PRIMARY KEY (`config_name`) " . " );"; $_SQL['cp_sessions'] = "CREATE TABLE {$_TABLES['cp_sessions']} ( " . " `session_id` varchar(40) NOT NULL default '', " . " `cptime` INT(11) NOT NULL default 0, " . " `validation` varchar(40) NOT NULL default '', " . " `counter` TINYINT(4) NOT NULL default 0, " . " PRIMARY KEY (`session_id`) " . " );"; foreach ($_SQL as $table => $sql) { COM_errorLog("Creating {$table} table", 1); DB_query($sql, 1); if (DB_error()) { COM_errorLog("Error Creating {$table} table", 1); plugin_uninstall_captcha(); return false; exit; } COM_errorLog("Success - Created {$table} table", 1); } $SQL_DEFAULTS = "INSERT INTO `{$_TABLES['cp_config']}` (`config_name`, `config_value`) VALUES " . " ('anonymous_only', '1'), " . " ('remoteusers','0'), " . " ('debug', '0'), " . " ('enable_comment', '0'), " . " ('enable_contact', '0'), " . " ('enable_emailstory', '0'), " . " ('enable_forum', '0'), " . " ('enable_registration', '0'), " . " ('enable_story', '0'), " . " ('gfxDriver', '2'), " . " ('gfxFormat', 'jpg'), " . " ('gfxPath', '');"; DB_query($SQL_DEFAULTS, 1); // Register the plugin with Geeklog COM_errorLog("Registering {$pi_name} plugin with Geeklog", 1); DB_delete($_TABLES['plugins'], 'pi_name', 'captcha'); DB_query("INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_homepage, pi_enabled) " . "VALUES ('{$pi_name}', '{$pi_version}', '{$gl_version}', '{$pi_url}', 1)"); if (DB_error()) { COM_errorLog("Failure registering plugin with Geeklog"); plugin_uninstall_captcha(); return false; exit; } // Create initial log entry CAPTCHA_errorLog("CAPTCHA Plugin Successfully Installed"); COM_errorLog("Successfully installed the {$pi_name} Plugin!", 1); return true; }
} /* * Main Function */ if (SEC_checkToken()) { $action = COM_applyFilter($_GET['action']); if ($action == 'install') { if (plugin_install_captcha()) { // Redirects to the plugin editor echo COM_refresh($_CONF['site_admin_url'] . '/plugins.php?msg=44'); exit; } else { echo COM_refresh($_CONF['site_admin_url'] . '/plugins.php?msg=72'); exit; } } else { if ($action == 'uninstall') { if (plugin_uninstall_captcha('installed')) { /** * Redirects to the plugin editor */ echo COM_refresh($_CONF['site_admin_url'] . '/plugins.php?msg=45'); exit; } else { echo COM_refresh($_CONF['site_admin_url'] . '/plugins.php?msg=73'); exit; } } } } echo COM_refresh($_CONF['site_admin_url'] . '/plugins.php');