本文整理汇总了PHP中Config::GetSetting方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::GetSetting方法的具体用法?PHP Config::GetSetting怎么用?PHP Config::GetSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::GetSetting方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: strlen
<script src="theme/default/libraries/colors/colors.min.js"></script>
<script src="theme/default/js/xibo-cms.js"></script>
<script src="theme/default/js/xibo-forms.js"></script>
<script src="theme/default/js/xibo-layout-designer.js"></script>
<script src="theme/default/js/xibo-preview-timeline.js"></script>
<script src="theme/default/js/xibo-calendar.js"></script>
<script src="theme/default/js/xibo-datasets.js"></script>
<script type="text/javascript">
var translations = <?php
echo Theme::Get('translations') == '' ? '{}' : Theme::Get('translations');
?>
;
var language = "<?php
echo TranslationEngine::GetJsLocale();
?>
";
var dateFormat = "<?php
echo Config::GetSetting('DATE_FORMAT', 'Y-m-d h:i');
?>
";
var calendarType = "<?php
echo Config::GetSetting('CALENDAR_TYPE');
?>
";
var calendarLanguage = "<?php
echo strlen(TranslationEngine::GetJsLocale() <= 2) ? TranslationEngine::GetJsLocale() . '-' . strtoupper(TranslationEngine::GetJsLocale()) : TranslationEngine::GetJsLocale();
?>
";
</script>
</body>
</html>
示例2: processActions
private function processActions()
{
if (Config::GetSetting('DEFAULTS_IMPORTED') == 0) {
$layout = new Layout();
$layout->importFolder('theme' . DIRECTORY_SEPARATOR . Theme::ThemeFolder() . DIRECTORY_SEPARATOR . 'layouts');
Config::ChangeSetting('DEFAULTS_IMPORTED', 1);
}
}
示例3: InitLocale
/**
* Gets and Sets the Local
* @return
*/
public static function InitLocale()
{
$localeDir = 'locale';
$default = Config::GetSetting('DEFAULT_LANGUAGE');
global $transEngine;
global $stream;
//Debug::LogEntry('audit', 'IN', 'TranslationEngine', 'InitLocal');
// Try to get the local firstly from _REQUEST (post then get)
$lang = Kit::GetParam('lang', _REQUEST, _WORD, '');
// Build an array of supported languages
$supportedLangs = scandir($localeDir);
if ($lang != '') {
// Set the language
Debug::LogEntry('audit', 'Set the Language from REQUEST [' . $lang . ']', 'TranslationEngine', 'InitLocal');
// Is this language supported?
// if not just use the default (eb_GB).
if (!in_array($lang . '.mo', $supportedLangs)) {
trigger_error(sprintf('Language not supported. %s', $lang));
// Use the default language instead.
$lang = $default;
}
} else {
$langs = Kit::GetParam('HTTP_ACCEPT_LANGUAGE', $_SERVER, _STRING);
if ($langs != '') {
//Debug::LogEntry('audit', ' HTTP_ACCEPT_LANGUAGE [' . $langs . ']', 'TranslationEngine', 'InitLocal');
$langs = explode(',', $langs);
foreach ($langs as $lang) {
// Remove any quality rating (as we aren't interested)
$rawLang = explode(';', $lang);
$lang = str_replace("-", "_", $rawLang[0]);
if (in_array($lang . '.mo', $supportedLangs)) {
//Debug::LogEntry('audit', 'Obtained the Language from HTTP_ACCEPT_LANGUAGE [' . $lang . ']', 'TranslationEngine', 'InitLocal');
break;
}
// Set lang as the default
$lang = $default;
}
} else {
$lang = $default;
}
}
// We have the language
//Debug::LogEntry('audit', 'Creating new file streamer for '. $localeDir . '/' . $lang . '.mo', 'TranslationEngine', 'InitLocal');
if (!($stream = new CachedFileReader($localeDir . '/' . $lang . '.mo'))) {
trigger_error('Unable to translate this language');
$transEngine = false;
return;
}
$transEngine = new gettext_reader($stream);
}
示例4: request
private function request($latitude, $longitude, $time = null, $options = array())
{
$request_url = self::API_ENDPOINT . '[APIKEY]' . '/' . $latitude . ',' . $longitude . (is_null($time) ? '' : ',' . $time);
if (!empty($options)) {
$request_url .= '?' . http_build_query($options);
}
\Debug::Audit('Calling API with: ' . $request_url);
$request_url = str_replace('[APIKEY]', $this->api_key, $request_url);
$httpOptions = array(CURLOPT_TIMEOUT => 20, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_USERAGENT => 'Xibo Digital Signage', CURLOPT_HEADER => false, CURLINFO_HEADER_OUT => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $request_url);
// Proxy support
if (\Config::GetSetting('PROXY_HOST') != '' && !\Config::isProxyException($request_url)) {
$httpOptions[CURLOPT_PROXY] = \Config::GetSetting('PROXY_HOST');
$httpOptions[CURLOPT_PROXYPORT] = \Config::GetSetting('PROXY_PORT');
if (\Config::GetSetting('PROXY_AUTH') != '') {
$httpOptions[CURLOPT_PROXYUSERPWD] = \Config::GetSetting('PROXY_AUTH');
}
}
$curl = curl_init();
curl_setopt_array($curl, $httpOptions);
$result = curl_exec($curl);
// Get the response headers
$outHeaders = curl_getinfo($curl);
if ($outHeaders['http_code'] == 0) {
// Unable to connect
\Debug::Error('Unable to reach Forecast API. No Host Found (HTTP Code 0). Curl Error = ' . curl_error($curl));
return false;
} else {
if ($outHeaders['http_code'] != 200) {
\Debug::Error('ForecastIO API returned ' . $outHeaders['http_code'] . ' status. Unable to proceed. Headers = ' . var_export($outHeaders, true));
// See if we can parse the error.
$body = json_decode($result);
\Debug::Error('ForecastIO Error: ' . (isset($body->errors[0]) ? $body->errors[0]->message : 'Unknown Error'));
return false;
}
}
// Parse out header and body
$body = json_decode($result);
return $body;
}
示例5: __construct
public function __construct(user $user, $theme = NULL)
{
// Store some things for the Theme engine to use
$this->user =& $user;
$this->help = new HelpManager();
$this->dateManager = new DateManager();
// What is the currently selected theme?
$globalTheme = $theme == NULL ? Config::GetSetting('GLOBAL_THEME_NAME', 'default') : $theme;
// Is this theme valid?
if (!is_dir('theme/' . $globalTheme)) {
throw new Exception(__('The theme "%s" does not exist', $globalTheme));
}
// Store the theme name for later
$this->name = $globalTheme;
// Get config
if (!file_exists('theme/' . $this->name . '/config.php')) {
throw new Exception(__('The theme "%s" config file does not exist', $globalTheme));
}
require 'theme/' . $this->name . '/config.php';
$this->config = $config;
self::$instance = $this;
}
示例6: __construct
public function __construct(database $db, user $user)
{
// Store some things for the Theme engine to use
$this->db =& $db;
$this->user =& $user;
$this->help = new HelpManager($db, $user);
$this->dateManager = new DateManager($db);
// TODO: Perhaps we also allow the user to configure their own theme for their session?
// What is the currently selected theme?
$globalTheme = Config::GetSetting('GLOBAL_THEME_NAME');
// Is this theme valid?
if (!is_dir('theme/' . $globalTheme)) {
throw new Exception(__('The theme "%s" does not exist', $globalTheme));
}
// Store the theme name for later
$this->name = $globalTheme;
// Get config
if (!file_exists('theme/' . $this->name . '/config.php')) {
throw new Exception(__('The theme "%s" config file does not exist', $globalTheme));
}
require_once 'theme/' . $this->name . '/config.php';
$this->config = $config;
self::$instance = $this;
}
示例7: header
header("Location: {$redirect}");
exit;
}
}
// What is the production mode of the server?
if (Config::GetSetting('SERVER_MODE') == 'Test') {
ini_set('display_errors', 1);
}
// Debugging?
if (Debug::getLevel(Config::GetSetting('audit')) == 10) {
error_reporting(E_ALL);
}
// Setup the translations for gettext
TranslationEngine::InitLocale();
// Create login control system
require_once 'modules/' . Config::GetSetting("userModule");
// Page variable set? Otherwise default to index
$page = Kit::GetParam('p', _REQUEST, _WORD, 'index');
$function = Kit::GetParam('q', _REQUEST, _WORD);
// Does the version in the DB match the version of the code?
// If not then we need to run an upgrade. Change the page variable to upgrade
if (DBVERSION != WEBSITE_VERSION && !($page == 'index' && $function == 'login' || $page == 'error')) {
require_once 'install/upgradestep.class.php';
$page = 'upgrade';
if (Kit::GetParam('includes', _POST, _BOOL)) {
$upgradeFrom = Kit::GetParam('upgradeFrom', _POST, _INT);
$upgradeTo = Kit::GetParam('upgradeTo', _POST, _INT);
for ($i = $upgradeFrom + 1; $i <= $upgradeTo; $i++) {
if (file_exists('install/database/' . $i . '.php')) {
include_once 'install/database/' . $i . '.php';
}
示例8: ReturnFile
/**
* Return file based media items to the browser for Download/Preview
* @return
* @param $download Boolean
*/
public function ReturnFile($fileName = '')
{
// Return the raw flash file with appropriate headers
$library = Config::GetSetting("LIBRARY_LOCATION");
# If we weren't passed in a filename then use the default
if ($fileName == '') {
$fileName = $library . $this->storedAs;
}
$download = Kit::GetParam('download', _REQUEST, _BOOLEAN, false);
$downloadFromLibrary = Kit::GetParam('downloadFromLibrary', _REQUEST, _BOOLEAN, false);
$size = filesize($fileName);
if ($download) {
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"" . ($downloadFromLibrary ? $this->originalFilename : basename($fileName)) . "\"");
} else {
$fi = new finfo(FILEINFO_MIME_TYPE);
$mime = $fi->file($fileName);
header("Content-Type: {$mime}");
}
//Output a header
header('Pragma: public');
header('Cache-Control: max-age=86400');
header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 86400));
header('Content-Length: ' . $size);
// Send via Apache X-Sendfile header?
if (Config::GetSetting('SENDFILE_MODE') == 'Apache') {
header("X-Sendfile: {$fileName}");
exit;
}
// Send via Nginx X-Accel-Redirect?
if (Config::GetSetting('SENDFILE_MODE') == 'Nginx') {
header("X-Accel-Redirect: /download/" . basename($fileName));
exit;
}
// Return the file with PHP
// Disable any buffering to prevent OOM errors.
@ob_end_clean();
readfile($fileName);
}
示例9: GetResource
/**
* Get Resource
*/
public function GetResource($displayId = 0)
{
$proportional = Kit::GetParam('proportional', _GET, _BOOL, true);
$thumb = Kit::GetParam('thumb', _GET, _BOOL, false);
$dynamic = isset($_REQUEST['dynamic']);
$file = $this->storedAs;
$width = intval(Kit::GetParam('width', _REQUEST, _DOUBLE, 80));
$height = intval(Kit::GetParam('height', _REQUEST, _DOUBLE, 80));
// File upload directory.. get this from the settings object
$library = Config::GetSetting("LIBRARY_LOCATION");
$fileName = $library . $file;
Debug::Audit(sprintf('Image Request %dx%d %s. Thumb: %s', $width, $height, $fileName, $thumb));
// If we are a thumb request then output the cached thumbnail
if ($thumb) {
$fileName = $library . sprintf('tn_%dx%d_%s', $width, $height, $file);
// If the thumbnail doesn't exist then create one
if (!file_exists($fileName)) {
Debug::LogEntry('audit', 'File doesnt exist, creating a thumbnail for ' . $fileName);
if (!($info = getimagesize($library . $file))) {
die($library . $file . ' is not an image');
}
ResizeImage($library . $file, $fileName, $width, $height, $proportional, 'file');
}
}
// Get the info for this new temporary file
if (!($info = getimagesize($fileName))) {
$fileName = 'theme/default/img/forms/filenotfound.png';
$this->ReturnFile($fileName);
exit;
}
if ($dynamic && !$thumb && $info[2]) {
$width = intval(Kit::GetParam('width', _REQUEST, _DOUBLE, 80));
$height = intval(Kit::GetParam('height', _REQUEST, _DOUBLE, 80));
// dynamically create an image of the correct size - used for previews
ResizeImage($fileName, '', $width, $height, $proportional, 'browser');
exit;
}
if (!file_exists($fileName)) {
//not sure
Debug::LogEntry('audit', "Cant find: {$uid}", 'module', 'GetResource');
$fileName = 'theme/default/img/forms/filenotfound.png';
}
$this->ReturnFile($fileName);
exit;
}
示例10: Import
public function Import()
{
$db =& $this->db;
$response = new ResponseManager();
// What are we importing?
$template = Kit::GetParam('template', _POST, _STRING, 'false');
$template = $template == 'true';
$layout = Kit::GetParam('layout', _POST, _STRING);
$replaceExisting = Kit::GetParam('replaceExisting', _POST, _CHECKBOX);
$importTags = Kit::GetParam('importTags', _POST, _CHECKBOX, !$template);
// File data
$tmpName = Kit::GetParam('hidFileID', _POST, _STRING);
if ($tmpName == '') {
trigger_error(__('Please ensure you have picked a file and it has finished uploading'), E_USER_ERROR);
}
// File name and extension (orignial name)
$fileName = Kit::GetParam('txtFileName', _POST, _STRING);
$fileName = basename($fileName);
$ext = strtolower(substr(strrchr($fileName, "."), 1));
// File upload directory.. get this from the settings object
$fileLocation = Config::GetSetting('LIBRARY_LOCATION') . 'temp/' . $tmpName;
Kit::ClassLoader('layout');
$layoutObject = new Layout($this->db);
if (!$layoutObject->Import($fileLocation, $layout, $this->user->userid, $template, $replaceExisting, $importTags)) {
trigger_error($layoutObject->GetErrorMessage(), E_USER_ERROR);
}
$response->SetFormSubmitResponse(__('Layout Imported'));
$response->Respond();
}
示例11: TestPasswordAgainstPolicy
/**
* Tests the supplied password against the password policy
* @param <type> $password
*/
public function TestPasswordAgainstPolicy($password)
{
// Check password complexity
$policy = Config::GetSetting('USER_PASSWORD_POLICY');
if ($policy != '') {
$policyError = Config::GetSetting('USER_PASSWORD_ERROR');
$policyError = $policyError == '' ? __('Your password does not meet the required complexity') : $policyError;
if (!preg_match($policy, $password, $matches)) {
return $this->SetError(26001, $policyError);
}
}
return true;
}
示例12: defined
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2010 Daniel Garner
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*
*
* OAuth-php include file.
* Here we setup the XRDS header and initialize OAuth.
*/
defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
if (Debug::getLevel(Config::GetSetting('audit')) == 10) {
DEFINE('OAUTH_LOG_REQUEST', true);
}
// Output a discovery header
header('X-XRDS-Location:' . $serviceLocation . '/service.php?xrds');
require_once '3rdparty/oauth-php/library/OAuthServer.php';
require_once '3rdparty/oauth-php/library/OAuthStore.php';
OAuthStore::instance('PDO', array('conn' => PDOConnect::init()));
示例13: displayPage
function displayPage()
{
// Get some data for a bandwidth chart
try {
$dbh = PDOConnect::init();
$sth = $dbh->prepare('SELECT MONTHNAME(FROM_UNIXTIME(month)) AS month, IFNULL(SUM(Size), 0) AS size FROM `bandwidth` WHERE month > :month GROUP BY MONTHNAME(FROM_UNIXTIME(month)) ORDER BY MIN(month);');
$sth->execute(array('month' => time() - 86400 * 365));
$results = $sth->fetchAll();
$points = array();
foreach ($results as $row) {
$points['data'][] = array($row['month'], (double) $row['size'] / 1024 / 1024 / 1024);
}
$points['label'] = __('GB');
$output = array();
$output['points'][] = $points;
// Some config options
$output['config']['series']['bars']['show'] = true;
$output['config']['series']['bars']['barWidth'] = 0.6;
$output['config']['series']['bars']['align'] = "center";
$output['config']['xaxis']['mode'] = "categories";
$output['config']['xaxis']['tickLength'] = 0;
// Monthly bandwidth - optionally tested against limits
$xmdsLimit = Config::GetSetting('MONTHLY_XMDS_TRANSFER_LIMIT_KB');
if ($xmdsLimit > 0) {
// Convert to MB
$xmdsLimit = $xmdsLimit / 1024 / 1024;
// Plot as a line
$markings = array();
$markings[] = array('color' => '#FF0000', 'lineWidth' => 2, 'yaxis' => array('from' => $xmdsLimit, 'to' => $xmdsLimit));
$output['config']['grid']['markings'] = $markings;
}
// Set the data
Theme::Set('bandwidth-widget', json_encode($output));
// We would also like a library usage pie chart!
$libraryLimit = Config::GetSetting('LIBRARY_SIZE_LIMIT_KB');
// Library Size in Bytes
$sth = $dbh->prepare('SELECT IFNULL(SUM(FileSize), 0) AS SumSize FROM media;');
$sth->execute();
$librarySize = $sth->fetchColumn();
// Pie chart
$output = array();
$output['points'][] = array('label' => 'Used', 'data' => (double) $librarySize);
if ($libraryLimit > 0) {
$libraryLimit = $libraryLimit * 1024;
$output['points'][] = array('label' => 'Available', 'data' => (double) $libraryLimit - $librarySize);
}
$output['config']['series']['pie']['show'] = true;
$output['config']['legend']['show'] = false;
Theme::Set('library-widget', json_encode($output));
// Also a display widget
$sort_order = array('display');
$displays = $this->user->DisplayList($sort_order);
$rows = array();
if (is_array($displays) && count($displays) > 0) {
// Output a table showing the displays
foreach ($displays as $row) {
$row['licensed'] = $row['licensed'] == 1 ? 'icon-ok' : 'icon-remove';
$row['loggedin'] = $row['loggedin'] == 1 ? 'icon-ok' : 'icon-remove';
$row['mediainventorystatus'] = $row['mediainventorystatus'] == 1 ? 'success' : ($row['mediainventorystatus'] == 2 ? 'error' : 'warning');
// Assign this to the table row
$rows[] = $row;
}
}
Theme::Set('display-widget-rows', $rows);
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage());
// Show the error in place of the bandwidth chart
Theme::Set('widget-error', 'Unable to get widget details');
}
// Do we have an embedded widget?
Theme::Set('embedded-widget', html_entity_decode(Config::GetSetting('EMBEDDED_STATUS_WIDGET')));
// Render the Theme and output
Theme::Render('status_dashboard');
}
示例14: getForecastData
private function getForecastData($displayId)
{
$defaultLat = Config::GetSetting('DEFAULT_LAT');
$defaultLong = Config::GetSetting('DEFAULT_LONG');
if ($this->GetOption('useDisplayLocation') == 1) {
// Use the display ID or the default.
if ($displayId != 0) {
$display = new Display();
$display->displayId = $displayId;
$display->Load();
$defaultLat = $display->latitude;
$defaultLong = $display->longitude;
}
} else {
$defaultLat = $this->GetOption('latitude', $defaultLat);
$defaultLong = $this->GetOption('longitude', $defaultLong);
}
$apiKey = $this->GetSetting('apiKey');
if ($apiKey == '') {
die(__('Incorrectly configured module'));
}
// Query the API and Dump the Results.
$forecast = new Forecast($apiKey);
$apiOptions = array('units' => $this->GetOption('units', 'auto'), 'lang' => $this->GetOption('lang', 'en'), 'exclude' => 'flags,minutely,hourly');
$key = md5($defaultLat . $defaultLong . 'null' . implode('.', $apiOptions));
if (!Cache::has($key)) {
Debug::LogEntry('audit', 'Getting Forecast from the API', $this->type, __FUNCTION__);
if (!($data = $forecast->get($defaultLat, $defaultLong, null, $apiOptions))) {
return false;
}
// If the response is empty, cache it for less time
$cacheDuration = $this->GetSetting('cachePeriod');
// Cache
Cache::put($key, $data, $cacheDuration);
} else {
Debug::LogEntry('audit', 'Getting Forecast from the Cache with key: ' . $key, $this->type, __FUNCTION__);
$data = Cache::get($key);
}
//Debug::Audit('Data: ' . var_export($data, true));
// Icon Mappings
$icons = array('unmapped' => 'wi-alien', 'clear-day' => 'wi-day-sunny', 'clear-night' => 'wi-night-clear', 'rain' => 'wi-rain', 'snow' => 'wi-snow', 'sleet' => 'wi-hail', 'wind' => 'wi-windy', 'fog' => 'wi-fog', 'cloudy' => 'wi-cloudy', 'partly-cloudy-day' => 'wi-day-cloudy', 'partly-cloudy-night' => 'wi-night-partly-cloudy');
// Temperature Unit Mappings
$temperatureUnit = '';
foreach ($this->unitsAvailable() as $unit) {
if ($unit['id'] == $this->GetOption('units', 'auto')) {
$temperatureUnit = $unit['tempUnit'];
break;
}
}
// Are we set to only show daytime weather conditions?
if ($this->GetOption('dayConditionsOnly') == 1) {
if ($data->currently->icon == 'partly-cloudy-night') {
$data->currently->icon = 'clear-day';
}
}
$data->currently->wicon = isset($icons[$data->currently->icon]) ? $icons[$data->currently->icon] : $icons['unmapped'];
$data->currently->temperatureFloor = isset($data->currently->temperature) ? floor($data->currently->temperature) : '--';
$data->currently->summary = isset($data->currently->summary) ? $data->currently->summary : '--';
$data->currently->weekSummary = isset($data->daily->summary) ? $data->daily->summary : '--';
$data->currently->temperatureUnit = $temperatureUnit;
// Convert a stdObject to an array
$data = json_decode(json_encode($data), true);
// Process the icon for each day
for ($i = 0; $i < 7; $i++) {
// Are we set to only show daytime weather conditions?
if ($this->GetOption('dayConditionsOnly') == 1) {
if ($data['daily']['data'][$i]['icon'] == 'partly-cloudy-night') {
$data['daily']['data'][$i]['icon'] = 'clear-day';
}
}
$data['daily']['data'][$i]['wicon'] = isset($icons[$data['daily']['data'][$i]['icon']]) ? $icons[$data['daily']['data'][$i]['icon']] : $icons['unmapped'];
$data['daily']['data'][$i]['temperatureMaxFloor'] = isset($data['daily']['data'][$i]['temperatureMax']) ? floor($data['daily']['data'][$i]['temperatureMax']) : '--';
$data['daily']['data'][$i]['temperatureMinFloor'] = isset($data['daily']['data'][$i]['temperatureMin']) ? floor($data['daily']['data'][$i]['temperatureMin']) : '--';
$data['daily']['data'][$i]['temperatureFloor'] = $data['daily']['data'][$i]['temperatureMinFloor'] != '--' && $data['daily']['data'][$i]['temperatureMaxFloor'] != '--' ? floor(($data['daily']['data'][$i]['temperatureMinFloor'] + $data['daily']['data'][$i]['temperatureMaxFloor']) / 2) : '--';
$data['daily']['data'][$i]['temperatureUnit'] = $temperatureUnit;
}
return $data;
}
示例15: date
if (Config::GetSetting("MAINTENANCE_STAT_MAXAGE") != 0 && Kit::GetParam('quick', _REQUEST, _INT) != 1) {
$maxage = date("Y-m-d H:i:s", time() - 86400 * Kit::ValidateParam(Config::GetSetting("MAINTENANCE_STAT_MAXAGE"), _INT));
try {
$dbh = PDOConnect::init();
$sth = $dbh->prepare('DELETE FROM `stat` WHERE statDate < :maxage');
$sth->execute(array('maxage' => $maxage));
print __('Done.');
} catch (Exception $e) {
Debug::LogEntry('error', $e->getMessage());
}
} else {
print "->" . __("Disabled") . "<br/>\n";
}
flush();
// Validate Display Licence Slots
$maxDisplays = Config::GetSetting('MAX_LICENSED_DISPLAYS');
if ($maxDisplays > 0) {
print '<h1>' . __('Licence Slot Validation') . '</h1>';
// Get a list of all displays
try {
$dbh = PDOConnect::init();
$sth = $dbh->prepare('SELECT displayId, display FROM `display` WHERE licensed = 1 ORDER BY lastAccessed');
$sth->execute();
$displays = $sth->fetchAll(PDO::FETCH_ASSOC);
if (count($displays) > $maxDisplays) {
// :(
// We need to un-licence some displays
$difference = count($displays) - $maxDisplays;
$update = $dbh->prepare('UPDATE `display` SET licensed = 0 WHERE displayId = :displayId');
foreach ($displays as $display) {
// If we are down to 0 difference, then stop