当前位置: 首页>>代码示例>>PHP>>正文


PHP waFiles::protect方法代码示例

本文整理汇总了PHP中waFiles::protect方法的典型用法代码示例。如果您正苦于以下问题:PHP waFiles::protect方法的具体用法?PHP waFiles::protect怎么用?PHP waFiles::protect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在waFiles的用法示例。


在下文中一共展示了waFiles::protect方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute()
 {
     try {
         $path_cache = waConfig::get('wa_path_cache');
         waFiles::delete($path_cache, true);
         waFiles::protect($path_cache);
         $app_path = waConfig::get('wa_path_apps');
         $apps = new waInstallerApps();
         $app_list = $apps->getApplicationsList(true);
         foreach ($app_list as $app) {
             if (isset($app['enabled']) && $app['enabled']) {
                 $path_cache = $app_path . '/' . $app['slug'] . '/js/compiled';
                 waFiles::delete($path_cache, true);
             }
         }
         $this->response['message'] = _w('Cache cleared');
     } catch (Exception $ex) {
         $this->setError($ex->getMessage());
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:20,代码来源:installerSettingsClearCache.controller.php

示例2: flushCache

 public static function flushCache($apps = array())
 {
     $path_cache = waConfig::get('wa_path_cache');
     waFiles::protect($path_cache);
     $caches = array();
     $paths = waFiles::listdir($path_cache);
     foreach ($paths as $path) {
         #skip long action & data path
         if ($path != 'temp') {
             $path = $path_cache . '/' . $path;
             if (is_dir($path)) {
                 $caches[] = $path;
             }
         }
     }
     if ($apps) {
         $app_path = waConfig::get('wa_path_apps');
         foreach ($apps as $app) {
             if (!empty($app['installed'])) {
                 $caches[] = $app_path . '/' . $app['slug'] . '/js/compiled';
             }
         }
     }
     $caches[] = $path_cache . '/temp';
     $root_path = wa()->getConfig()->getRootPath();
     $errors = array();
     foreach ($caches as $path) {
         try {
             waFiles::delete($path);
         } catch (Exception $ex) {
             $errors[] = str_replace($root_path . DIRECTORY_SEPARATOR, '', $ex->getMessage());
             waFiles::delete($path, true);
         }
     }
     return $errors;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:36,代码来源:installerHelper.class.php

示例3: wa

// Create cli.php if not included in distr already
$path = wa()->getConfig()->getRootPath() . '/cli.php';
if (!file_exists($path)) {
    if ($fp = fopen($path, 'w')) {
        $content = <<<CLI
#!/usr/bin/php
<?php
require_once(dirname(__FILE__).'/wa-system/cli.php');

CLI;
        fwrite($fp, $content);
        fclose($fp);
    }
}
// Protect private dirs with .htaccess
$paths = array('log', 'cache', 'config', 'installer');
foreach ($paths as $path) {
    $path = waSystem::getInstance()->getConfig()->getPath($path);
    waFiles::protect($path);
}
// Insert data into tables
foreach (array('wa_country', 'wa_region') as $table) {
    if ($sql = @file_get_contents(dirname(__FILE__) . '/' . $table . '.sql')) {
        try {
            $m = new waModel();
            $m->exec($sql);
        } catch (Exception $e) {
            waLog::log('Unable to populate ' . $table . ': ' . $e->getMessage() . "\n" . $e->getTraceAsString());
        }
    }
}
开发者ID:Lazary,项目名称:webasyst,代码行数:31,代码来源:install.php

示例4: create

 protected function create($app_id, $path, $params = array())
 {
     if (!file_exists($path)) {
         $path .= '/';
         mkdir($path);
         mkdir($path . 'css');
         touch($path . 'css/' . $app_id . '.css');
         mkdir($path . 'js');
         touch($path . 'js/' . $app_id . '.js');
         mkdir($path . 'img');
         // lib
         mkdir($path . 'lib');
         waFiles::protect($path . 'lib');
         mkdir($path . 'lib/actions');
         // backend controller
         mkdir($path . 'lib/actions/backend');
         // api
         if (isset($params['api'])) {
             mkdir($path . 'lib/api');
             if ($params['api'] !== true) {
                 mkdir($path . 'lib/api/' . $params['api']);
             }
         }
         // cli
         if (isset($params['cli'])) {
             mkdir($path . 'lib/cli');
         }
         mkdir($path . 'lib/classes');
         mkdir($path . 'lib/models');
         // config
         mkdir($path . 'lib/config');
         // app description
         $app = array('name' => empty($params['name']) ? ucfirst($app_id) : $params['name'], 'icon' => 'img/' . $app_id . '.gif', 'version' => $version = empty($params['version']) ? '0.1' : $params['version']);
         if (isset($params['frontend'])) {
             $app['frontend'] = true;
             if (isset($params['themes'])) {
                 $app['themes'] = true;
             }
             $routing = array('*' => 'frontend');
             waUtils::varExportToFile($routing, $path . 'lib/config/routing.php');
             // frontend controller
             mkdir($path . 'lib/actions/frontend');
         }
         // plugins
         if (isset($params['plugins'])) {
             $app['plugins'] = true;
             mkdir($path . 'plugins');
         }
         waUtils::varExportToFile($app, $path . 'lib/config/app.php');
         // templates
         mkdir($path . 'templates');
         waFiles::protect($path . 'templates');
         mkdir($path . 'templates/actions');
         mkdir($path . 'templates/actions/backend');
         // backend template
         if (isset($params['frontend'])) {
             // frontend template
             mkdir($path . 'templates/actions/frontend');
         }
         // locale
         mkdir($path . 'locale');
         if (isset($params['frontend']) && isset($params['themes'])) {
             // themes
             mkdir($path . 'themes');
             mkdir($path . 'themes/default');
             $theme = new waTheme('default', $app_id, true);
             $theme->name = 'Default theme';
             $theme->description = 'Auto generated default theme';
             $theme->system = 1;
             $theme->addFile('index.html', 'Frontend index file');
             touch($path . 'themes/default/index.html');
             $theme->addFile('default.css', 'Frontend CSS file');
             touch($path . 'themes/default/default.css');
             $theme->version = $version;
             $theme->save();
         }
         print "App with id {$app_id} created";
     } else {
         print "App with id {$app_id} already exists";
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:81,代码来源:webasystCreateApp.cli.php

示例5: create

    protected function create($app_id, $path, $params = array())
    {
        $report = '';
        if (!file_exists($path)) {
            $path .= '/';
            mkdir($path);
            mkdir($path . 'css');
            touch($path . 'css/' . $app_id . '.css');
            mkdir($path . 'js');
            touch($path . 'js/' . $app_id . '.js');
            mkdir($path . 'img');
            // lib
            mkdir($path . 'lib');
            waFiles::protect($path . 'lib');
            mkdir($path . 'lib/actions');
            // backend controller
            mkdir($path . 'lib/actions/backend');
            // api
            if (isset($params['api'])) {
                mkdir($path . 'lib/api');
                if ($params['api'] !== true) {
                    mkdir($path . 'lib/api/' . $params['api']);
                } else {
                    mkdir($path . 'lib/api/v1');
                }
            }
            // cli
            if (isset($params['cli'])) {
                mkdir($path . 'lib/cli');
            }
            mkdir($path . 'lib/classes');
            mkdir($path . 'lib/models');
            // config
            mkdir($path . 'lib/config');
            // app description
            $app = array('name' => empty($params['name']) ? ucfirst($app_id) : $params['name'], 'icon' => 'img/' . $app_id . '.gif', 'version' => $version = empty($params['version']) ? '0.1' : $params['version'], 'vendor' => $vendor = empty($params['vendor']) ? '--' : $params['vendor']);
            if (isset($params['frontend'])) {
                $app['frontend'] = true;
                if (isset($params['themes'])) {
                    $app['themes'] = true;
                }
                $routing = array('*' => 'frontend');
                waUtils::varExportToFile($routing, $path . 'lib/config/routing.php');
                // frontend controller
                mkdir($path . 'lib/actions/frontend');
            }
            // plugins
            if (isset($params['plugins'])) {
                $app['plugins'] = true;
                mkdir($path . 'plugins');
            }
            waUtils::varExportToFile($app, $path . 'lib/config/app.php');
            // templates
            mkdir($path . 'templates');
            waFiles::protect($path . 'templates');
            mkdir($path . 'templates/actions');
            mkdir($path . 'templates/actions/backend');
            // backend template
            if (isset($params['frontend'])) {
                // frontend template
                mkdir($path . 'templates/actions/frontend');
            }
            // locale
            mkdir($path . 'locale');
            waFiles::protect($path . 'locale');
            if (isset($params['frontend']) && isset($params['themes'])) {
                // themes
                mkdir($path . 'themes');
                mkdir($path . 'themes/default');
                $theme = new waTheme('default', $app_id, true);
                $theme->name = 'Default theme';
                $theme->description = 'Auto generated default theme';
                $theme->vendor = $vendor;
                $theme->system = 1;
                $theme->addFile('index.html', 'Frontend index file');
                touch($path . 'themes/default/index.html');
                $theme->addFile('default.css', 'Frontend CSS file');
                touch($path . 'themes/default/default.css');
                $theme->version = $version;
                $theme->save();
                waFiles::move($theme->path . '/theme.xml', $path . 'themes/default/theme.xml');
            }
            $report .= <<<REPORT
App with id "{$app_id}" created!

Useful commands:
    #generate app's database description file db.php
    php wa.php generateDb {$app_id}

    #generate app's locale files
    php wa-system/locale/locale.php {$app_id}
REPORT;
            if (isset($params['plugins'])) {
                $report .= "\n\n" . <<<REPORT
    #create a plugin with specified 'plugin_id' for your app
    php wa.php createPlugin {$app_id} plugin_id
REPORT;
            }
            //TODO add hint about compress command
        } else {
//.........这里部分代码省略.........
开发者ID:Lazary,项目名称:webasyst,代码行数:101,代码来源:webasystCreateApp.cli.php

示例6: execute

 public function execute()
 {
     $model = new waAppSettingsModel();
     $settings = array('name' => 'Webasyst', 'url' => wa()->getRootUrl(true), 'auth_form_background' => null, 'auth_form_background_stretch' => 1, 'locale' => 'ru_RU', 'email' => '', 'rememberme' => 1);
     $config_settings = array('debug' => 'boolean');
     $flush_settings = array('debug');
     $config_path = waSystem::getInstance()->getConfigPath() . '/config.php';
     $config = file_exists($config_path) ? include $config_path : array();
     if (!is_array($config)) {
         $config = array();
     }
     $changed = false;
     $flush = false;
     $message = array();
     try {
         $messages = installerMessage::getInstance()->handle(waRequest::get('msg'));
         foreach ($settings as $setting => &$value) {
             if (waRequest::post() && !in_array($setting, array('auth_form_background'))) {
                 $post_value = waRequest::post($setting, '', 'string_trim');
                 if (!is_null($post_value)) {
                     $model->set('webasyst', $setting, $post_value);
                     $changed = true;
                 } elseif (!is_null($value)) {
                     $model->set('webasyst', $setting, '');
                 }
                 $value = $model->get('webasyst', $setting, $value);
             } else {
                 $value = $model->get('webasyst', $setting, $value);
             }
             unset($value);
         }
         $config_changed = false;
         if (waRequest::post()) {
             $config_values = waRequest::post('config');
             if (!is_array($config_values)) {
                 $config_values = array();
             }
             foreach ($config_settings as $setting => $type) {
                 $value = isset($config_values[$setting]) ? $config_values[$setting] : false;
                 switch ($type) {
                     case 'boolean':
                         $value = $value ? true : false;
                         break;
                 }
                 if (!isset($config[$setting]) || $config[$setting] !== $value) {
                     $config[$setting] = $value;
                     $config_changed = true;
                     if (in_array($setting, $flush_settings)) {
                         $flush = true;
                     }
                 }
             }
             if ($config_changed) {
                 waUtils::varExportToFile($config, $config_path);
             }
             if ($flush) {
                 $path_cache = waConfig::get('wa_path_cache');
                 waFiles::delete($path_cache, true);
                 waFiles::protect($path_cache);
             }
             $model->ping();
         }
         if ($changed || $config_changed) {
             $message[] = '[`Settings saved`]';
         }
         $name = preg_replace('/\\?.*$/', '', $settings['auth_form_background']);
         $path = wa()->getDataPath($name, true, 'webasyst');
         $file = waRequest::file('auth_form_background');
         if ($file->uploaded()) {
             if ($name) {
                 waFiles::delete(wa()->getDataPath($name, true, 'webasyst'));
                 $model->set('webasyst', 'auth_form_background', false);
                 $settings['auth_form_background'] = false;
             }
             $ext = 'png';
             if (preg_match('/\\.(png|gif|jpg|jpeg|bmp|tif)$/i', $file->name, $matches)) {
                 $ext = $matches[1];
             }
             $name = 'auth_form_background.' . $ext;
             $path = wa()->getDataPath($name, true, 'webasyst');
             try {
                 $image = $file->waImage();
             } catch (waException $ex) {
                 $message = $ex->getMessage();
                 $tmp_name = $file->tmp_name;
                 if (!preg_match('//u', $tmp_name)) {
                     $tmp_name = iconv('windows-1251', 'utf-8', $tmp_name);
                 }
                 if (strpos($message, $tmp_name) !== false) {
                     throw new waException(preg_replace('/:\\s*$/', '', str_replace($tmp_name, '', $message)));
                 }
                 throw $ex;
             }
             $file->copyTo($path);
             //$image->save($path);
             $name .= '?' . time();
             $model->set('webasyst', 'auth_form_background', $name);
             $settings['auth_form_background'] = $name;
             $message[] = '[`Image uploaded`]';
             $image_info = get_object_vars($image);
//.........这里部分代码省略.........
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:101,代码来源:installerSettings.action.php

示例7: protect

 protected function protect($paths)
 {
     foreach ($paths as $path) {
         waFiles::protect($this->path . $path);
     }
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:6,代码来源:webasystCreateCliController.class.php

示例8: create

 protected function create($type, $id, $path, $params = array())
 {
     $template_id = 'wapattern';
     $template_path = wa()->getConfig()->getPath('plugins') . '/' . $type . '/' . $template_id . '/';
     if (!file_exists($path)) {
         try {
             $path .= '/';
             mkdir($path);
             // lib
             mkdir($path . 'lib');
             waFiles::protect($path . 'lib');
             $plugin_class = null;
             mkdir($path . 'lib/classes');
             // config
             mkdir($path . 'lib/config');
             // app description
             $plugin = array('name' => empty($params['name']) ? ucfirst($id) : $params['name'], 'description' => '', 'icon' => 'img/' . $id . '.png', 'version' => empty($params['version']) ? '1.0.0' : $params['version'], 'vendor' => empty($params['vendor']) ? '' : $params['vendor']);
             waUtils::varExportToFile($plugin, $path . 'lib/config/plugin.php');
             switch ($type) {
                 case 'payment':
                     #settings
                     if (isset($params['settings'])) {
                         waUtils::varExportToFile(array(), $path . 'lib/config/settings.php');
                     }
                     #plugin class
                     $template_class_path = $template_path . 'lib/' . $template_id . ucfirst($type) . '.class.php';
                     $class_path = $path . 'lib/' . $id . ucfirst($type) . '.class.php';
                     $template = file_get_contents($template_class_path);
                     waFiles::write($class_path, str_replace($template_id, $id, $template));
                     #plugin template
                     mkdir($path . 'templates');
                     waFiles::protect($path . 'templates');
                     waFiles::copy($template_path . 'templates/payment.html', $path . 'templates/payment.html');
                     break;
                 case 'shipping':
                     #settings
                     if (isset($params['settings'])) {
                         waUtils::varExportToFile(array(), $path . 'lib/config/settings.php');
                     }
                     #plugin class
                     $template_class_path = $template_path . 'lib/' . $template_id . ucfirst($type) . '.class.php';
                     $class_path = $path . 'lib/' . $id . ucfirst($type) . '.class.php';
                     $template = file_get_contents($template_class_path);
                     waFiles::write($class_path, str_replace($template_id, $id, $template));
                     break;
                 default:
                     throw new waException(sprintf("Plugin type \"%s\" not supported yet.\n", $type));
                     break;
             }
             print "Plugin with id \"{$id}\" created!\n";
         } catch (waException $ex) {
             print "Plugin with id \"{$id}\" was NOT created.\n";
             if (waSystemConfig::isDebug()) {
                 echo $ex;
             } else {
                 print "Error:" . $ex->getMessage() . "\n";
             }
             waFiles::delete($path);
         }
     } else {
         print "Plugin with id \"{$id}\" already exists.\n";
     }
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:63,代码来源:webasystCreateSystemplugin.cli.php

示例9: execute


//.........这里部分代码省略.........
                         foreach ($info['extras'] as $subject => $extras) {
                             foreach ($extras as $extras_id => $extras_info) {
                                 $extras_id = $app_id . '/' . $subject . '/' . $extras_id;
                                 if (isset($app_ids[$extras_id]) && installerHelper::equals($app_ids[$extras_id], $extras_info)) {
                                     if (!empty($app_ids[$extras_id]['dependent']) && (empty($extras_info['action']) || !in_array($extras_info['action'], $execute_actions))) {
                                         continue;
                                     }
                                     $target = 'wa-apps/' . $extras_id;
                                     $extras_info['subject'] = 'app_' . $subject;
                                     $this->add($target, $extras_info, $extras_info['slug']);
                                     if ($extras_info['dependency']) {
                                         foreach ($extras_info['dependency'] as $dependency) {
                                             $app_ids[$dependency] = $app_ids[$extras_id];
                                             $app_ids[$dependency]['slug'] = $dependency;
                                             $app_ids[$dependency]['dependent'] = $target;
                                             $added = true;
                                         }
                                     }
                                     if ($subject == 'themes') {
                                         if (!empty($extras_info['current']['parent_theme_id'])) {
                                             $parent_id = $extras_info['current']['parent_theme_id'];
                                             $parent_app_id = $app_id;
                                             if (strpos($parent_id, ':')) {
                                                 list($parent_app_id, $parent_id) = explode(':', $parent_id);
                                             }
                                             $dependency = "{$parent_app_id}/{$subject}/{$parent_id}";
                                             $app_ids[$dependency] = $app_ids[$extras_id];
                                             $app_ids[$dependency]['slug'] = $dependency;
                                             $app_ids[$dependency]['dependent'] = $target;
                                             $added = true;
                                         }
                                     }
                                     unset($app_ids[$extras_id]);
                                 }
                             }
                         }
                     }
                 }
                 unset($info);
             }
             $storage = wa()->getStorage();
             $storage->close();
             $result_urls = $updater->update($this->urls);
             if (waRequest::get('install')) {
                 $model->ping();
                 $user = $this->getUser();
                 $set_rights = false;
                 if (!$user->isAdmin()) {
                     $set_rights = true;
                 }
                 foreach ($this->urls as $target => $url) {
                     //TODO workaround exceptions
                     if ((!isset($url['skipped']) || !$url['skipped']) && preg_match('@^wa-apps@', $target)) {
                         $apps->installWebAsystItem($url['slug'], null, isset($url['edition']) ? $url['edition'] : true);
                         if ($set_rights) {
                             $user->setRight($url['slug'], 'backend', 2);
                         }
                     }
                 }
             }
             $secure_properties = array('archive', 'source', 'backup', 'md5', 'extract_path');
             foreach ($result_urls as &$result_url) {
                 foreach ($secure_properties as $property) {
                     if (isset($result_url[$property])) {
                         unset($result_url[$property]);
                     }
                 }
                 unset($result_url);
             }
             $this->response['sources'] = $result_urls;
             $this->response['current_state'] = $updater->getState();
             $this->response['state'] = $updater->getFullState(waRequest::get('mode', 'apps'));
             //cleanup cache
             //waFiles::delete(wa()->getAppCachePath(null, false), true);
             $path_cache = waConfig::get('wa_path_cache');
             waFiles::delete($path_cache, true);
             waFiles::protect($path_cache);
             $root_path = waConfig::get('wa_path_root');
             foreach ($this->urls as $url) {
                 if (!isset($url['skipped']) || !$url['skipped']) {
                     $path_cache = $root_path . '/' . $url['target'] . '/js/compiled';
                     waFiles::delete($path_cache, true);
                 }
             }
             $model->ping();
             $this->getConfig()->setCount(false);
             $response = $this->getResponse();
             $response->addHeader('Content-Type', 'application/json; charset=utf-8');
             $response->sendHeaders();
         } catch (Exception $ex) {
             $this->setError($ex->getMessage());
         }
         if ($ob = ob_get_clean()) {
             $this->response['warning'] = $ob;
             waLog::log('Output at ' . __METHOD__ . ': ' . $ob);
         }
     } else {
         throw new Exception('nothing to update');
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:101,代码来源:installerUpdateExecute.controller.php

示例10: create

    protected function create($app_id, $plugin_id, $path, $params = array())
    {
        $report = '';
        if (!file_exists($path)) {
            $plugin = array('name' => empty($params['name']) ? ucfirst($plugin_id) : $params['name'], 'icon' => 'img/' . $plugin_id . '.gif', 'version' => $version = empty($params['version']) ? '0.1' : $params['version'], 'vendor' => $vendor = empty($params['vendor']) ? '--' : $params['vendor'], 'handlers' => array());
            $path .= '/';
            mkdir($path);
            mkdir($path . 'css');
            touch($path . 'css/' . $plugin_id . '.css');
            mkdir($path . 'js');
            touch($path . 'js/' . $plugin_id . '.js');
            mkdir($path . 'img');
            // lib
            mkdir($path . 'lib');
            waFiles::protect($path . 'lib');
            $class_name = $app_id . ucfirst($plugin_id) . 'Plugin';
            wa($app_id, true);
            $extends = $app_id . 'Plugin';
            if (!class_exists($extends)) {
                $extends = 'waPlugin';
            }
            $class = <<<PHP
<?php

class {$class_name} extends {$extends}
{

}

PHP;
            waFiles::write($path . 'lib/' . $app_id . ucfirst($plugin_id) . 'Plugin.class.php', $class);
            mkdir($path . 'lib/config');
            mkdir($path . 'lib/actions');
            mkdir($path . 'lib/classes');
            if (isset($params['db'])) {
                mkdir($path . 'lib/models');
            }
            if (isset($params['frontend'])) {
                $plugin['frontend'] = true;
                $routing = array('*' => 'frontend');
                waUtils::varExportToFile($routing, $path . 'lib/config/routing.php');
                // frontend controller
                mkdir($path . 'lib/actions/frontend');
            }
            // config
            waUtils::varExportToFile($plugin, $path . 'lib/config/plugin.php');
            if (isset($params['settings'])) {
                waUtils::varExportToFile(array(), $path . 'lib/config/settings.php');
            }
            // templates
            mkdir($path . 'templates');
            waFiles::protect($path . 'templates');
            mkdir($path . 'templates/actions');
            mkdir($path . 'templates/actions/backend');
            // backend template
            if (isset($params['frontend'])) {
                // frontend template
                mkdir($path . 'templates/actions/frontend');
            }
            // locale
            if (isset($params['locale'])) {
                mkdir($path . 'locale');
                waFiles::protect($path . 'locale');
            }
            $report .= <<<REPORT
Plugin with id "{$plugin_id}" created!

Useful commands:
    #generate plugin's database description file db.php
    php wa.php generateDb {$app_id}/{$plugin_id} table1 table2 table3

    #generate plugin's locale files
    php wa-system/locale/locale.php {$app_id}/plugins/{$plugin_id}
REPORT;
        } else {
            $report .= <<<REPORT
Plugin with id "{$plugin_id}" already exists.
REPORT;
        }
        print $report . "\n";
    }
开发者ID:Lazary,项目名称:webasyst,代码行数:81,代码来源:webasystCreatePlugin.cli.php

示例11: execute

 public function execute()
 {
     $model = new waAppSettingsModel();
     $settings = array('name' => 'Webasyst', 'url' => wa()->getRootUrl(true), 'auth_form_background' => 'stock:bokeh_vivid.jpg', 'auth_form_background_stretch' => 1, 'locale' => 'ru_RU', 'email' => '', 'sender' => '', 'rememberme' => 1);
     $config_settings = array('debug' => 'boolean');
     $flush_settings = array('debug');
     $config_path = waSystem::getInstance()->getConfigPath() . '/config.php';
     $images_path = wa()->getDataPath(null, true, 'webasyst');
     $config = file_exists($config_path) ? include $config_path : array();
     if (!is_array($config)) {
         $config = array();
     }
     $images = array();
     $changed = false;
     $flush = false;
     $message = array();
     try {
         foreach ($settings as $setting => &$value) {
             if (waRequest::post() && !in_array($setting, array('auth_form_background'))) {
                 $post_value = waRequest::post($setting, '', waRequest::TYPE_STRING_TRIM);
                 if (!is_null($post_value)) {
                     $model->set('webasyst', $setting, $post_value);
                     $changed = true;
                 } elseif (!is_null($value)) {
                     $model->set('webasyst', $setting, '');
                 }
                 $value = $model->get('webasyst', $setting, $value);
             } else {
                 $value = $model->get('webasyst', $setting, $value);
             }
             unset($value);
         }
         $config_changed = false;
         if (waRequest::post()) {
             $config_values = waRequest::post('config');
             if (!is_array($config_values)) {
                 $config_values = array();
             }
             foreach ($config_settings as $setting => $type) {
                 $value = isset($config_values[$setting]) ? $config_values[$setting] : false;
                 switch ($type) {
                     case 'boolean':
                         $value = $value ? true : false;
                         break;
                 }
                 if (!isset($config[$setting]) || $config[$setting] !== $value) {
                     $config[$setting] = $value;
                     $config_changed = true;
                     if (in_array($setting, $flush_settings)) {
                         $flush = true;
                     }
                 }
             }
             if ($config_changed) {
                 waUtils::varExportToFile($config, $config_path);
             }
             if ($flush) {
                 $path_cache = waConfig::get('wa_path_cache');
                 waFiles::delete($path_cache, true);
                 waFiles::protect($path_cache);
             }
             $model->ping();
         }
         if ($changed || $config_changed) {
             $message[] = '[`Settings saved`]';
         }
         $name = preg_replace('/\\?.*$/', '', $settings['auth_form_background']);
         $path = wa()->getDataPath($name, true, 'webasyst');
         $file = waRequest::file('auth_form_background');
         $images = $this->getImages($images_path);
         if ($file->uploaded()) {
             if ($name) {
                 //waFiles::delete(wa()->getDataPath($name, true, 'webasyst'));
                 $model->set('webasyst', 'auth_form_background', false);
                 $settings['auth_form_background'] = false;
             }
             $ext = 'png';
             if (preg_match('/\\.(png|gif|jpg|jpeg|bmp|tif)$/i', $file->name, $matches)) {
                 $ext = $matches[1];
             }
             $name = 'auth_form_background.' . $ext;
             $path = wa()->getDataPath($name, true, 'webasyst');
             try {
                 $image = $file->waImage();
             } catch (waException $ex) {
                 $message = $ex->getMessage();
                 $tmp_name = $file->tmp_name;
                 if (!preg_match('//u', $tmp_name)) {
                     $tmp_name = iconv('windows-1251', 'utf-8', $tmp_name);
                 }
                 if (strpos($message, $tmp_name) !== false) {
                     throw new waException(preg_replace('/:\\s*$/', '', str_replace($tmp_name, '', $message)));
                 }
                 throw $ex;
             }
             foreach ($images as $i) {
                 waFiles::delete($images_path . '/' . $i);
             }
             $file->copyTo($path);
             clearstatcache();
//.........这里部分代码省略.........
开发者ID:Lazary,项目名称:webasyst,代码行数:101,代码来源:installerSettings.action.php


注:本文中的waFiles::protect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。