<?php
-
+namespace GLMServerStats;
/**
* Gaslight Media ServerStats - Stand Alone
* Activate Plugin Tasks
}
} else {
- trigger_error("*** SLUG FOUND ***",E_USER_NOTICE);
+ trigger_error("glm-serverstats: Policy page already exists on activation.",E_USER_NOTICE);
}
}
<?php
+namespace GLMServerStats;
/**
* database.php
*
public function updateCache()
{
// Prevent this from running on activation of this plugin.
- if ( class_exists( 'glmServerStatsPluginActivate' ) ) {
+ if ( class_exists( 'GLMServerStats\glmServerStatsPluginActivate' ) ) {
return false;
}
// If the update transient exists don't get anything from the relay.
<?php
+namespace GLMServerStats;
/**
* Gaslight Media Server Bandwidth - Stand Alone
* Server Bandwidth Support Abstract
<?php
+namespace GLMServerStats;
/**
* Gaslight Media ServerStats - Stand Alone
* Deactivate Plugin Tasks
<?php
+namespace GLMServerStats;
/**
* Gaslight Media ServerStats - Stand Alone
*
<?php
+namespace GLMServerStats;
/**
* Plugin Name: GLM Bandwidth
* Plugin URI: http://www.gaslightmedia.com/
// If this is an admin request
if (is_admin()) {
- add_action('admin_menu', 'configureMenus');
- require_once GLM_SERVERSTATS_PLUGIN_PATH.'/setup/adminHooks.php';
+ add_action('admin_menu', function() {
+ require_once GLM_SERVERSTATS_PLUGIN_PATH.'/setup/adminMenus.php';
+ });
}
// If setup/commonHooks.php exists include that now
require_once $commonFile;
}
-/*
- * Function to configure admin menus
- */
-function configureMenus ()
-{
- require_once GLM_SERVERSTATS_PLUGIN_PATH.'/setup/adminMenus.php';
-}
-
/*
* Setup AJAX
*/
-add_action( 'wp_ajax_glm_server_stats', 'glmServerStatsAjax');
+add_action( 'wp_ajax_glm_server_stats', '\GLMServerStats\glmServerStatsAjax');
/*
*
function enqueueJquery() {
glmServerJqueryScipts();
}
- add_action( 'wp_enqueue_scripts', 'enqueueJquery' );
+ 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';
}
- add_action( 'wp_footer', 'doCookiePopUp' );
+ add_action( 'get_footer', '\GlmServerStats\doCookiePopUp' );
}
function serverStatsController( $model, $isAjax = false )
{
+ $namespaceModel = '\\GLMServerStats\\'.$model;
+
if ( GLM_SERVERSTATS_PLUGIN_DEBUG ) {
$debugStartTime = microtime( true );
trigger_error("GLM Usage Controller Start: Model = $model", E_USER_NOTICE );
// Load and execute the specified model
require_once GLM_SERVERSTATS_PLUGIN_MODEL_PATH . '/' . $model . '.php';
- $Model = new $model();
+ $Model = new $namespaceModel();
$results = $Model->model();
// If there's a redirect request, run that (this controler can only do one level of redirect)
require_once GLM_SERVERSTATS_PLUGIN_PATH . '/activate.php';
new glmServerStatsPluginActivate();
}
-register_activation_hook(__FILE__, 'glmServerStatsPluginActivate');
+register_activation_hook(__FILE__, '\GLMServerStats\glmServerStatsPluginActivate');
// Deactivate
function glmServerStatsPluginDeactivate ()
$x = new glmServerStatsPluginDeactivate();
return false;
}
-register_deactivation_hook(__FILE__, 'glmServerStatsPluginDeactivate');
+register_deactivation_hook(__FILE__, '\GLMServerStats\glmServerStatsPluginDeactivate');
/*
* Check if we should run the target check E-mail process
}
}
-add_action('glm_serverstats_notify_cron', 'doGlmServerUsageCron');
+add_action('glm_serverstats_notify_cron', '\GLMServerStats\doGlmServerUsageCron');
/*
* This code sets up a once per minute cron schedule to use for testing.
<?php
+namespace GLMServerStats;
/**
* OpenTools Plugin Update Checker Library
*
// * http://w-shadow.com/blog/2010/09/02/automatic-updates-for-any-plugin/
// *****************************************************************
-if (!class_exists('OpenToolsPluginUpdateChecker')):
+if (!class_exists('GLMServerStats\OpenToolsPluginUpdateChecker')):
require dirname(__FILE__).'/../plugin-update-checker/plugin-update-checker.php';
<?php
-
-if ( !class_exists('PluginUpdateCheckerPanel_3_1', false) && class_exists('Debug_Bar_Panel', false) ) {
+namespace GLMServerStats;
+if ( !class_exists('GLMServerStats\PluginUpdateCheckerPanel_3_1', false) && class_exists('GLMServerStats\Debug_Bar_Panel', false) ) {
/**
* A Debug Bar panel for the plugin update checker.
<?php
-if ( !class_exists('PucDebugBarPlugin_3_1', false) ) {
+namespace GLMServerStats;
+if ( !class_exists('GLMServerStats\PucDebugBarPlugin_3_1', false) ) {
class PucDebugBarPlugin_3_1 {
/** @var PluginUpdateChecker_3_1 */
*/
public function addDebugBarPanel($panels) {
require_once dirname(__FILE__) . '/debug-bar-panel.php';
- if ( current_user_can('update_plugins') && class_exists('PluginUpdateCheckerPanel_3_1', false) ) {
+ if ( current_user_can('update_plugins') && class_exists('GLMServerStats\PluginUpdateCheckerPanel_3_1', false) ) {
$panels[] = new PluginUpdateCheckerPanel_3_1($this->updateChecker);
}
return $panels;
<?php\r
-\r
-if ( !class_exists('PucGitHubChecker_3_1', false) ):\r
+namespace GLMServerStats;\r
+if ( !class_exists('GLMServerStats\PucGitHubChecker_3_1', false) ):\r
\r
class PucGitHubChecker_3_1 extends PluginUpdateChecker_3_1 {\r
/**\r
* @return string\r
*/\r
protected function parseMarkdown($markdown) {\r
- if ( !class_exists('Parsedown', false) ) {\r
+ if ( !class_exists('GLMServerStats\Parsedown', false) ) {\r
require_once(dirname(__FILE__) . '/vendor/Parsedown' . (version_compare(PHP_VERSION, '5.3.0', '>=') ? '' : 'Legacy') . '.php');\r
}\r
\r
}\r
\r
protected function parseReadme($content) {\r
- if ( !class_exists('PucReadmeParser', false) ) {\r
+ if ( !class_exists('GLMServerStats\PucReadmeParser', false) ) {\r
require_once(dirname(__FILE__) . '/vendor/readme-parser.php');\r
}\r
$parser = new PucReadmeParser();\r
<?php\r
+namespace GLMServerStats;\r
/**\r
* Plugin Update Checker Library 3.1\r
* http://w-shadow.com/\r
* Released under the MIT license. See license.txt for details.\r
*/\r
\r
-if ( !class_exists('PluginUpdateChecker_3_1', false) ):\r
+if ( !class_exists('GLMServerStats\PluginUpdateChecker_3_1', false) ):\r
\r
/**\r
* A custom plugin update checker.\r
\r
$state = $this->getUpdateState();\r
if ( empty($state) ){\r
- $state = new stdClass;\r
+ $state = new \stdClass;\r
$state->lastCheck = 0;\r
$state->checkedVersion = '';\r
$state->update = null;\r
*/\r
private function addUpdateToList($updates, $updateToAdd) {\r
if ( !is_object($updates) ) {\r
- $updates = new stdClass();\r
+ $updates = new \stdClass();\r
$updates->response = array();\r
}\r
\r
\r
//Being defensive.\r
if ( !is_object($updates) ) {\r
- $updates = new stdClass();\r
+ $updates = new \stdClass();\r
}\r
if ( !isset($updates->translations) ) {\r
$updates->translations = array();\r
*/\r
public function initDebugBarPanel() {\r
$debugBarPlugin = dirname(__FILE__) . '/debug-bar-plugin.php';\r
- if ( class_exists('Debug_Bar', false) && file_exists($debugBarPlugin) ) {\r
+ if ( class_exists('GLMServerStats\Debug_Bar', false) && file_exists($debugBarPlugin) ) {\r
/** @noinspection PhpIncludeInspection */\r
require_once $debugBarPlugin;\r
$this->debugBarPlugin = new PucDebugBarPlugin_3_1($this);\r
\r
endif;\r
\r
-if ( !class_exists('PluginInfo_3_1', false) ):\r
+if ( !class_exists('GLMServerStats\PluginInfo_3_1', false) ):\r
\r
/**\r
* A container class for holding and transforming various plugin metadata.\r
* @return object\r
*/\r
public function toWpFormat(){\r
- $info = new stdClass;\r
+ $info = new \stdClass;\r
\r
//The custom update API is built so that many fields have the same name and format\r
//as those returned by the native WordPress.org API. These can be assigned directly.\r
\r
endif;\r
\r
-if ( !class_exists('PluginUpdate_3_1', false) ):\r
+if ( !class_exists('GLMServerStats\PluginUpdate_3_1', false) ):\r
\r
/**\r
* A simple container class for holding information about an available update.\r
* @return StdClass\r
*/\r
public function toStdClass() {\r
- $object = new stdClass();\r
+ $object = new \stdClass();\r
$fields = self::$fields;\r
if ( !empty($this->slug) ) {\r
$fields = apply_filters('puc_retain_fields-' . $this->slug, $fields);\r
* @return object\r
*/\r
public function toWpFormat(){\r
- $update = new stdClass;\r
+ $update = new \stdClass;\r
\r
$update->id = $this->id;\r
$update->slug = $this->slug;\r
\r
endif;\r
\r
-if ( !class_exists('PucScheduler_3_1', false) ):\r
+if ( !class_exists('GLMServerStats\PucScheduler_3_1', false) ):\r
\r
/**\r
* The scheduler decides when and how often to check for updates.\r
endif;\r
\r
\r
-if ( !class_exists('PucUpgraderStatus_3_1', false) ):\r
+if ( !class_exists('GLMServerStats\PucUpgraderStatus_3_1', false) ):\r
\r
/**\r
* A utility class that helps figure out which plugin WordPress is upgrading.\r
endif;\r
\r
\r
-if ( !class_exists('PucFactory', false) ):\r
+if ( !class_exists('GLMServerStats\GLMServerStats\PucFactory', false) ):\r
\r
/**\r
* A factory that builds instances of other classes from this library.\r
$text = call_user_func( array( __CLASS__, 'code_trick' ), $text, $markdown ); // A better parser than Markdown's for: backticks -> CODE
if ( $markdown ) { // Parse markdown.
- if ( !class_exists('Parsedown', false) ) {
+ if ( !class_exists('GLMServerStats\Parsedown', false) ) {
require_once(dirname(__FILE__) . '/Parsedown' . (version_compare(PHP_VERSION, '5.3.0', '>=') ? '' : 'Legacy') . '.php');
}
$instance = Parsedown::instance();
);
$text = balanceTags($text);
-
+
$text = wp_kses( $text, $allowed );
$text = trim($text);
return $text;
<?php
-
+namespace GLMServerStats;
/**
* Gaslight Media - GLM Bandwidth
* Smarty Templates Support Class
/*
* Load and instatiate Smarty Templates
*/
- require_once GLM_SERVERSTATS_PLUGIN_PATH.'/lib/smarty-3.1.33/libs/SmartyBC.class.php';
- $this->template = new SmartyBC ();
+ if ( !class_exists( '\SmartyBC' ) ) {
+ require_once GLM_SERVERSTATS_PLUGIN_PATH.'/lib/smarty-3.1.33/libs/SmartyBC.class.php';
+ }
+ $this->template = new \SmartyBC ();
/*
* Configure Smarty Templates for this site
<?php
+namespace GLMServerStats;
/**
* Gaslight Media - GLM Bandwidth
*
<?php
+namespace GLMServerStats;
/**
* Gaslight Media = GLM Bandwidth
* Send Usage Report(s)
<?php
+namespace GLMServerStats;
/**
* Gaslight Media = GLM Bandwidth
* Server Bandwidth Stats by AJAX
}
// Load PHPGraphLib
- require_once GLM_SERVERSTATS_PLUGIN_LIB_PATH.'/phpgraphlib-master/phpgraphlib.php';
+ if ( !class_exists( '\PHPGraphLib' ) ) {
+ require_once GLM_SERVERSTATS_PLUGIN_LIB_PATH.'/phpgraphlib-master/phpgraphlib.php';
+ }
// Create graph object and set parameters
- $graph = new PHPGraphLib(1200,300);
+ $graph = new \PHPGraphLib(1200,300);
$graph->setXValues(true);
$graph->setYValues(true);
$graph->setMinMaxY(1); // Set minimum top value to Y axis
<?php
+namespace GLMServerStats;
// Get Configuration for Cookie info popup
$bwdb = mysqli_init();
<?php
+namespace GLMServerStats;
/**
* Gaslight Media Server Bandwidth - Stand Alone
* Server Bandwidth Support Abstract
<?php
+namespace GLMServerStats;
/**
* Gaslight Media - GLM Bandwidth
* Server Bandwidth Stats Target Check Class
<?php
+namespace GLMServerStats;
/**
* Gaslight Media Members Database
* GLM Members Misc Admin Hooks and Filters
<?php
+namespace GLMServerStats;
/**
* Gaslight Media - GLM Bandwidth
*
global $websiteSettings;
// If show usage is enabled from main site or if administrator, show usage menu
- if( $websiteSettings['show_usage'] || current_user_can('administrator') )
- add_menu_page(
- "GLM Data Usage",
- 'GLM Data Usage',
- 'edit_pages',
- 'glm-server-stats-main-menu',
- function() {
- serverStatsController('adminServerStats');
- },
- GLM_SERVERSTATS_PLUGIN_ASSETS_URL.'/flame.png',
- '3.100'
- );
+ if( $websiteSettings['show_usage'] || current_user_can('administrator') ) {
+ add_menu_page(
+ "GLM Data Usage",
+ 'GLM Data Usage',
+ 'edit_pages',
+ 'glm-server-stats-main-menu',
+ function() {
+ serverStatsController('adminServerStats');
+ },
+ GLM_SERVERSTATS_PLUGIN_ASSETS_URL.'/flame.png',
+ '3.100'
+ );
+ }
add_menu_page(
'GLM Notifications',
<?php
+namespace GLMServerStats;
/**
* Gaslight Media Members Database
* GLM Members Misc Common Hooks and Filters
/*
* Shortcode to output contact information for the bottom of the cookie and policy page created by this plugin.
*/
-function policy_contact_shortcode( $atts ){
+add_shortcode( 'policy_contact', function($atts) {
global $websiteSettings;
return
- (!empty($websiteSettings['contact_name'])?$websiteSettings['contact_name']."<br>":'')
- .(!empty($websiteSettings['contact_org'])?$websiteSettings['contact_org']."<br>":'')
- .(!empty($websiteSettings['contact_address'])?$websiteSettings['contact_address']."<br>":'')
- .(!empty($websiteSettings['contact_address2'])?$websiteSettings['contact_address2']."<br>":'')
- .(!empty($websiteSettings['contact_city'])?$websiteSettings['contact_city']:'')
- .(!empty($websiteSettings['contact_state'])?", ".$websiteSettings['contact_state']:'')
- .(!empty($websiteSettings['contact_zip'])?" ".$websiteSettings['contact_zip']:'')
- .(!empty($websiteSettings['contact_city'])||!empty($websiteSettings['contact_state'])||!empty($websiteSettings['contact_zip'])?"<br>":'')
- .(!empty($websiteSettings['contact_phone'])?"<br>Phone: ".$websiteSettings['contact_phone']:'')
- .(!empty($websiteSettings['contact_email'])?"<br>E-Mail: ".$websiteSettings['contact_email']:'');
-}
-add_shortcode( 'policy_contact', 'policy_contact_shortcode' );
+ (!empty($websiteSettings['contact_name'])?$websiteSettings['contact_name']."<br>":'')
+ .(!empty($websiteSettings['contact_org'])?$websiteSettings['contact_org']."<br>":'')
+ .(!empty($websiteSettings['contact_address'])?$websiteSettings['contact_address']."<br>":'')
+ .(!empty($websiteSettings['contact_address2'])?$websiteSettings['contact_address2']."<br>":'')
+ .(!empty($websiteSettings['contact_city'])?$websiteSettings['contact_city']:'')
+ .(!empty($websiteSettings['contact_state'])?", ".$websiteSettings['contact_state']:'')
+ .(!empty($websiteSettings['contact_zip'])?" ".$websiteSettings['contact_zip']:'')
+ .(!empty($websiteSettings['contact_city'])||!empty($websiteSettings['contact_state'])||!empty($websiteSettings['contact_zip'])?"<br>":'')
+ .(!empty($websiteSettings['contact_phone'])?"<br>Phone: ".$websiteSettings['contact_phone']:'')
+ .(!empty($websiteSettings['contact_email'])?"<br>E-Mail: ".$websiteSettings['contact_email']:'');
+});
<?php
+namespace GLMServerStats;
/**
* Gaslight Media - GLM Bandwidth
* Standard Template Parameters
<?php
-
+namespace GLMServerStats;
die('uninstall not configured - See plugin uninstall.php script!');
/**