function installApp() { if ($_FILES['app']['name']) { if ($_FILES['app']['type'] != 'application/zip') { s::set('ERRORS', '<ul><li>Неверный формат архива приложения.</li></ul>'); } else { $arr = explode('.', $_FILES['app']['name']); if (count($arr) < 5) { s::set('ERRORS', '<ul><li>Неверный формат архива приложения.</li></ul>'); } else { define('INSTALL_APP', $arr[0]); define('INSTALL_APP_VERSION', $arr[1] . '.' . $arr[2] . '.' . $arr[3]); files::fullRemoveDir(SYS_ROOT . 'var/tmp/apps/'); $path = SYS_ROOT . 'var/tmp/apps/'; zipfile::read($_FILES['app']['tmp_name']); zipfile::extract($path); $install_file = $path . 'install.php'; if (!file_exists($install_file)) { s::set('ERRORS', '<ul><li>Не найден инсталляционый файл приложения.</li></ul>'); } else { include $install_file; // copy lang files $tmp_lang_dir = SYS_ROOT . 'var/tmp/apps/langs/'; $lang_dir = SYS_ROOT . 'langs/admin/'; if (file_exists($lang_dir)) { $array = files::getFiles($tmp_lang_dir); foreach ($array as $v) { if (!file_exists($lang_dir . $v)) { copy($tmp_lang_dir . $v, $lang_dir . $v); } else { $lang = ini::parse($tmp_lang_dir . $v); ini::parse($lang_dir . $v); ini::add($lang); ini::write(); } } } // copy app files $dir = SYS_ROOT . 'var/tmp/apps/' . INSTALL_APP . '/'; $new_dir = SYS_ROOT . 'apps/' . INSTALL_APP . '/'; files::copyDir($dir, $new_dir); // clear tmp files::fullRemoveDir(SYS_ROOT . 'var/tmp/apps/'); headers::app('manage'); } } } } }
function save($app) { if (!isset(self::$settings[$app])) { self::load($app); } $file = APPS . $app . '/settings.ini'; if (defined('ADMIN_SITE_ID')) { $site_id = ADMIN_SITE_ID; } else { $site_id = SITE_ID; } $ini = ini::parse($file); $ini[$site_id] = self::$settings[$app]; ini::write($ini, $file, true); }
/** * Сканирует классы, обновляет файлы module.ini */ public function rebuildMeta() { foreach (os::find('lib', 'modules', '*', 'module.ini') as $iniFileName) { $moduleName = basename(dirname($iniFileName)); if (!empty($argv[1]) and $argv[1] != $moduleName) { continue; } $ini = ini::read($iniFileName); $path = dirname($iniFileName); if (file_exists($routeFileName = os::path($path, 'route.ini'))) { $routes = ini::read($routeFileName); } else { $routes = array(); } // Удаляем временные маршруты, считанные из комментариев в прошлый раз. foreach ($routes as $k => $v) { if (is_array($v) and !empty($v['volatile'])) { unset($routes[$k]); } } foreach ($ini as $k => $v) { if (is_array($v)) { unset($ini[$k]); } } foreach (os::find($path, '*.php') as $fileName) { $baseName = basename($fileName); if (0 === strpos($baseName, 'test')) { continue; } elseif ('.test.php' == substr($baseName, -9)) { continue; } $source = strtolower(file_get_contents($fileName)); if (preg_match('@^\\s*(?:abstract\\s+)?class\\s+([a-z0-9_]+)(\\s+extends\\s+([^\\s]+))*(\\s+implements\\s+([^\\n\\r]+))*@m', $source, $m)) { $className = $m[1]; $ini['classes'][$m[1]] = $baseName; if (preg_match_all('#(?:@mcms_message\\s+)([a-z0-9.]+)(?:[^{]*public\\s+static\\s+function\\s+)([^(]+)#s', $source, $m)) { foreach ($m[1] as $idx => $message) { $method = $m[2][$idx]; $ini['messages'][$message][] = $className . '::' . $method; } } if (preg_match_all('#(?:@route\\s+)([a-z0-9./-]+)(?:[^{]*public\\s+static\\s+function\\s+)([^(]+)#s', $source, $m)) { foreach ($m[1] as $idx => $route) { $parts = explode('//', $route); $parts[0] = strtoupper($parts[0]); $routes[implode('//', $parts)] = array('call' => $className . '::' . $m[2][$idx], 'volatile' => true); } } } elseif (preg_match('@^\\s*interface\\s+([a-z0-9_]+)@m', $source, $m)) { $ini['classes'][$m[1]] = $baseName; } } $ini['changelog'] = 'http://molinos-cms.googlecode.com/svn/dist/' . MCMS_RELEASE . '/changelogs/' . $moduleName . '.txt'; if (!empty($ini['classes'])) { ksort($ini['classes']); } if (!empty($routes)) { ksort($routes); ini::write($routeFileName, $routes); } elseif (file_exists($routeFileName)) { unlink($routeFileName); } ini::write($iniFileName, $ini); } }
private function writeConfig() { $ini = array(); $ini['db']['dsn'] = $this->conf['db.default']; $ini['mail']['from'] = $this->conf['mail.from']; $ini['mail']['server'] = $this->conf['mail.server']; $ini['debug']['backtrace'] = join(',', $this->conf['backtracerecipients']); $ini['debug']['allow'] = join(',', $this->conf['debuggers']); $ini['attachment']['storage'] = $this->conf['filestorage']; $ini['attachment']['ftp'] = $this->conf['ftp']; $ini['core']['tmpdir'] = $this->conf['tmpdir']; ini::write($fileName = os::path($this->site, 'config.ini'), $ini); $this->log('wrote ' . $fileName); }
foreach ($this->lines as &$line) { if ($line['type'] != 'entry') { continue; } if ($line['section'] != $section) { continue; } if ($line['key'] != $key) { continue; } $line['value'] = $value; $line['data'] = $key . " = " . $value . "\r\n"; return; } throw new Exception('Missing Section or Key'); } public function write($file) { $fp = fopen($file, 'w'); foreach ($this->lines as $line) { fwrite($fp, $line['data']); } fclose($fp); } } $ini = new ini(); $ini->read("C:\\php.ini"); $ini->set('PHP', 'engine', 'Off'); echo $ini->get('PHP', 'engine'); $ini->write("C:\\php.ini");
public function run() { $tmpdir = os::mkdir(os::path('tmp', 'modules')); $existing = $this->getExistingModules(); foreach (glob(os::path('lib', 'modules', '*', 'module.ini')) as $inifile) { $module = basename(dirname($inifile)); $ini = array_merge(array('priority' => 'optional', 'section' => 'service'), ini::read($inifile)); foreach (array('section', 'version', 'name') as $k) { if (!array_key_exists($k, $ini)) { printf("warning: %s has no '%s' key, module ignored.\n", $module, $k); continue 2; } } if (!in_array($zipname = $module . '-' . $ini['version'] . '.zip', $existing)) { zip::fromFolder($fullzipname = os::path($tmpdir, $zipname), dirname($inifile)); printf("new file: %s\n", basename($fullzipname)); } foreach ($ini as $k => $v) { if (is_array($v)) { unset($ini[$k]); } } $ini['filename'] = $zipname; $this->modules[$module] = $ini; } ksort($this->modules); ini::write($this->inifile, $this->modules); }
function deleteGroup() { $group_id = params::get('group_id'); $array = ini::parse(SYS_ROOT . 'conf/admin/groups.ini'); ini::delete($group_id); ini::write(); }
/** * Запись/обновление кеша * * @access private * @param string $name уникальное имя сервера * @param array $params * @return boolean */ public function set_cache($name, $params) { $cache = new ini($this->sysf . 'cache.ini'); if (empty($cache->file)) { return false; } $cache->content[$name] = $params; $cache->write(); }
function delete($conf_name, $section) { ini::parse(SYS_ROOT . 'conf/web/' . $conf_name . '.ini'); ini::delete($section); ini::write(); }
<?php $cfgile = winLocalPath(CSIDL_PERSONAL) . '/KeyPad/config.ini'; if (!is_dir(dirname($cfgile))) { mkdir(dirname($cfgile), 0777, true); } ini::open($cfgile); ini::write('main', 'wordWrap', c("memo1")->wordWrap); ini::write('main', 'width', c("Form1")->w); ini::write('main', 'height', c("Form1")->h); ini::write('main', 'x', c("Form1")->x); ini::write('main', 'y', c("Form1")->y); ini::write('main', 'ws', c("Form1")->windowState); ini::write('font', 'name', c("memo1")->font->name); ini::write('font', 'size', c("memo1")->font->size); ini::write('font', 'color', c("memo1")->font->color); ini::write('font', 'style', implode(',', c("memo1")->font->style)); ini::update();