<?php #-------------------------------------------------------------------# # TubeX - Copyright � 2009 JMB Software, Inc. All Rights Reserved. # # This file may not be redistributed in whole or significant part. # # TubeX IS NOT FREE SOFTWARE # #-------------------------------------------------------------------# # http://www.jmbsoft.com/ http://www.jmbsoft.com/license/ # #-------------------------------------------------------------------# define('SERVER_INFO_TEST', 'SERVER_INFO_TEST'); if (isset($_SERVER[SERVER_INFO_TEST])) { $si = ServerInfo::Get(); echo serialize($si); exit; } class ServerInfo { // The name to use for caching this information const CACHE_NAME = 'ServerInfo'; // How long to cache this information, in seconds const CACHE_LIFETIME = 86400; // Minimum PHP version required const MIN_PHP_VERSION = '5.2.0'; // Minimum MySQL version required const MIN_MYSQL_VERSION = '4.1.0'; // PHP Extensions const EXT_CURL = 'curl'; const EXT_DOM = 'dom'; const EXT_GD = 'gd'; const EXT_JSON = 'json'; const EXT_MYSQL = 'mysql';
function tbxGlobalSettingsSave() { Privileges::CheckSuper(); $si = ServerInfo::GetCached(); $required = array('site_name' => 'Site Name', 'meta_description' => 'Meta Description', 'meta_keywords' => 'Meta Keywords', 'document_root' => 'Document Root', 'base_url' => 'TubeX URL', 'cookie_domain' => 'Cookie Domain', 'cookie_path' => 'Cookie Path', 'email_address' => 'E-mail Address', 'email_name' => 'E-mail Name', 'date_format' => 'Date Format', 'time_format' => 'Time Format', 'dec_point' => 'Decimal Point', 'thousands_sep' => 'Thousands Separator', 'video_extensions' => 'File Extensions'); switch (Request::Get('mailer')) { case Mailer::SMTP: $required['smtp_hostname'] = 'SMTP Hostname'; $required['smtp_port'] = 'SMTP Port'; break; case Mailer::SENDMAIL: $required['sendmail_path'] = 'Sendmail Path'; break; } $v = Validator::Get(); foreach ($required as $field => $label) { $v->Register(Request::Get($field), Validator_Type::NOT_EMPTY, 'The ' . $label . ' field is required'); } if (!$v->Validate()) { $output['message'] = 'Settings could not be saved; please fix the following items'; $output['errors'] = $v->GetErrors(); return JSON::Failure($output); } unset($_REQUEST['r']); // Setup mcf file for VP6 encoding if ($_REQUEST['video_format'] == Video_Converter::FORMAT_VP6 && preg_match('~^[0-9]+$~', $_REQUEST['video_bitrate'])) { $fp = fopen(INCLUDES_DIR . '/vp6.mcf', 'r+'); fseek($fp, 0x14); fwrite($fp, pack('s', $_REQUEST['video_bitrate'])); fclose($fp); } $_REQUEST['max_upload_size'] = Format::BytesToString(min(Format::StringToBytes($si->php_settings[ServerInfo::PHP_UPLOAD_MAX_FILESIZE]), Format::StringToBytes($_REQUEST['max_upload_size']))); $_REQUEST['document_root'] = Dir::StripTrailingSlash($_REQUEST['document_root']); $_REQUEST['base_url'] = Dir::StripTrailingSlash($_REQUEST['base_url']); $_REQUEST['base_uri'] = parse_url($_REQUEST['base_url'], PHP_URL_PATH); $_REQUEST['template_uri'] = $_REQUEST['base_uri'] . '/templates/' . $_REQUEST['template']; if (Config::Get('template') != $_REQUEST['template']) { tbxTemplateCacheFlush(true); TemplateRecompileAll(BASE_DIR . '/templates/' . $_REQUEST['template']); } ServerInfo::Get(true); Config::Save($_REQUEST); JSON::Success('Global software settings have been saved'); }