public function updates() { if (!isset($_POST['resetlog'])) { return; } ShoppErrorLogging()->reset(); $this->notice(Shopp::__('The log file has been reset.')); }
/** * Defines the Shopp pages used to create WordPress menus * * @since 1.3 * * @return void **/ private function __construct() { // Orders menu $this->add('orders', Shopp::__('All Orders'), 'ShoppAdminOrders'); $this->add('customers', Shopp::__('Customers'), 'ShoppAdminCustomers'); $this->add('reports', Shopp::__('Reports'), 'ShoppAdminReports'); $this->add('settings', Shopp::__('Settings'), 'ShoppAdminSettings'); // Settings pages $this->add('settings-core', Shopp::__('Setup'), 'ShoppAdminSettings', 'settings', 'shoppui-th-list'); $this->add('settings-shipping', Shopp::__('Shipping Rates'), 'ShoppAdminSettings', 'settings', 'shoppui-map-marker'); $this->add('settings-boxes', Shopp::__('Shipment Boxes'), 'ShoppAdminSettings', 'settings', 'shoppui-archive'); $this->add('settings-downloads', Shopp::__('Downloads'), 'ShoppAdminSettings', 'settings', 'shoppui-download'); $this->add('settings-orders', Shopp::__('Orders'), 'ShoppAdminSettings', 'settings', 'shoppui-flag'); $this->add('settings-payments', Shopp::__('Payments'), 'ShoppAdminSettings', 'settings', 'shoppui-credit'); $this->add('settings-taxes', Shopp::__('Taxes'), 'ShoppAdminSettings', 'settings', 'shoppui-money'); $this->add('settings-presentation', Shopp::__('Presentation'), 'ShoppAdminSettings', 'settings', 'shoppui-th-large'); $this->add('settings-pages', Shopp::__('Pages'), 'ShoppAdminSettings', 'settings', 'shoppui-file'); $this->add('settings-images', Shopp::__('Images'), 'ShoppAdminSettings', 'settings', 'shoppui-picture'); $this->add('settings-storage', Shopp::__('Storage'), 'ShoppAdminSettings', 'settings', 'shoppui-cloud'); $this->add('settings-advanced', Shopp::__('Advanced'), 'ShoppAdminSettings', 'settings', 'shoppui-cog'); if (ShoppErrorLogging()->size() > 0) { $this->add('settings-log', Shopp::__('Log'), 'ShoppAdminSettings', 'settings', 'shoppui-info-2'); } // Catalog menu $this->add('products', Shopp::__('Products'), 'ShoppAdminProducts', 'products'); $this->add('categories', Shopp::__('Categories'), 'ShoppAdminCategories', 'products'); // Add Shopp taxonomies and custom Shopp taxonomies to menus $taxonomies = get_object_taxonomies(ShoppProduct::$posttype, 'object'); foreach ($taxonomies as $t) { if ('shopp_category' == $t->name) { continue; } $pagehook = str_replace('shopp_', '', $t->name); $this->add($pagehook, $t->labels->menu_name, 'ShoppAdminCategories', 'products'); } $this->add('discounts', Shopp::__('Discounts'), 'ShoppAdminDiscounts', 'products'); // Adds extra screens $this->add('welcome', Shopp::__('Welcome'), 'ShoppAdminWelcome', 'welcome'); $this->add('credits', Shopp::__('Credits'), 'ShoppAdminWelcome', 'credits'); // Filter hook for adding/modifying Shopp page definitions $this->pages = apply_filters('shopp_admin_pages', $this->pages); $this->caps = apply_filters('shopp_admin_caps', $this->caps); reset($this->pages); $this->mainmenu = key($this->pages); add_action('admin_menu', array($this, 'taxonomies'), 100); shopp_enqueue_style('menus'); // Set the currently requested page and menu $page = ShoppFlow()->request('page'); if (self::posteditor()) { $page = 'shopp-products'; } if (empty($page)) { return; } if (isset($this->pages[$page])) { $this->Page = $this->pages[$page]; } if (isset($this->menus[$page])) { $this->menu = $this->menus[$page]; } }
<?php shopp_admin_screen_tabs(); do_action('shopp_admin_notices'); $logurl = wp_nonce_url(add_query_arg('action', 'shopp_debuglog', admin_url('admin-ajax.php')), 'wp_ajax_shopp_debuglog') . '#bottom'; ?> <form name="settings" id="system" action="<?php echo esc_url($this->url); ?> " method="post"> <?php wp_nonce_field('shopp-system-log'); ?> <?php if (count(ShoppErrorLogging()->tail(2)) > 1) { ?> <iframe id="logviewer" src="<?php echo esc_url($logurl); ?> "> <p>Loading log file...</p> </iframe> <p class="alignright"><a href="<?php echo esc_url($logurl); ?> " class="button" target="_blank"><?php Shopp::_e('Open in New Window'); ?> </a> <button name="resetlog" id="resetlog" value="resetlog" class="button"><?php
public function log() { if (isset($_POST['resetlog'])) { check_admin_referer('shopp-system-log'); ShoppErrorLogging()->reset(); $this->notice(Shopp::__('The log file has been reset.')); } include $this->ui('log.php'); }
/** * Automatic refresh of the log is possible when $_REQUEST['refresh'] is set to something other than 'off'. * * @todo Investigate if it is possible to inject a formatted error log message as an XSS vector */ public function logviewer() { check_admin_referer('wp_ajax_shopp_debuglog'); ?> <html> <head> <?php if (isset($_REQUEST['refresh']) && 'off' !== $_REQUEST['refresh']) { ?> <meta http-equiv="refresh" content="10"> <?php } ?> <style type="text/css"> body { margin: 0; padding: 0; font-family:monospace;font-size:1em;line-height:1em;} ol { list-style:decimal;padding-left:5em;background:#ececec;margin-left:0; margin-bottom: 1px; } ol li { background:white;margin:0;padding:5px; } a { color: #606060; text-decoration: none; } </style> </head> <body> <ol><?php $log = ShoppErrorLogging()->tail(1000); $size = count($log); foreach ($log as $n => $line) { if (empty($line)) { continue; } echo '<li' . ($n + 1 == $size ? ' id="bottom"' : '') . '>' . $line . '</li>'; } ?> </ol> <script type="text/javascript"> document.getElementById('bottom').scrollIntoView(); </script></body></html><?php exit; }
public function screen() { if (!empty($_POST['save'])) { if (!isset($_POST['settings']['error_notifications'])) { $_POST['settings']['error_notifications'] = array(); } shopp_set_formsettings(); // Reinitialize Error System ShoppErrors()->reporting((int) shopp_setting('error_logging')); ShoppErrorLogging()->loglevel((int) shopp_setting('error_logging')); ShoppErrorNotification()->setup(); if (isset($_POST['shopp_services_plugins']) && $this->helper_installed()) { add_option('shopp_services_plugins'); // Add if it doesn't exist update_option('shopp_services_plugins', $_POST['shopp_services_plugins']); } $this->notice(Shopp::__('Advanced settings saved.')); } elseif (!empty($_POST['rebuild'])) { $assets = ShoppDatabaseObject::tablename(ProductImage::$table); $query = "DELETE FROM {$assets} WHERE context='image' AND type='image'"; if (sDB::query($query)) { $this->notice(Shopp::__('All cached images have been cleared.')); } } elseif (!empty($_POST['resum'])) { $summaries = ShoppDatabaseObject::tablename(ProductSummary::$table); $query = "UPDATE {$summaries} SET modified='" . ProductSummary::RECALCULATE . "'"; if (sDB::query($query)) { $this->notice(Shopp::__('Product summaries are set to recalculate.')); } } elseif (isset($_POST['shopp_services_helper'])) { $plugin = 'ShoppServices.php'; $source = SHOPP_PATH . "/core/library/{$plugin}"; $install = WPMU_PLUGIN_DIR . '/' . $plugin; if (false === ($creds = request_filesystem_credentials($this->url, '', false, false, null))) { return true; } // stop the normal page form from displaying if (!WP_Filesystem($creds)) { // credentials were no good, ask for them again request_filesystem_credentials($this->url, '', false, false, null); return true; } global $wp_filesystem; if ('install' == $_POST['shopp_services_helper']) { if (!$wp_filesystem->exists($install)) { if ($wp_filesystem->exists(WPMU_PLUGIN_DIR) || $wp_filesystem->mkdir(WPMU_PLUGIN_DIR, FS_CHMOD_DIR)) { // Install the mu-plugin helper $wp_filesystem->copy($source, $install, true, FS_CHMOD_FILE); } else { $this->notice(Shopp::_mi('The services helper could not be installed because the `mu-plugins` directory could not be created. Check the file permissions of the `%s` directory on the web aserver.', WP_CONTENT_DIR), 'error'); } } if ($wp_filesystem->exists($install)) { shopp_set_setting('shopp_services_helper', 'on'); $this->notice(Shopp::__('Services helper installed.')); } else { $this->notice(Shopp::__('The services helper failed to install.'), 'error'); } } elseif ('remove' == $_POST['shopp_services_helper']) { global $wp_filesystem; if ($wp_filesystem->exists($install)) { $wp_filesystem->delete($install); } if (!$wp_filesystem->exists($install)) { shopp_set_setting('shopp_services_helper', 'off'); $this->notice(Shopp::__('Services helper uninstalled.')); } else { $this->notice(Shopp::__('Services helper could not be uninstalled.'), 'error'); } } } $notifications = shopp_setting('error_notifications'); if (empty($notifications)) { $notifications = array(); } $notification_errors = array(SHOPP_TRXN_ERR => Shopp::__('Transaction Errors'), SHOPP_AUTH_ERR => Shopp::__('Login Errors'), SHOPP_ADDON_ERR => Shopp::__('Add-on Errors'), SHOPP_COMM_ERR => Shopp::__('Communication Errors'), SHOPP_STOCK_ERR => Shopp::__('Inventory Warnings')); $errorlog_levels = array(0 => Shopp::__('Disabled'), SHOPP_ERR => Shopp::__('General Shopp Errors'), SHOPP_TRXN_ERR => Shopp::__('Transaction Errors'), SHOPP_AUTH_ERR => Shopp::__('Login Errors'), SHOPP_ADDON_ERR => Shopp::__('Add-on Errors'), SHOPP_COMM_ERR => Shopp::__('Communication Errors'), SHOPP_STOCK_ERR => Shopp::__('Inventory Warnings'), SHOPP_ADMIN_ERR => Shopp::__('Admin Errors'), SHOPP_DB_ERR => Shopp::__('Database Errors'), SHOPP_PHP_ERR => Shopp::__('PHP Errors'), SHOPP_ALL_ERR => Shopp::__('All Errors'), SHOPP_DEBUG_ERR => Shopp::__('Debugging Messages')); $plugins = get_plugins(); $service_plugins = get_option('shopp_services_plugins'); include $this->ui('advanced.php'); }
/** * Defines the Shopp pages used to create WordPress menus * * @author Jonathan Davis * @since 1.3 * * @return void **/ private function pages() { // Orders menu $this->addpage('orders', Shopp::__('Orders'), 'ShoppAdminService'); $this->addpage('customers', Shopp::__('Customers'), 'ShoppAdminAccount'); $this->addpage('reports', Shopp::__('Reports'), 'ShoppAdminReport'); // Setup tabs $this->addpage('setup', Shopp::__('Setup'), 'ShoppAdminSetup'); $this->addpage('setup-core', Shopp::__('Shopp Setup'), 'ShoppAdminSetup', 'setup'); $this->addpage('setup-management', Shopp::__('Management'), 'ShoppAdminSetup', 'setup'); $this->addpage('setup-checkout', Shopp::__('Checkout'), 'ShoppAdminSetup', 'setup'); $this->addpage('setup-downloads', Shopp::__('Downloads'), 'ShoppAdminSetup', 'setup'); $this->addpage('setup-presentation', Shopp::__('Presentation'), 'ShoppAdminSetup', 'setup'); $this->addpage('setup-pages', Shopp::__('Pages'), 'ShoppAdminSetup', 'setup'); $this->addpage('setup-images', Shopp::__('Images'), 'ShoppAdminSetup', 'setup'); // System tabs $this->addpage('system', Shopp::__('System'), 'ShoppAdminSystem'); $this->addpage('system-payments', Shopp::__('Payments'), 'ShoppAdminSystem', 'system'); $this->addpage('system-shipping', Shopp::__('Shipping'), 'ShoppAdminSystem', 'system'); $this->addpage('system-taxes', Shopp::__('Taxes'), 'ShoppAdminSystem', 'system'); $this->addpage('system-storage', Shopp::__('Storage'), 'ShoppAdminSystem', 'system'); $this->addpage('system-advanced', Shopp::__('Advanced'), 'ShoppAdminSystem', 'system'); if (count(ShoppErrorLogging()->tail(2)) > 1) { $this->addpage('system-log', Shopp::__('Log'), 'ShoppAdminSystem', 'system'); } // Catalog menu $this->addpage('products', Shopp::__('Products'), 'ShoppAdminWarehouse', 'products'); $this->addpage('categories', Shopp::__('Categories'), 'ShoppAdminCategorize', 'products'); $taxonomies = get_object_taxonomies(ShoppProduct::$posttype, 'object'); foreach ($taxonomies as $t) { if ('shopp_category' == $t->name) { continue; } $pagehook = str_replace('shopp_', '', $t->name); $this->addpage($pagehook, $t->labels->menu_name, 'ShoppAdminCategorize', 'products'); } $this->addpage('discounts', Shopp::__('Discounts'), 'ShoppAdminDiscounter', 'products'); $this->addpage('welcome', Shopp::__('Welcome'), 'ShoppAdminWelcome', 'welcome'); $this->addpage('credits', Shopp::__('Credits'), 'ShoppAdminWelcome', 'credits'); // Filter hook for adding/modifying Shopp page definitions $this->pages = apply_filters('shopp_admin_pages', $this->pages); $this->caps = apply_filters('shopp_admin_caps', $this->caps); reset($this->pages); $this->mainmenu = key($this->pages); }
<?php $logurl = wp_nonce_url(add_query_arg('action', 'shopp_debuglog', admin_url('admin-ajax.php')), 'wp_ajax_shopp_debuglog') . '#bottom'; wp_nonce_field('shopp-system-log'); if (ShoppErrorLogging()->size() > 1) { ?> <iframe id="logviewer" src="<?php echo esc_url($logurl); ?> "> <p>Loading log file...</p> </iframe> <p class="alignright"><a href="<?php echo esc_url($logurl); ?> " class="button" target="_blank"><?php Shopp::_e('Open in New Window'); ?> </a> <button name="resetlog" id="resetlog" value="resetlog" class="button"><?php Shopp::_e('Clear Log'); ?> </button></p> <?php }