123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?php
- if (!class_exists('installer')) {
-
- class installer {
-
- function checkPluginShareDir($dirname,$protect = true)
- {
- $my_share_dir = DC_SHARE_DIR.'/'.$dirname;
- $failed = false;
- if (!is_dir($my_share_dir)) {
- $failed = true;
-
-
- if (ini_get('safe_mode') != false) return($failed);
- if (is_writeable(DC_SHARE_DIR)) {
- @umask(000);
- if (@mkdir($my_share_dir, 0777)) {
- $failed = false;
-
- if ($fh = @fopen($my_share_dir.'/.htaccess', "wb")) {
- $deny_str = $protect?'':'#';
- $deny_str .= "Deny from all\n";
- fwrite($fh,
- "# Comment/uncomment the lines below depending of your needs\n".
- "# To deny any access to this directory\n".
- $deny_str
- );
- fclose($fh);
- }
- }
- }
- }
- return($failed);
- }
-
- function loadPluginConfig($plugin_name)
- {
- $cfg_file = DC_SHARE_DIR.'/'.$plugin_name.'/'.$plugin_name.'.ini';
- if (@file_exists($cfg_file)) {
- return(iniFile::read($cfg_file, true));
- } else {
- return(false);
- }
- }
-
- function savePluginConfig($plugin_name, $plugin_cfg)
- {
- $cfg_file = DC_SHARE_DIR.'/'.$plugin_name.'/'.$plugin_name.'.ini';
- if (!@file_exists($cfg_file)) {
- @umask(000);
- if (@touch($cfg_file)) {
- @chmod($cfg_file, 0664);
- }
- }
- $ini_file = new iniFile($cfg_file);
- if (!empty($plugin_cfg) && is_array($plugin_cfg)) {
- foreach ($plugin_cfg as $key => $value) {
- $ini_file->editVar($key, $value);
- }
- $ini_file->saveFile();
- if ($ini_file->file && defined('DC_UPDATE_FILE_W') && DC_UPDATE_FILE_W) {
- files::touch(DC_UPDATE_FILE,time());
- }
- }
- return($ini_file->file);
- }
- }
- }
- ?>
|