Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/main/components/config.php
Строк: 330
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_main_config
{
    public function 
__construct()
    {
    }
    
    public function 
render()
    {
        
$cfg     VF::cfg('core.config');
        
$tpl    VF::factory('template');
        
$db         VF::factory('database');
        
        
$cache_drivers   $this->get_cache_drivers();
        
$session_drivers $this->get_session_drivers();
        
        
$errors       = array();
        
$messages     = array();
        
$warnings     = array();

        
$languages  $db->get_rows("SELECT code, name FROM #__language ORDER BY name ASC");
        
$timezones    VF::cfg('library.timezones');
        
        if (isset(
$_POST['submit_config'])) {
            
$filter              = &VF::factory('filter');
            
$site_name             $filter->get('site_name');
            
$offline            $filter->get('offline''INT');
            
$offline_message     $filter->get('offline_message');
            
$meta_desc            $filter->get('meta_desc');
            
$meta_keys            $filter->get('meta_keys');
            
$meta_title            $filter->get('meta_title''INT');
            
$meta_author        $filter->get('meta_author''INT');
            
$email_site            $filter->get('email_site');
             
$email_admin        $filter->get('email_admin');
            
$email_noreply        $filter->get('email_noreply');
            
$secret                $filter->get('secret');
            
$error                $filter->get('error''INT');
            
$debug                $filter->get('debug''INT');
            
$profile            $filter->get('profile''INT');
            
$log                $filter->get('log''INT');
            
$cache                $filter->get('cache''INT');
            
$cache_driver         $filter->get('cache_driver');
            
$cache_lifetime        $filter->get('cache_lifetime''INT');
            
$mservers            $filter->get('memcache_servers');
            
$mpersistent        = (int) trim($_POST['memcache_persistent']);
            
$mcompression        = (int) trim($_POST['memcache_compression']);
            
$template_cache        $filter->get('template_cache''INT');
            
$session_name         $filter->get('session_name');
            
$session_driver      $filter->get('session_driver');
            
$session_lifetime    $filter->get('session_lifetime''INT');
            
$ads                $filter->get('ads''INT');
            
$timezone            $filter->get('timezone');
            
$php_cli_path        $filter->get('php_cli_path');
            
$mailer                $filter->get('mailer');
            
$sendmail            $filter->get('sendmail');
            
$smtp                $filter->get('smtp''INT');
            
$smtp_auth            $filter->get('smtp_auth''INT');
            
$smtp_host            $filter->get('smtp_host');
            
$smtp_port            $filter->get('smtp_port''INT');
            
$smtp_username        $filter->get('smtp_username');
            
$smtp_password        $filter->get('smtp_password');
            
$smtp_prefix        $filter->get('smtp_prefix');
            
$age_check            $filter->get('age_check''INT');
            
$sphinx_host        $filter->get('sphinx_host');
            
$sphinx_port        = (int) trim($_POST['sphinx_port']);
            
$sphinx_index        $filter->get('sphinx_index');
            
$comment_delay        = (int) trim($_POST['comment_delay']);
            
$akismet_enabled    = (int) trim($_POST['akismet_enabled']);
            
$akismet_key        trim($_POST['akismet_key']);
            
$multi_language        = (int) trim($_POST['multi_language']);
            
            if (
$site_name == '') {
                
$errors[]    = 'Site name cannot be left blank!';
            }
            
            if (!
VValid::length($tpl->cfg['meta_desc'], 1155)) {
                
$warnings[] = 'Meta description should not contain more than 155 characters!';
            }
            
            if (!
VValid::length($tpl->cfg['meta_keys'], 1180)) {
                
$warnings[] = 'Meta keywords should not contain more than 180 characters!';
            }
            
            if (
$cfg['offline'] == '1') {
                if (
$offline_message == '') {
                    
$errors[] = 'Offline message cannot be left blank!';
                }
            }
            
            if (
$email_site == '') {
                
$errors[]    = 'Please enter the site email address!';
            } elseif (!
VValid::email($email_site)) {
                
$errors[]    = 'Site email is not a valid email address!';
            }

            if (
$email_admin == '') {
                
$errors[]    = 'Please enter the admin email address!';
            } elseif (!
VValid::email($email_admin)) {
                
$errors[]    = 'Admin email is not a valid email address!';
            }

            if (
$email_noreply == '') {
                
$errors[]    = 'Please enter the no-reply email address!';
            } elseif (!
VValid::email($email_noreply)) {
                
$errors[]    = 'No-reply email is not a valid email address!';
            }
            
            
$cache_driver_found FALSE;
            foreach (
$cache_drivers as $driver) {
                if (
$cache_driver == $driver['value']) {
                    
$cache_driver_found TRUE;
                    break;
                }
            }
            
            if (
$cache_driver_found === FALSE) {
                
$errors[]    = 'Cache driver invalid! What exactly did you select!?';
            }
            
            if (
$session_name == '') {
                
$errors[]    = 'Please enter the session name string!';
            }

            
$session_driver_found FALSE;
            foreach (
$session_drivers as $driver) {
                if (
$session_driver == $driver['value']) {
                    
$session_driver_found TRUE;
                    break;
                }
            }
            
            if (
$session_driver_found === FALSE) {
                
$errors[]    = 'Invalid session driver! What exactly did you select!?';
            }
            
            if (!
file_exists($php_cli_path) OR !is_file($php_cli_path) OR
                !
is_executable($php_cli_path)) {
                
$warnings[] = 'PHP-CLI path invalid (could not find php binary at the specified path)!';
            }
            
            if (
$akismet_enabled && !$akismet_key) {
                
$errors[]    = 'Please enter your akismet key to use the akismet spam prevention service!';
            }
            
            if (!
$errors) {
                
// we need to update the timezone here
                
if ($timezone != date_default_timezone_get()) {
                    
date_default_timezone_set($timezone);
                }
            
                
$ncfg                        = array();
                
$ncfg['site_name']             = $site_name;
                
$ncfg['offline']            = (string) $offline;
                
$ncfg['offline_message']    = $offline_message;
                
$ncfg['meta_desc']            = $meta_desc;
                
$ncfg['meta_keys']            = $meta_keys;
                
$ncfg['meta_title']            = $meta_title;
                
$ncfg['meta_author']        = $meta_author;
                
$ncfg['email_site']            = $email_site;
                
$ncfg['email_admin']        = $email_admin;
                
$ncfg['email_noreply']        = $email_noreply;
                
$ncfg['debug']                = (string) $debug;
                
$ncfg['log']                = (string) $log;
                
$ncfg['error']                = (string) $error;
                
$ncfg['profile']            = (string) $profile;
                
$ncfg['cache']                = (string) $cache;
                
$ncfg['cache_driver']        = $cache_driver;
                
$ncfg['cache_lifetime']        = $cache_lifetime;
                
$ncfg['template_cache']        = $template_cache;
                
$ncfg['session_name']        = $session_name;
                
$ncfg['session_driver']        = $session_driver;
                
$ncfg['session_lifetime']    = (string) $session_lifetime;
                
$ncfg['ads']                = (string) $ads;
                
$ncfg['timezone']            = $timezone;
                
$ncfg['php_cli_path']        = $php_cli_path;
                
$ncfg['mailer']                = $mailer;
                
$ncfg['sendmail']            = $sendmail;
                
$ncfg['smtp']                = (string) $smtp;
                
$ncfg['smtp_auth']            = (string) $smtp_auth;
                
$ncfg['smtp_host']            = $smtp_host;
                
$ncfg['smtp_port']            = (string) $smtp_port;
                
$ncfg['smtp_username']        = $smtp_username;
                
$ncfg['smtp_password']        = $smtp_password;
                
$ncfg['smtp_prefix']        = $smtp_prefix;
                
$ncfg['age_check']            = (string) $age_check;
                
$ncfg['sphinx_host']        = (string) $sphinx_host;
                
$ncfg['sphinx_port']        = $sphinx_port;
                
$ncfg['sphinx_index']        = $sphinx_index;
                
$ncfg['editor']                = 'ckeditor';
                
$ncfg['template']            = $cfg['template'];
                
$ncfg['template_admin']        = $cfg['template_admin'];
                
$ncfg['language']            = (isset($cfg['language'])) ? $cfg['language'] : 'en-US';
                
$ncfg['multi_language']        = $multi_language;
                
                
$ncfg['memcache_persistent']    = $mpersistent;
                
$ncfg['memcache_compression']    = $mcompression;
                if (
$mservers != '') {
                    
$mservers            explode(','$mservers);
                    
$memcache_servers    = array();
                    foreach (
$mservers as $mserver) {
                        
$mserver             explode(':'$mserver);
                        
$memcache_servers[] = array(
                            
'server' => $mserver['0'],
                            
'port'     => $mserver['1']
                        );
                    }
                }
                
$ncfg['memcache_servers']        = $memcache_servers;
                
                
$ncfg['google_webmasters']    = (isset($cfg['google_webmasters'])) ? $cfg['google_webmasters'] : '';
                
$ncfg['google_analytics']    = (isset($cfg['google_analytics'])) ? $cfg['google_analytics'] : '';
                
$ncfg['bing_validate']        = (isset($cfg['bing_validate'])) ? $cfg['bing_validate'] : '';
                
$ncfg['yahoo_explorer']        = (isset($cfg['yahoo_explorer'])) ? $cfg['yahoo_explorer'] : '';
                
                
$ncfg['comment_delay']        = $comment_delay;
                
$ncfg['akismet_enabled']    = $akismet_enabled;
                
$ncfg['akismet_key']        = $akismet_key;
                
                
$db->query("UPDATE #__config
                            SET config_cache = '"
.$db->escape(serialize($ncfg))."'
                            WHERE name = '"
.$db->escape($cfg['default'])."'
                            LIMIT 1"
);
                
VF::cache_set('config'$ncfg'config');
                
$messages[] = 'Configuration updated!';
            }
        }
        
        
$tpl->cfg VF::cfg('core.config'TRUETRUE);
        if (
$tpl->cfg['memcache_servers']) {
            
$memcache_servers                 = array();
            foreach (
$tpl->cfg['memcache_servers'] as $server) {
                
$memcache_servers[] = $server['server'].':'.$server['port'];
            }
            
$tpl->cfg['memcache_servers'] = implode(','$memcache_servers);
        }
    
        
$tpl->menu                 'main';
        
$tpl->submenu             'main_config';
        
$tpl->meta_title         'Admin::Configuration';
        
$tpl->errors            $errors;
        
$tpl->messages            $messages;
        
$tpl->warnings            $warnings;
        
$tpl->cache_drivers     $cache_drivers;
        
$tpl->session_drivers      $session_drivers;
        
$tpl->languages            $languages;
        
$tpl->timezones            $timezones;
        
$tpl->load(array('header''main_config''footer'));
        
$tpl->display();
    }
    
    private function 
get_cache_drivers()
    {
        
$drivers   = array();
        
$drivers[] = array('value' => 'none''name' => 'None');
        
$drivers[] = array('value' => 'file''name' => 'File');

        if (
extension_loaded('apc')) {
            
$drivers[] = array('value' => 'apc''name' => 'APC');
        }

        if (
extension_loaded('eaccelerator')) {
            
$drivers[] = array('value' => 'eaccelerator''name' => 'EAccelerator');
        }

        if (
extension_loaded('memcache') && class_exists('Memcache')) {
            
$drivers[] = array('value' => 'memcache''name' => 'Memcache');
        }

        if (
extension_loaded('xcache')) {
            
$drivers[] = array('value' => 'xcache''name' => 'XCache');
        }
        
        return 
$drivers;
    }
    
    private function 
get_session_drivers()
    {
        
$drivers     = array();
        
$drivers[]  = array('value' => 'none''name' => 'None');
        
$drivers[]  = array('value' => 'database''name' => 'Database');

        if (
extension_loaded('memcache') && class_exists('Memcache')) {
            
$drivers[] = array('value' => 'memcache''name' => 'Memcache');
        }
        
        return 
$drivers;
    }
}
?>
Онлайн: 1
Реклама