where('plugin',$_SERVER['argv']['1'])->update(['state'=>0]); break; case 'enable': default: $classname = "\\{$_SERVER['argv']['1']}"; $pluginController = new $classname; $handler = new \PluginHandler("{$_SERVER['argv']['1']}", "server'"); # Determine if plugin was previously enabled with db tables created and config $wasSqlInstalled = \DB::table('plugins')->where('plugin',$_SERVER['argv']['1'])->first(); # Enable Plugin echo "Enabling plugin\n"; DB::table('plugins')->updateOrInsert(['plugin' => "{$_SERVER['argv']['1']}"], ['state'=>1]); # Save Plugin Configuration if ( !$wasSqlInstalled ){ echo "Creating default configuration\n"; $handler->config_save( collect($pluginController->configuration()) ->transform(function ($value, $key) { return is_array($value) ? $value[0] : $value; })->toArray() ); # Install Plugin SQLDATA echo "Creating SQL records\n"; $_POST['db_prefix'] = $db_prefix; $MySQL = []; require_once(BASE . "system/plugins/server/{$_SERVER['argv']['1']}/sqldata.php"); $count = count($MySQL); // Count Queries for ($i = 0; $i < $count; $i++) { if (!mysql_query($MySQL[$i])) { echo "ERROR: " . mysql_error() . "\n"; } } } break; } echo "Completed\n";