From: Chuck Scott Date: Wed, 16 Oct 2019 13:24:48 +0000 (-0400) Subject: Updating code formatting to be compiant with specification. X-Git-Tag: v4.2.0^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=421db320f4970e382ddcb44e2a730bf059617c7f;p=WP-Plugins%2Fglm-serverstats.git Updating code formatting to be compiant with specification. --- diff --git a/index.php b/index.php index ff62f01..5f2240e 100755 --- a/index.php +++ b/index.php @@ -24,14 +24,14 @@ namespace GLMServerStats; */ // Check that we're being called by WordPress. -if (!defined('ABSPATH')) { - header("Location: http://".$_SERVER['SERVER_NAME']."/error/404.html"); +if ( !defined( 'ABSPATH' ) ) { + header( "Location: http://" . $_SERVER['SERVER_NAME'] . "/error/404.html" ); die(); } -define('GLM_SERVERSTATS_PLUGIN_VERSION', '4.1.8'); +define( 'GLM_SERVERSTATS_PLUGIN_VERSION', '4.1.8' ); -define('GLM_SERVERSTATS_PLUGIN_DB_VERSION', '0.0.1'); +define( 'GLM_SERVERSTATS_PLUGIN_DB_VERSION', '0.0.1' ); // Required to be able to get user capabilities when being called as a filter from the main plugin require_once ABSPATH . 'wp-includes/pluggable.php'; @@ -41,7 +41,7 @@ include_once ABSPATH . 'wp-admin/includes/plugin.php'; require_once 'defines.php'; -require_once GLM_SERVERSTATS_PLUGIN_LIB_PATH.'/smartyTemplateSupport.php'; +require_once GLM_SERVERSTATS_PLUGIN_LIB_PATH . '/smartyTemplateSupport.php'; // Grab the database class require_once GLM_SERVERSTATS_PLUGIN_PATH . '/classes/GlmServerStats.php'; @@ -50,18 +50,18 @@ $serverStatsDb = new GlmServerStats( $wpdb ); // Connect to bandwidth database and get all settings for this site $bwdb = false; -$websiteSettings = bandwidthDataConnect(GLM_SERVERSTATS_PLUGIN_HOSTNAME); +$websiteSettings = bandwidthDataConnect( GLM_SERVERSTATS_PLUGIN_HOSTNAME ); // If this is an admin request -if (is_admin()) { - add_action('admin_menu', function() { - require_once GLM_SERVERSTATS_PLUGIN_PATH.'/setup/adminMenus.php'; - }); +if ( is_admin() ) { + add_action( 'admin_menu', function () { + require_once GLM_SERVERSTATS_PLUGIN_PATH . '/setup/adminMenus.php'; + } ); require_once GLM_SERVERSTATS_PLUGIN_PATH . '/setup/adminHooks.php'; } // If setup/commonHooks.php exists include that now -$commonFile = GLM_SERVERSTATS_PLUGIN_PATH.'/setup/commonHooks.php'; +$commonFile = GLM_SERVERSTATS_PLUGIN_PATH . '/setup/commonHooks.php'; if ( is_file( $commonFile ) ) { require_once $commonFile; } @@ -69,91 +69,68 @@ if ( is_file( $commonFile ) ) { /* * Setup AJAX */ -add_action( 'wp_ajax_glm_server_stats', '\GLMServerStats\glmServerStatsAjax'); +add_action( 'wp_ajax_glm_server_stats', '\GLMServerStats\glmServerStatsAjax' ); /* * * Load CSS and Scripts * */ +function glmServerJqueryScipts() { -function glmServerJqueryScipts() -{ // jQuery scripts - wp_enqueue_script('jquery', false, array(), false, true); - wp_enqueue_script('jquery-style', false, array(), false, true); - wp_enqueue_script('jquery-ui-core', false, array(), false, true); - wp_enqueue_script('jquery-ui-widget', false, array(), false, true); - wp_enqueue_script('jquery-ui-dialog', false, array(), false, true); -} + wp_enqueue_script( 'jquery', false, array(), false, true ); + wp_enqueue_script( 'jquery-style', false, array(), false, true ); + wp_enqueue_script( 'jquery-ui-core', false, array(), false, true ); + wp_enqueue_script( 'jquery-ui-widget', false, array(), false, true ); + wp_enqueue_script( 'jquery-ui-dialog', false, array(), false, true ); -function glmServerStatsScripts() -{ +} +function glmServerStatsScripts() { // jQuery scripts - wp_enqueue_script('jquery', false, array(), false, true); - wp_enqueue_script('jquery-style', false, array(), false, true); - wp_enqueue_script('jquery-ui-core', false, array(), false, true); - wp_enqueue_script('jquery-ui-widget', false, array(), false, true); - wp_enqueue_script('jquery-ui-dialog', false, array(), false, true); - - wp_register_style( - 'glm-usage-admin-styles', - GLM_SERVERSTATS_PLUGIN_URL . 'css/admin.css', - array(), - GLM_SERVERSTATS_PLUGIN_VERSION - ); - wp_enqueue_style('glm-usage-admin-styles'); - - wp_enqueue_script( - 'glm-usage-foundation6-js', - GLM_SERVERSTATS_PLUGIN_URL.'js/foundation-6.min.js', - array('jquery'), - GLM_SERVERSTATS_PLUGIN_VERSION, - true - ); - wp_register_style( - 'glm-usage-foundation6-css', - GLM_SERVERSTATS_PLUGIN_URL . 'css/foundation-6.min.css', - array(), - GLM_SERVERSTATS_PLUGIN_VERSION - ); - wp_enqueue_style('glm-usage-foundation6-css'); - - wp_enqueue_style('jquery-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'); -// wp_enqueue_style('glm-server-stats-admin-css', GLM_SERVERSTATS_PLUGIN_CSS_URL.'/admin.css'); + wp_enqueue_script( 'jquery', false, array(), false, true ); + wp_enqueue_script( 'jquery-style', false, array(), false, true ); + wp_enqueue_script( 'jquery-ui-core', false, array(), false, true ); + wp_enqueue_script( 'jquery-ui-widget', false, array(), false, true ); + wp_enqueue_script( 'jquery-ui-dialog', false, array(), false, true ); + + wp_register_style( 'glm-usage-admin-styles', GLM_SERVERSTATS_PLUGIN_URL . 'css/admin.css', array(), + GLM_SERVERSTATS_PLUGIN_VERSION ); + wp_enqueue_style( 'glm-usage-admin-styles' ); + + wp_enqueue_script( 'glm-usage-foundation6-js', GLM_SERVERSTATS_PLUGIN_URL . 'js/foundation-6.min.js', + array( + 'jquery' + ), GLM_SERVERSTATS_PLUGIN_VERSION, true ); + wp_register_style( 'glm-usage-foundation6-css', GLM_SERVERSTATS_PLUGIN_URL . 'css/foundation-6.min.css', array(), + GLM_SERVERSTATS_PLUGIN_VERSION ); + wp_enqueue_style( 'glm-usage-foundation6-css' ); + + wp_enqueue_style( 'jquery-style', + 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css' ); + // wp_enqueue_style('glm-server-stats-admin-css', GLM_SERVERSTATS_PLUGIN_CSS_URL.'/admin.css'); // Jquery DatePicker - wp_enqueue_script('jquery-ui-datepicker'); - wp_enqueue_style('jquery-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'); + wp_enqueue_script( 'jquery-ui-datepicker' ); + wp_enqueue_style( 'jquery-style', + 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css' ); // Register and enqueue DateTimePicker - wp_enqueue_script( - 'glm-serverstats-admin-datetimepicker', - GLM_SERVERSTATS_PLUGIN_URL . 'js/datetimepicker/build/jquery.datetimepicker.full.min.js', - array( - 'jquery' - ), - GLM_SERVERSTATS_PLUGIN_VERSION - ); - wp_register_style( - 'glm-serverstats-admin-datetimepicker-css', - GLM_SERVERSTATS_PLUGIN_URL . 'js/datetimepicker/jquery.datetimepicker.css', - false, - GLM_SERVERSTATS_PLUGIN_VERSION - ); - wp_enqueue_style('glm-serverstats-admin-datetimepicker-css'); - wp_register_style( - 'glm-serverstats-admin-responsive-card-table-css', - GLM_SERVERSTATS_PLUGIN_URL . 'css/responsive-card-table.css', - false, - GLM_SERVERSTATS_PLUGIN_VERSION - ); - wp_enqueue_style('glm-serverstats-admin-responsive-card-table-css'); + wp_enqueue_script( 'glm-serverstats-admin-datetimepicker', + GLM_SERVERSTATS_PLUGIN_URL . 'js/datetimepicker/build/jquery.datetimepicker.full.min.js', array( + 'jquery' + ), GLM_SERVERSTATS_PLUGIN_VERSION ); + wp_register_style( 'glm-serverstats-admin-datetimepicker-css', + GLM_SERVERSTATS_PLUGIN_URL . 'js/datetimepicker/jquery.datetimepicker.css', false, + GLM_SERVERSTATS_PLUGIN_VERSION ); + wp_enqueue_style( 'glm-serverstats-admin-datetimepicker-css' ); + wp_register_style( 'glm-serverstats-admin-responsive-card-table-css', + GLM_SERVERSTATS_PLUGIN_URL . 'css/responsive-card-table.css', false, GLM_SERVERSTATS_PLUGIN_VERSION ); + wp_enqueue_style( 'glm-serverstats-admin-responsive-card-table-css' ); } - /* * Setup Cookie Notice Pop-Up * Shows the pop-up. When the user clicks "Got it!" then sets a cookie to not show it again for some @@ -164,23 +141,25 @@ function glmServerStatsScripts() */ // If this is an admin request and the cookie pop-ups have been enabled - Popup test in scripting on page -if ( ( !empty( $_REQUEST['force_cookie'] ) || $websiteSettings['show_cookie_popup'] ) && !is_admin() ) { +if ( (!empty( $_REQUEST['force_cookie'] ) || $websiteSettings['show_cookie_popup']) && !is_admin() ) { // Make sure that the jQuery scripts are included function enqueueJquery() { + glmServerJqueryScipts(); + } add_action( 'wp_enqueue_scripts', '\GLMServerStats\enqueueJquery' ); // Have WordPress include the cookie pop-up code just before the footer. function doCookiePopUp() { - include GLM_SERVERSTATS_PLUGIN_MODEL_PATH.'/frontCookiePopUp.php'; + + include GLM_SERVERSTATS_PLUGIN_MODEL_PATH . '/frontCookiePopUp.php'; + } add_action( 'wp_footer', '\GlmServerStats\doCookiePopUp' ); - } - /** * Admin Ajax Target * @@ -191,19 +170,19 @@ if ( ( !empty( $_REQUEST['force_cookie'] ) || $websiteSettings['show_cookie_popu * * @return void */ -function glmServerStatsAjax() -{ +function glmServerStatsAjax() { + $glmAjaxActionCalled = true; $glmAction = false; // Get the requested model - if (isset($_REQUEST['glm_action']) && $_REQUEST['glm_action'] != '') { - $glmAction = sanitize_text_field($_REQUEST['glm_action']); + if ( isset( $_REQUEST['glm_action'] ) && $_REQUEST['glm_action'] != '' ) { + $glmAction = sanitize_text_field( $_REQUEST['glm_action'] ); } // Call controller to handle AJAX request - Ajax models should not return to controller - if ($glmAction && $glmAction != '') { - serverStatsController($glmAction, true); + if ( $glmAction && $glmAction != '' ) { + serverStatsController( $glmAction, true ); } } @@ -216,18 +195,18 @@ function glmServerStatsAjax() * model and the view. * */ -function serverStatsController( $model, $isAjax = false ) -{ +function serverStatsController( $model, $isAjax = false ) { - $namespaceModel = '\\GLMServerStats\\'.$model; + $namespaceModel = '\\GLMServerStats\\' . $model; if ( GLM_SERVERSTATS_PLUGIN_DEBUG ) { $debugStartTime = microtime( true ); - trigger_error("GLM Usage Controller Start: Model = $model", E_USER_NOTICE ); + trigger_error( "GLM Usage Controller Start: Model = $model", E_USER_NOTICE ); } if ( GLM_SERVERSTATS_PLUGIN_DEBUG && !$isAjax ) { - trigger_error("GLM Usage Plugin Debug Enabled: *** Turn off for production *** - See defines.php", E_USER_NOTICE ); + trigger_error( "GLM Usage Plugin Debug Enabled: *** Turn off for production *** - See defines.php", + E_USER_NOTICE ); } // Enque admin scripts and css here so that only happens when we're doing something @@ -236,14 +215,14 @@ function serverStatsController( $model, $isAjax = false ) // Load and execute the specified model require_once GLM_SERVERSTATS_PLUGIN_MODEL_PATH . '/' . $model . '.php'; - $Model = new $namespaceModel(); + $Model = new $namespaceModel(); $results = $Model->model(); // If there's a redirect request, run that (this controler can only do one level of redirect) - if (isset($results['redirect'])) { + if ( isset( $results['redirect'] ) ) { $model = $results['redirect']; - require_once GLM_SERVERSTATS_PLUGIN_MODEL_PATH.'/'.$model.'.php'; - $Model = new $model(); + require_once GLM_SERVERSTATS_PLUGIN_MODEL_PATH . '/' . $model . '.php'; + $Model = new $model(); $results = $Model->model(); } @@ -255,24 +234,24 @@ function serverStatsController( $model, $isAjax = false ) $smarty = new glmBandwidthStatsSmartyTemplateSupport(); // Add standard template parameters - require GLM_SERVERSTATS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php'; + require GLM_SERVERSTATS_PLUGIN_SETUP_PATH . '/standardTemplateParams.php'; // Add data from model to Smarty template - if (is_array($results['data']) && count($results['data']) > 0) { - foreach ($results['data'] as $k => $d) { - $smarty->templateAssign($k, $d); + if ( is_array( $results['data'] ) && count( $results['data'] ) > 0 ) { + foreach ( $results['data'] as $k=>$d ) { + $smarty->templateAssign( $k, $d ); } } // Update the Smarty view path - *** NEEED TO FIX THIS TO SUPPORT THEME VIEWS SOMEHOW **** - $smarty->template->addTemplateDir(GLM_SERVERSTATS_PLUGIN_VIEW_PATH); + $smarty->template->addTemplateDir( GLM_SERVERSTATS_PLUGIN_VIEW_PATH ); // Generate output from model data and view - $smarty->template->display(GLM_SERVERSTATS_PLUGIN_VIEW_PATH.'/'.$model.'.html'); + $smarty->template->display( GLM_SERVERSTATS_PLUGIN_VIEW_PATH . '/' . $model . '.html' ); - if (GLM_SERVERSTATS_PLUGIN_DEBUG) { - $debugTimeUsed = microtime(true) - $debugStartTime; - trigger_error("GLM Usage Controller End: Time = $debugTimeUsed", E_USER_NOTICE ); + if ( GLM_SERVERSTATS_PLUGIN_DEBUG ) { + $debugTimeUsed = microtime( true ) - $debugStartTime; + trigger_error( "GLM Usage Controller End: Time = $debugTimeUsed", E_USER_NOTICE ); } } @@ -280,38 +259,38 @@ function serverStatsController( $model, $isAjax = false ) /* * Plugin Update Support - uses Gaslight Media update server */ -require_once GLM_SERVERSTATS_PLUGIN_LIB_PATH.'/opentools-update-checker/opentools-update-checker.php'; -${GLM_SERVERSTATS_PLUGIN_PREFIX."updateChecker"} = new OpenToolsPluginUpdateChecker( - GLM_SERVERSTATS_PLUGIN_UPDATE_SERVER.'/?action=get_metadata&slug='.GLM_SERVERSTATS_PLUGIN_SLUG, - __FILE__, - GLM_SERVERSTATS_PLUGIN_SLUG -); -${GLM_SERVERSTATS_PLUGIN_PREFIX."updateChecker"}->declareCredentials(array( - 'license_key' => __('License Key:') -)); +require_once GLM_SERVERSTATS_PLUGIN_LIB_PATH . '/opentools-update-checker/opentools-update-checker.php'; +${GLM_SERVERSTATS_PLUGIN_PREFIX . "updateChecker"} = new OpenToolsPluginUpdateChecker( + GLM_SERVERSTATS_PLUGIN_UPDATE_SERVER . '/?action=get_metadata&slug=' . GLM_SERVERSTATS_PLUGIN_SLUG, __FILE__, + GLM_SERVERSTATS_PLUGIN_SLUG ); +${GLM_SERVERSTATS_PLUGIN_PREFIX . "updateChecker"}->declareCredentials( array( + 'license_key' => __( 'License Key:' ) +) ); /* -* -* Activate and Deactivate hooks -* -*/ + * + * Activate and Deactivate hooks + * + */ // Activate -function glmServerStatsPluginActivate () -{ +function glmServerStatsPluginActivate() { + require_once GLM_SERVERSTATS_PLUGIN_PATH . '/activate.php'; new glmServerStatsPluginActivate(); + } -register_activation_hook(__FILE__, '\GLMServerStats\glmServerStatsPluginActivate'); +register_activation_hook( __FILE__, '\GLMServerStats\glmServerStatsPluginActivate' ); // Deactivate -function glmServerStatsPluginDeactivate () -{ +function glmServerStatsPluginDeactivate() { + require_once GLM_SERVERSTATS_PLUGIN_PATH . '/deactivate.php'; $x = new glmServerStatsPluginDeactivate(); return false; + } -register_deactivation_hook(__FILE__, '\GLMServerStats\glmServerStatsPluginDeactivate'); +register_deactivation_hook( __FILE__, '\GLMServerStats\glmServerStatsPluginDeactivate' ); /* * Check if we should run the target check E-mail process @@ -331,17 +310,17 @@ register_deactivation_hook(__FILE__, '\GLMServerStats\glmServerStatsPluginDeacti // Called by WordPress scheduler as set below function doGlmServerUsageCron() { - trigger_error('GLM Serverstats Cron Called', E_USER_NOTICE); + trigger_error( 'GLM Serverstats Cron Called', E_USER_NOTICE ); - $enabled = get_option(GLM_SERVERSTATS_PLUGIN_SEND_OPTION); - if (!$enabled) { - trigger_error('GLM Serverstats E-Mail Notifications not enabled!', E_USER_NOTICE); + $enabled = get_option( GLM_SERVERSTATS_PLUGIN_SEND_OPTION ); + if ( !$enabled ) { + trigger_error( 'GLM Serverstats E-Mail Notifications not enabled!', E_USER_NOTICE ); return; } // Test if already run this month. - $targetCheckMonth = date('m/Y'); - $targetCheckLast = get_option(GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION.'_LAST_CHECK'); + $targetCheckMonth = date( 'm/Y' ); + $targetCheckLast = get_option( GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION . '_LAST_CHECK' ); /* *** FOR TESTING ONLY *** * Adds a suffix to the date to enable another E-Mail check. @@ -351,22 +330,23 @@ function doGlmServerUsageCron() { */ $targetCheckMonth .= '/53'; - trigger_error("GLM Serverstats Cron Check: If $targetCheckMonth equals $targetCheckLast this has already been run.", E_USER_NOTICE); + trigger_error( + "GLM Serverstats Cron Check: If $targetCheckMonth equals $targetCheckLast this has already been run.", + E_USER_NOTICE ); - if ( $targetCheckMonth != $targetCheckLast) { + if ( $targetCheckMonth != $targetCheckLast ) { - trigger_error('Running Usage E-Mail Notification Process for Month = '.$targetCheckMonth, E_USER_NOTICE); + trigger_error( 'Running Usage E-Mail Notification Process for Month = ' . $targetCheckMonth, E_USER_NOTICE ); - update_option(GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION.'_LAST_CHECK', $targetCheckMonth); + update_option( GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION . '_LAST_CHECK', $targetCheckMonth ); - require_once GLM_SERVERSTATS_PLUGIN_MODEL_PATH.'/serverUsageTargetCheck.php'; + require_once GLM_SERVERSTATS_PLUGIN_MODEL_PATH . '/serverUsageTargetCheck.php'; $ServerUsageTargetCheck = new serverUsageTargetCheck(); $ServerUsageTargetCheck->model(); - } } -add_action('glm_serverstats_notify_cron', '\GLMServerStats\doGlmServerUsageCron'); +add_action( 'glm_serverstats_notify_cron', '\GLMServerStats\doGlmServerUsageCron' ); /* * This code sets up a once per minute cron schedule to use for testing. @@ -382,37 +362,34 @@ add_action('glm_serverstats_notify_cron', '\GLMServerStats\doGlmServerUsageCron' // return $schedules; // } - /* * If this running on the Bandwidth Management site (see defines.php), sets scheduler to call * doGlmServerstatsCron * once per . * */ -if (apply_filters('glm-serverstats-is-provider', false) || true) { +if ( apply_filters( 'glm-serverstats-is-provider', false ) || true ) { // Add a 1 minute schedule option for testing only - For testing only // add_filter( 'cron_schedules', 'cron_add_minute' ); // If there's no current cron for doing this, set it now $cronTimestamp = wp_next_scheduled( 'glm_serverstats_notify_cron' ); - if (!$cronTimestamp) { + if ( !$cronTimestamp ) { wp_schedule_event( time(), 'hourly', 'glm_serverstats_notify_cron' ); // wp_schedule_event( time(), 'minute', 'glm_serverstats_notify_cron' ); // For testing only - } - } /* * Function to connect to bandwidth database and return site specific settings for this site */ -function bandwidthDataConnect($website = false) -{ +function bandwidthDataConnect( $website = false ) { + // Check that we have a good website name - if (empty($website)) { - trigger_error('GLM Usage: bandwidthDataConnect() - No Website name provided!', E_USER_NOTICE); + if ( empty( $website ) ) { + trigger_error( 'GLM Usage: bandwidthDataConnect() - No Website name provided!', E_USER_NOTICE ); return false; } @@ -422,36 +399,32 @@ function bandwidthDataConnect($website = false) $settings = false; - if ($bwdb !== null) { + if ( $bwdb !== null ) { // Set a short timeout - $bwdb->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5); + $bwdb->options( MYSQLI_OPT_CONNECT_TIMEOUT, 5 ); // Connect to MySQL - if ($bwdb->real_connect( - GLM_SERVERSTATS_DATABASE_SERVER, - GLM_SERVERSTATS_DATABASE_USER, - GLM_SERVERSTATS_DATABASE_PASSWORD, - GLM_SERVERSTATS_DATABASE_NAME - )) { - - // Get Website Settings - $settings = bandwidthGetWebsiteSettingsFromName($website); - - if (!$settings) { - trigger_error('GLM Usage: bandwidthDataConnect() - Unable to get Website Settings', E_USER_NOTICE); - return false; - } - - // Unable to connect to database - } else { - $this->connectError = mysqli_connect_error(); - trigger_error('GLM Usage: bandwidthDataConnect() - SQL Connect Error = '.$this->connectError, E_USER_NOTICE); - return false; - } - + if ( $bwdb->real_connect( GLM_SERVERSTATS_DATABASE_SERVER, GLM_SERVERSTATS_DATABASE_USER, + GLM_SERVERSTATS_DATABASE_PASSWORD, GLM_SERVERSTATS_DATABASE_NAME ) ) { + + // Get Website Settings + $settings = bandwidthGetWebsiteSettingsFromName( $website ); + + if ( !$settings ) { + trigger_error( 'GLM Usage: bandwidthDataConnect() - Unable to get Website Settings', E_USER_NOTICE ); + return false; + } + + // Unable to connect to database + } else { + $this->connectError = mysqli_connect_error(); + trigger_error( 'GLM Usage: bandwidthDataConnect() - SQL Connect Error = ' . $this->connectError, + E_USER_NOTICE ); + return false; + } } else { - trigger_error('GLM Usage: bandwidthDataConnect() - Unable to init MySQL!', E_USER_NOTICE); + trigger_error( 'GLM Usage: bandwidthDataConnect() - Unable to init MySQL!', E_USER_NOTICE ); return false; } @@ -462,8 +435,8 @@ function bandwidthDataConnect($website = false) /* * Function to Get Web site settings from Web site name. */ -function bandwidthGetWebsiteSettingsFromName($name) -{ +function bandwidthGetWebsiteSettingsFromName( $name ) { + global $bwdb; $sql = " @@ -471,18 +444,19 @@ function bandwidthGetWebsiteSettingsFromName($name) FROM website WHERE name = '$name' ;"; - $websiteResult = $bwdb->query($sql); - if (!$websiteResult) { - trigger_error("Get website settings failed: " . mysqli_error($bwdb) ); + $websiteResult = $bwdb->query( $sql ); + if ( !$websiteResult ) { + trigger_error( "Get website settings failed: " . mysqli_error( $bwdb ) ); return false; } - $website = mysqli_fetch_assoc($websiteResult); - if (!$website){ - trigger_error("Website '$name' not found."); + $website = mysqli_fetch_assoc( $websiteResult ); + if ( !$website ) { + trigger_error( "Website '$name' not found." ); return false; } return $website; + }