示例#1
0
function dc_admin_icon_url($img)
{
    global $core;
    $core->auth->user_prefs->addWorkspace('interface');
    $user_ui_iconset = @$core->auth->user_prefs->interface->iconset;
    if ($user_ui_iconset && $img) {
        $icon = false;
        if (preg_match('/^images\\/menu\\/(.+)$/', $img, $m) || preg_match('/^index\\.php\\?pf=(.+)$/', $img, $m)) {
            if ($m[1]) {
                $icon = path::real(dirname(__FILE__) . '/../../admin/images/iconset/' . $user_ui_iconset . '/' . $m[1], false);
                if ($icon !== false) {
                    $allow_types = array('png', 'jpg', 'jpeg', 'gif');
                    if (is_file($icon) && is_readable($icon) && in_array(files::getExtension($icon), $allow_types)) {
                        return DC_ADMIN_URL . 'images/iconset/' . $user_ui_iconset . '/' . $m[1];
                    }
                }
            }
        }
    }
    return $img;
}
 public function execute()
 {
     // Get theme path
     $path = $this->core->blog->themes_path;
     $theme = $this->core->blog->settings->system->theme;
     $dir = path::real($path . '/' . $theme);
     if (empty($path) || empty($theme) || !is_dir($dir)) {
         return false;
     }
     // Create zip
     @set_time_limit(300);
     $fp = fopen('php://output', 'wb');
     $zip = new fileZip($fp);
     $zip->addExclusion('#(^|/).(.*?)_(m|s|sq|t).jpg$#');
     $zip->addDirectory($dir . '/', '', true);
     // Log task execution here as we sent file and stop script
     $this->log();
     // Send zip
     header('Content-Disposition: attachment;filename=theme-' . $theme . '.zip');
     header('Content-Type: application/x-zip');
     $zip->write();
     unset($zip);
     exit(1);
 }
	protected function __flushCache() {
		$this->__putLog('Flushing cache');
		$sCacheFiles = files::scanDir($this->sCacheDir);
		foreach ($sCacheFiles as $v) {
			$sCacheFile = $this->sCacheDir.'/'.$v;
			$sCacheFile = path::clean(path::real($sCacheFile));
			if (is_file($sCacheFile)) {
				if (time() - filemtime($sCacheFile) >= $this->nCacheTime) {
					unlink($sCacheFile);
					$this->__putLog('Deleting '.$v);
				}
			}
		}
		$sCacheFiles = files::scanDir($this->sCacheDir);
		return true;
	}
示例#4
0
 /**
  * Delete an image from images folder (with its thumbnails if any)
  *
  * @param  string $folder images folder
  * @param  string $img    image filename
  */
 public static function dropImage($folder, $img)
 {
     global $core;
     $img = path::real(self::imagesPath($folder) . '/' . $img);
     if (is_writable(dirname($img))) {
         // Delete thumbnails if any
         try {
             $media = new dcMedia($core);
             $media->imageThumbRemove($img);
         } catch (Exception $e) {
             $core->error->add($e->getMessage());
         }
         // Delete image
         @unlink($img);
     }
 }
示例#5
0
 public function displayModules($cols = array('name', 'config', 'version', 'desc'), $actions = array(), $nav_limit = false)
 {
     echo '<form action="' . $this->getURL() . '" method="post" class="modules-form-actions">' . '<div id="' . html::escapeHTML($this->list_id) . '" class="modules' . (in_array('expander', $cols) ? ' expandable' : '') . ' one-box">';
     $sort_field = $this->getSort();
     # Sort modules by id
     $modules = $this->getSearch() === null ? self::sortModules($this->data, $sort_field, $this->sort_asc) : $this->data;
     $res = '';
     $count = 0;
     foreach ($modules as $id => $module) {
         # Show only requested modules
         if ($nav_limit && $this->getSearch() === null) {
             $char = substr($module[$sort_field], 0, 1);
             if (!in_array($char, $this->nav_list)) {
                 $char = $this->nav_special;
             }
             if ($this->getIndex() != $char) {
                 continue;
             }
         }
         $current = $this->core->blog->settings->system->theme == $id && $this->modules->moduleExists($id);
         $distrib = self::isDistributedModule($id) ? ' dc-box' : '';
         $line = '<div class="box ' . ($current ? 'medium current-theme' : 'theme') . $distrib . '">';
         if (in_array('name', $cols) && !$current) {
             $line .= '<h4 class="module-name">';
             if (in_array('checkbox', $cols)) {
                 $line .= '<label for="' . html::escapeHTML($this->list_id) . '_modules_' . html::escapeHTML($id) . '">' . form::checkbox(array('modules[' . $count . ']', html::escapeHTML($this->list_id) . '_modules_' . html::escapeHTML($id)), html::escapeHTML($id)) . html::escapeHTML($module['name']) . '</label>';
             } else {
                 $line .= form::hidden(array('modules[' . $count . ']'), html::escapeHTML($id)) . html::escapeHTML($module['name']);
             }
             $line .= $this->core->formNonce() . '</h4>';
         }
         # Display score only for debug purpose
         if (in_array('score', $cols) && $this->getSearch() !== null && defined('DC_DEBUG') && DC_DEBUG) {
             $line .= '<p class="module-score debug">' . sprintf(__('Score: %s'), $module['score']) . '</p>';
         }
         if (in_array('sshot', $cols)) {
             # Screenshot from url
             if (preg_match('#^http(s)?://#', $module['sshot'])) {
                 $sshot = $module['sshot'];
             } elseif (file_exists($this->core->blog->themes_path . '/' . $id . '/screenshot.jpg')) {
                 $sshot = $this->getURL('shot=' . rawurlencode($id));
             } else {
                 $sshot = 'images/noscreenshot.png';
             }
             $line .= '<div class="module-sshot"><img src="' . $sshot . '" alt="' . sprintf(__('%s screenshot.'), html::escapeHTML($module['name'])) . '" /></div>';
         }
         $line .= '<div class="module-infos toggle-bloc">';
         if (in_array('name', $cols) && $current) {
             $line .= '<h4 class="module-name">';
             if (in_array('checkbox', $cols)) {
                 $line .= '<label for="' . html::escapeHTML($this->list_id) . '_modules_' . html::escapeHTML($id) . '">' . form::checkbox(array('modules[' . $count . ']', html::escapeHTML($this->list_id) . '_modules_' . html::escapeHTML($id)), html::escapeHTML($id)) . html::escapeHTML($module['name']) . '</label>';
             } else {
                 $line .= form::hidden(array('modules[' . $count . ']'), html::escapeHTML($id)) . html::escapeHTML($module['name']);
             }
             $line .= '</h4>';
         }
         $line .= '<p>';
         if (in_array('desc', $cols)) {
             $line .= '<span class="module-desc">' . html::escapeHTML(__($module['desc'])) . '</span> ';
         }
         if (in_array('author', $cols)) {
             $line .= '<span class="module-author">' . sprintf(__('by %s'), html::escapeHTML($module['author'])) . '</span> ';
         }
         if (in_array('version', $cols)) {
             $line .= '<span class="module-version">' . sprintf(__('version %s'), html::escapeHTML($module['version'])) . '</span> ';
         }
         if (in_array('current_version', $cols)) {
             $line .= '<span class="module-current-version">' . sprintf(__('(current version %s)'), html::escapeHTML($module['current_version'])) . '</span> ';
         }
         if (in_array('parent', $cols) && !empty($module['parent'])) {
             if ($this->modules->moduleExists($module['parent'])) {
                 $line .= '<span class="module-parent-ok">' . sprintf(__('(built on "%s")'), html::escapeHTML($module['parent'])) . '</span> ';
             } else {
                 $line .= '<span class="module-parent-missing">' . sprintf(__('(requires "%s")'), html::escapeHTML($module['parent'])) . '</span> ';
             }
         }
         $has_details = in_array('details', $cols) && !empty($module['details']);
         $has_support = in_array('support', $cols) && !empty($module['support']);
         if ($has_details || $has_support) {
             $line .= '<span class="mod-more">';
             if ($has_details) {
                 $line .= '<a class="module-details" href="' . $module['details'] . '">' . __('Details') . '</a>';
             }
             if ($has_support) {
                 $line .= ' - <a class="module-support" href="' . $module['support'] . '">' . __('Support') . '</a>';
             }
             $line .= '</span>';
         }
         $line .= '</p>' . '</div>';
         $line .= '<div class="module-actions toggle-bloc">';
         # Plugins actions
         if ($current) {
             # _GET actions
             if (file_exists(path::real($this->core->blog->themes_path . '/' . $id) . '/style.css')) {
                 $theme_url = preg_match('#^http(s)?://#', $this->core->blog->settings->system->themes_url) ? http::concatURL($this->core->blog->settings->system->themes_url, '/' . $id) : http::concatURL($this->core->blog->url, $this->core->blog->settings->system->themes_url . '/' . $id);
                 $line .= '<p><a href="' . $theme_url . '/style.css">' . __('View stylesheet') . '</a></p>';
             }
             $line .= '<div class="current-actions">';
             if (file_exists(path::real($this->core->blog->themes_path . '/' . $id) . '/_config.php')) {
                 $line .= '<p><a href="' . $this->getURL('module=' . $id . '&amp;conf=1', false) . '" class="button submit">' . __('Configure theme') . '</a></p>';
             }
             # --BEHAVIOR-- adminCurrentThemeDetails
             $line .= $this->core->callBehavior('adminCurrentThemeDetails', $this->core, $id, $module);
             $line .= '</div>';
         }
         # _POST actions
         if (!empty($actions)) {
             $line .= '<p>' . implode(' ', $this->getActions($id, $module, $actions)) . '</p>';
         }
         $line .= '</div>';
         $line .= '</div>';
         $count++;
         $res = $current ? $line . $res : $res . $line;
     }
     echo $res . '</div>';
     if (!$count && $this->getSearch() === null) {
         echo '<p class="message">' . __('No themes matched your search.') . '</p>';
     } elseif ((in_array('checkbox', $cols) || $count > 1) && !empty($actions) && $this->core->auth->isSuperAdmin()) {
         $buttons = $this->getGlobalActions($actions, in_array('checkbox', $cols));
         if (!empty($buttons)) {
             if (in_array('checkbox', $cols)) {
                 echo '<p class="checkboxes-helpers"></p>';
             }
             echo '<div>' . implode(' ', $buttons) . '</div>';
         }
     }
     echo '</form>';
     return $this;
 }
示例#6
0
# Copyright (c) 2003-2006 Olivier Meunier and contributors. All rights
# reserved.
#
# DotClear is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# DotClear is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with DotClear; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# ***** END LICENSE BLOCK *****
l10n::set(dirname(__FILE__) . '/locales/' . $_lang . '/main');
$css_file = path::real($core->blog->themes_path) . '/' . $core->blog->settings->theme . '/style.css';
if (!is_file($css_file) && !is_writable(dirname($css_file))) {
    throw new Exception(sprintf(__('File %s does not exist and directory %s is not writable.'), $css_file, dirname($css_file)));
}
if (isset($_POST['css'])) {
    @($fp = fopen($css_file, 'wb'));
    fwrite($fp, $_POST['css']);
    fclose($fp);
    echo '<div class="message"><p>' . __('Style sheet upgraded.') . '</p></div>';
}
$css_content = is_file($css_file) ? file_get_contents($css_file) : '';
echo '<p class="area"><label>' . __('Style sheet:') . ' ' . form::textarea('css', 60, 20, html::escapeHTML($css_content)) . '</label></p>';
示例#7
0
 protected function getFilesInDir($dir, $ext = null, $prefix = '', $model = null)
 {
     $dir = path::real($dir);
     if (!$dir || !is_dir($dir) || !is_readable($dir)) {
         return array();
     }
     $d = dir($dir);
     $res = array();
     while (($f = $d->read()) !== false) {
         if (is_file($dir . '/' . $f) && !preg_match('/^\\./', $f) && (!$ext || preg_match('/\\.' . preg_quote($ext) . '$/i', $f))) {
             if (!$model || preg_match('/^' . preg_quote($model) . '$/i', $f)) {
                 $res[$prefix . $f] = $dir . '/' . $f;
             }
         }
     }
     return $res;
 }
示例#8
0
}
$DBDRIVER = !empty($_POST['DBDRIVER']) ? $_POST['DBDRIVER'] : (function_exists('mysqli_connect') ? 'mysqli' : 'mysql');
$DBHOST = !empty($_POST['DBHOST']) ? $_POST['DBHOST'] : '';
$DBNAME = !empty($_POST['DBNAME']) ? $_POST['DBNAME'] : '';
$DBUSER = !empty($_POST['DBUSER']) ? $_POST['DBUSER'] : '';
$DBPASSWORD = !empty($_POST['DBPASSWORD']) ? $_POST['DBPASSWORD'] : '';
$DBPREFIX = !empty($_POST['DBPREFIX']) ? $_POST['DBPREFIX'] : 'dc_';
if (!empty($_POST)) {
    try {
        if ($DBDRIVER == 'sqlite') {
            if (strpos($DBNAME, '/') === false) {
                $sqlite_db_directory = dirname(DC_RC_PATH) . '/../db/';
                files::makeDir($sqlite_db_directory, true);
                # Can we write sqlite_db_directory ?
                if (!is_writable($sqlite_db_directory)) {
                    throw new Exception(sprintf(__('Cannot write "%s" directory.'), path::real($sqlite_db_directory, false)));
                }
                $DBNAME = $sqlite_db_directory . $DBNAME;
            }
        }
        # Tries to connect to database
        try {
            $con = dbLayer::init($DBDRIVER, $DBHOST, $DBNAME, $DBUSER, $DBPASSWORD);
        } catch (Exception $e) {
            throw new Exception('<p>' . __($e->getMessage()) . '</p>');
        }
        # Checks system capabilites
        require dirname(__FILE__) . '/check.php';
        if (!dcSystemCheck($con, $_e)) {
            $can_install = false;
            throw new Exception('<p>' . __('Dotclear cannot be installed.') . '</p><ul><li>' . implode('</li><li>', $_e) . '</li></ul>');
示例#9
0
 /**
  * Constructor
  *
  * Creates an instance of fileItem object.
  *
  * @param string	$file		Absolute file or directory path
  * @param string	$root		File root path
  * @param string	$root_url		File root URL
  */
 public function __construct($file, $root, $root_url = '')
 {
     $file = path::real($file);
     $stat = stat($file);
     $path = path::info($file);
     $rel = preg_replace('/^' . preg_quote($root, '/') . '\\/?/', '', $file);
     $this->file = $file;
     $this->basename = $path['basename'];
     $this->dir = $path['dirname'];
     $this->relname = $rel;
     $this->file_url = str_replace('%2F', '/', rawurlencode($rel));
     $this->file_url = $root_url . $this->file_url;
     $this->dir_url = dirname($this->file_url);
     $this->extension = $path['extension'];
     $this->mtime = $stat[9];
     $this->size = $stat[7];
     $this->mode = $stat[2];
     $this->uid = $stat[4];
     $this->gid = $stat[5];
     $this->w = is_writable($file);
     $this->d = is_dir($file);
     $this->f = is_file($file);
     $this->x = file_exists($file . '/.');
     $this->del = files::isDeletable($file);
     $this->type = $this->d ? null : files::getMimeType($file);
     $this->type_prefix = preg_replace('/^(.+?)\\/.+$/', '$1', $this->type);
 }
示例#10
0
define('DC_DBPASSWORD', $_ENV['DC_DBPASSWORD']);
// Database name
define('DC_DBNAME', $_ENV['DC_DBNAME']);
// Tables' prefix
define('DC_DBPREFIX', isset($_ENV['DC_DBPREFIX']) ? $_ENV['DC_DBPREFIX'] : 'dc_');
// Persistent database connection
define('DC_DBPERSIST', isset($_ENV['DC_DBPERSIST']) ? $_ENV['DC_DBPERSIST'] : false);
// Crypt key (password storage)
define('DC_MASTER_KEY', $_ENV['DC_MASTER_KEY']);
// Admin URL. You need to set it for some features.
define('DC_ADMIN_URL', $_ENV['DC_ADMIN_URL']);
// Admin mail from address. For password recovery and such.
define('DC_ADMIN_MAILFROM', $_ENV['DC_ADMIN_MAILFROM']);
// Cookie's name
define('DC_SESSION_NAME', isset($_ENV['DC_SESSION_NAME']) ? $_ENV['DC_SESSION_NAME'] : 'dcxd');
// Plugins root
define('DC_PLUGINS_ROOT', isset($_ENV['DC_PLUGINS_ROOT']) ? $_ENV['DC_PLUGINS_ROOT'] : dirname(__FILE__) . '/../plugins');
// Template cache directory
define('DC_TPL_CACHE', isset($_ENV['DC_TPL_CACHE']) ? $_ENV['DC_TPL_CACHE'] : path::real(dirname(__FILE__) . '/..') . '/cache');
// If you have PATH_INFO issue, uncomment following lines
//if (!isset($_SERVER['ORIG_PATH_INFO'])) {
//	$_SERVER['ORIG_PATH_INFO'] = '';
//}
//$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
// If you have mail problems, uncomment following lines and adapt it to your hosting configuration
// For more information about this setting, please refer to http://doc.dotclear.net/2.0/admin/install/custom-sendmail
//function _mail($to,$subject,$message,$headers)
//{
//	socketMail::$smtp_relay = 'my.smtp.relay.org';
//	socketMail::mail($to,$subject,$message,$headers);
//}
示例#11
0
文件: config.php 项目: Git-Host/AMPPS
define('DC_DBPASSWORD', '[[softdbpass]]');
// Database name
define('DC_DBNAME', '[[softdb]]');
// Tables' prefix
define('DC_DBPREFIX', '[[dbprefix]]');
// Persistent database connection
define('DC_DBPERSIST', false);
// Crypt key (password storage)
define('DC_MASTER_KEY', '[[secret]]');
// Admin URL. You need to set it for some features.
define('DC_ADMIN_URL', '[[softurl]]/admin/');
// Admin mail from address. For password recovery and such.
define('DC_ADMIN_MAILFROM', '[[admin_email]]');
// Cookie's name
define('DC_SESSION_NAME', 'dcxd');
// Plugins root
define('DC_PLUGINS_ROOT', dirname(__FILE__) . '/../plugins');
// Template cache directory
define('DC_TPL_CACHE', path::real(dirname(__FILE__) . '/..') . '/cache');
// If you have PATH_INFO issue, uncomment following lines
//if (!isset($_SERVER['ORIG_PATH_INFO'])) {
//	$_SERVER['ORIG_PATH_INFO'] = '';
//}
//$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
// If you have mail problems, uncomment following lines and adapt it to your hosting configuration
// For more information about this setting, please refer to http://doc.dotclear.net/2.0/admin/install/custom-sendmail
//function _mail($to,$subject,$message,$headers)
//{
//	socketMail::$smtp_relay = 'my.smtp.relay.org';
//	socketMail::mail($to,$subject,$message,$headers);
//}
示例#12
0
文件: media.php 项目: nikrou/dotclear
if ($dir && !empty($_POST['medias']) && !empty($_POST['delete_medias'])) {
    try {
        foreach ($_POST['medias'] as $media) {
            $core->media->removeItem(rawurldecode($media));
        }
        dcPage::addSuccessNotice(sprintf(__('Successfully delete one media.', 'Successfully delete %d medias.', count($_POST['medias'])), count($_POST['medias'])));
        $core->adminurl->redirect('admin.media', $page_url_params);
    } catch (Exception $e) {
        $core->error->add($e->getMessage());
    }
}
# Removing item from popup only
if ($dir && !empty($_POST['rmyes']) && !empty($_POST['remove'])) {
    $_POST['remove'] = rawurldecode($_POST['remove']);
    try {
        if (is_dir(path::real($core->media->getPwd() . '/' . path::clean($_POST['remove'])))) {
            $msg = __('Directory has been successfully removed.');
        } else {
            $msg = __('File has been successfully removed.');
        }
        $core->media->removeItem($_POST['remove']);
        dcPage::addSuccessNotice($msg);
        $core->adminurl->redirect('admin.media', $page_url_params);
    } catch (Exception $e) {
        $core->error->add($e->getMessage());
    }
}
# Rebuild directory
if ($dir && $core->auth->isSuperAdmin() && !empty($_POST['rebuild'])) {
    try {
        $core->media->rebuild($d);
示例#13
0
 public function run()
 {
     require_once LIB_PATH . 'clearbricks/jelix.inc.php';
     require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php';
     $appPath = $this->getParam('path');
     $appPath = $this->getRealPath($appPath);
     $appName = basename($appPath);
     $appPath .= '/';
     if (file_exists($appPath)) {
         throw new Exception("this application is already created");
     }
     $this->config = JelixScript::loadConfig($appName);
     $this->config->infoIDSuffix = $this->config->newAppInfoIDSuffix;
     $this->config->infoWebsite = $this->config->newAppInfoWebsite;
     $this->config->infoLicence = $this->config->newAppInfoLicence;
     $this->config->infoLicenceUrl = $this->config->newAppInfoLicenceUrl;
     $this->config->newAppInfoLocale = $this->config->newAppInfoLocale;
     $this->config->newAppInfoCopyright = $this->config->newAppInfoCopyright;
     $this->config->initAppPaths($appPath);
     jApp::setEnv('jelix-scripts');
     jApp::initLegacy();
     JelixScript::checkTempPath();
     if ($p = $this->getOption('-wwwpath')) {
         $wwwpath = path::real($appPath . $p, false) . '/';
     } else {
         $wwwpath = jApp::wwwPath();
     }
     $this->createDir($appPath);
     $this->createDir(jApp::tempBasePath());
     $this->createDir($wwwpath);
     $varPath = jApp::varPath();
     $configPath = jApp::configPath();
     $this->createDir($varPath);
     $this->createDir(jApp::logPath());
     $this->createDir($configPath);
     $this->createDir($configPath . 'index/');
     $this->createDir($varPath . 'overloads/');
     $this->createDir($varPath . 'themes/');
     $this->createDir($varPath . 'themes/default/');
     $this->createDir($varPath . 'uploads/');
     $this->createDir($varPath . 'sessions/');
     $this->createDir($varPath . 'mails/');
     $this->createDir($appPath . 'install');
     $this->createDir($appPath . 'modules');
     $this->createDir($appPath . 'plugins');
     $this->createDir($appPath . 'plugins/coord/');
     $this->createDir($appPath . 'plugins/tpl/');
     $this->createDir($appPath . 'plugins/tpl/common');
     $this->createDir($appPath . 'plugins/tpl/html');
     $this->createDir($appPath . 'plugins/tpl/text');
     $this->createDir($appPath . 'plugins/db/');
     $this->createDir($appPath . 'plugins/auth/');
     $this->createDir($appPath . 'responses');
     $this->createDir($appPath . 'tests');
     $this->createDir(jApp::scriptsPath());
     $param = array();
     $param['default_id'] = $appName . $this->config->infoIDSuffix;
     if ($this->getOption('-nodefaultmodule')) {
         $param['tplname'] = 'jelix~defaultmain';
         $param['modulename'] = 'jelix';
     } else {
         // note: since module name are used for name of generated name,
         // only this characters are allowed
         $param['modulename'] = preg_replace('/([^a-zA-Z_0-9])/', '_', $appName);
         $param['tplname'] = $param['modulename'] . '~main';
     }
     $param['config_file'] = 'index/config.ini.php';
     $param['rp_temp'] = $this->getRelativePath($appPath, jApp::tempBasePath());
     $param['rp_var'] = $this->getRelativePath($appPath, jApp::varPath());
     $param['rp_log'] = $this->getRelativePath($appPath, jApp::logPath());
     $param['rp_conf'] = $this->getRelativePath($appPath, $configPath);
     $param['rp_www'] = $this->getRelativePath($appPath, $wwwpath);
     $param['rp_cmd'] = $this->getRelativePath($appPath, jApp::scriptsPath());
     $param['rp_jelix'] = $this->getRelativePath($appPath, JELIX_LIB_PATH);
     $param['rp_app'] = $this->getRelativePath($wwwpath, $appPath);
     $this->createFile($appPath . '.htaccess', 'htaccess_deny', $param);
     $this->createFile($appPath . 'project.xml', 'project.xml.tpl', $param);
     $this->createFile($appPath . 'cmd.php', 'cmd.php.tpl', $param);
     $this->createFile($configPath . 'defaultconfig.ini.php', 'var/config/defaultconfig.ini.php.tpl', $param);
     $this->createFile($configPath . 'profiles.ini.php', 'var/config/profiles.ini.php.tpl', $param);
     $this->createFile($configPath . 'urls.xml', 'var/config/urls.xml.tpl', $param);
     //$this->createFile(JELIX_APP_CONFIG_PATH.'installer.ini.php', 'var/config/installer.ini.php.tpl', $param);
     $this->createFile($configPath . 'index/config.ini.php', 'var/config/index/config.ini.php.tpl', $param);
     $this->createFile($appPath . 'responses/myHtmlResponse.class.php', 'responses/myHtmlResponse.class.php.tpl', $param);
     $this->createFile($appPath . 'install/installer.php', 'installer/installer.php.tpl', $param);
     $this->createFile($appPath . 'tests/runtests.php', 'tests/runtests.php', $param);
     $this->createFile($wwwpath . 'index.php', 'www/index.php.tpl', $param);
     $this->createFile($wwwpath . '.htaccess', 'htaccess_allow', $param);
     $param['php_rp_temp'] = $this->convertRp($param['rp_temp']);
     $param['php_rp_var'] = $this->convertRp($param['rp_var']);
     $param['php_rp_log'] = $this->convertRp($param['rp_log']);
     $param['php_rp_conf'] = $this->convertRp($param['rp_conf']);
     $param['php_rp_www'] = $this->convertRp($param['rp_www']);
     $param['php_rp_cmd'] = $this->convertRp($param['rp_cmd']);
     $param['php_rp_jelix'] = $this->convertRp($param['rp_jelix']);
     $this->createFile($appPath . 'application.init.php', 'application.init.php.tpl', $param);
     $installer = new jInstaller(new textInstallReporter('warning'));
     $installer->installApplication();
     $moduleok = true;
     if (!$this->getOption('-nodefaultmodule')) {
         try {
             $cmd = JelixScript::getCommand('createmodule', $this->config);
             $cmd->initOptParam(array('-addinstallzone' => true), array('module' => $param['modulename']));
             $cmd->run();
             $this->createFile($appPath . 'modules/' . $param['modulename'] . '/templates/main.tpl', 'module/main.tpl.tpl', $param);
         } catch (Exception $e) {
             $moduleok = false;
             echo "The module has not been created because of this error: " . $e->getMessage() . "\nHowever the application has been created\n";
         }
     }
     if ($this->getOption('-withcmdline')) {
         if (!$this->getOption('-nodefaultmodule') && $moduleok) {
             $agcommand = JelixScript::getCommand('createctrl', $this->config);
             $options = array('-cmdline' => true);
             $agcommand->initOptParam($options, array('module' => $param['modulename'], 'name' => 'default', 'method' => 'index'));
             $agcommand->run();
         }
         $agcommand = JelixScript::getCommand('createentrypoint', $this->config);
         $options = array('-type' => 'cmdline');
         $parameters = array('name' => $param['modulename']);
         $agcommand->initOptParam($options, $parameters);
         $agcommand->run();
     }
 }
示例#14
0
function dotclearUpgrade($core)
{
    $cleanup_sessions = false;
    // update it in a step that needed sessions to be removed
    $version = $core->getVersion('core');
    if ($version === null) {
        return false;
    }
    if (version_compare($version, DC_VERSION, '<') == 1 || strpos(DC_VERSION, 'dev')) {
        try {
            if ($core->con->driver() == 'sqlite') {
                return false;
                // Need to find a way to upgrade sqlite database
            }
            # Database upgrade
            $_s = new dbStruct($core->con, $core->prefix);
            require dirname(__FILE__) . '/db-schema.php';
            $si = new dbStruct($core->con, $core->prefix);
            $changes = $si->synchronize($_s);
            /* Some other upgrades
            			------------------------------------ */
            # Populate media_dir field (since 2.0-beta3.3)
            if (version_compare($version, '2.0-beta3.3', '<')) {
                $strReq = 'SELECT media_id, media_file FROM ' . $core->prefix . 'media ';
                $rs_m = $core->con->select($strReq);
                while ($rs_m->fetch()) {
                    $cur = $core->con->openCursor($core->prefix . 'media');
                    $cur->media_dir = dirname($rs_m->media_file);
                    $cur->update('WHERE media_id = ' . (int) $rs_m->media_id);
                }
            }
            if (version_compare($version, '2.0-beta7.3', '<')) {
                # Blowup becomes default theme
                $strReq = 'UPDATE ' . $core->prefix . 'setting ' . "SET setting_value = '%s' " . "WHERE setting_id = 'theme' " . "AND setting_value = '%s' " . 'AND blog_id IS NOT NULL ';
                $core->con->execute(sprintf($strReq, 'blueSilence', 'default'));
                $core->con->execute(sprintf($strReq, 'default', 'blowup'));
            }
            if (version_compare($version, '2.1-alpha2-r2383', '<')) {
                $schema = dbSchema::init($core->con);
                $schema->dropUnique($core->prefix . 'category', $core->prefix . 'uk_cat_title');
                # Reindex categories
                $rs = $core->con->select('SELECT cat_id, cat_title, blog_id ' . 'FROM ' . $core->prefix . 'category ' . 'ORDER BY blog_id ASC , cat_position ASC ');
                $cat_blog = $rs->blog_id;
                $i = 2;
                while ($rs->fetch()) {
                    if ($cat_blog != $rs->blog_id) {
                        $i = 2;
                    }
                    $core->con->execute('UPDATE ' . $core->prefix . 'category SET ' . 'cat_lft = ' . $i++ . ', cat_rgt = ' . $i++ . ' ' . 'WHERE cat_id = ' . (int) $rs->cat_id);
                    $cat_blog = $rs->blog_id;
                }
            }
            if (version_compare($version, '2.1.6', '<=')) {
                # ie7js has been upgraded
                $ie7files = array('ie7-base64.php ', 'ie7-content.htc', 'ie7-core.js', 'ie7-css2-selectors.js', 'ie7-css3-selectors.js', 'ie7-css-strict.js', 'ie7-dhtml.js', 'ie7-dynamic-attributes.js', 'ie7-fixed.js', 'ie7-graphics.js', 'ie7-html4.js', 'ie7-ie5.js', 'ie7-layout.js', 'ie7-load.htc', 'ie7-object.htc', 'ie7-overflow.js', 'ie7-quirks.js', 'ie7-server.css', 'ie7-standard-p.js', 'ie7-xml-extras.js');
                foreach ($ie7files as $f) {
                    @unlink(DC_ROOT . '/admin/js/ie7/' . $f);
                }
            }
            if (version_compare($version, '2.2-alpha1-r3043', '<')) {
                # metadata has been integrated to the core.
                $core->plugins->loadModules(DC_PLUGINS_ROOT);
                if ($core->plugins->moduleExists('metadata')) {
                    $core->plugins->deleteModule('metadata');
                }
                # Tags template class has been renamed
                $sqlstr = 'SELECT blog_id, setting_id, setting_value ' . 'FROM ' . $core->prefix . 'setting ' . 'WHERE (setting_id = \'widgets_nav\' OR setting_id = \'widgets_extra\') ' . 'AND setting_ns = \'widgets\';';
                $rs = $core->con->select($sqlstr);
                while ($rs->fetch()) {
                    $widgetsettings = base64_decode($rs->setting_value);
                    $widgetsettings = str_replace('s:11:"tplMetadata"', 's:7:"tplTags"', $widgetsettings);
                    $cur = $core->con->openCursor($core->prefix . 'setting');
                    $cur->setting_value = base64_encode($widgetsettings);
                    $sqlstr = 'WHERE setting_id = \'' . $rs->setting_id . '\' AND setting_ns = \'widgets\' ' . 'AND blog_id ' . ($rs->blog_id == NULL ? 'is NULL' : '= \'' . $core->con->escape($rs->blog_id) . '\'');
                    $cur->update($sqlstr);
                }
            }
            if (version_compare($version, '2.3', '<')) {
                # Add global favorites
                $init_fav = array();
                $init_fav['new_post'] = array('new_post', 'New entry', 'post.php', 'images/menu/edit.png', 'images/menu/edit-b.png', 'usage,contentadmin', null, null);
                $init_fav['newpage'] = array('newpage', 'New page', 'plugin.php?p=pages&amp;act=page', 'index.php?pf=pages/icon-np.png', 'index.php?pf=pages/icon-np-big.png', 'contentadmin,pages', null, null);
                $init_fav['media'] = array('media', 'Media manager', 'media.php', 'images/menu/media.png', 'images/menu/media-b.png', 'media,media_admin', null, null);
                $init_fav['widgets'] = array('widgets', 'Presentation widgets', 'plugin.php?p=widgets', 'index.php?pf=widgets/icon.png', 'index.php?pf=widgets/icon-big.png', 'admin', null, null);
                $init_fav['blog_theme'] = array('blog_theme', 'Blog appearance', 'blog_theme.php', 'images/menu/themes.png', 'images/menu/blog-theme-b.png', 'admin', null, null);
                $count = 0;
                foreach ($init_fav as $k => $f) {
                    $t = array('name' => $f[0], 'title' => $f[1], 'url' => $f[2], 'small-icon' => $f[3], 'large-icon' => $f[4], 'permissions' => $f[5], 'id' => $f[6], 'class' => $f[7]);
                    $sqlstr = 'INSERT INTO ' . $core->prefix . 'pref (pref_id, user_id, pref_ws, pref_value, pref_type, pref_label) VALUES (' . '\'' . sprintf("g%03s", $count) . '\',NULL,\'favorites\',\'' . serialize($t) . '\',\'string\',NULL);';
                    $core->con->execute($sqlstr);
                    $count++;
                }
                # A bit of housecleaning for no longer needed files
                $remfiles = array('admin/style/cat-bg.png', 'admin/style/footer-bg.png', 'admin/style/head-logo.png', 'admin/style/tab-bg.png', 'admin/style/tab-c-l.png', 'admin/style/tab-c-r.png', 'admin/style/tab-l-l.png', 'admin/style/tab-l-r.png', 'admin/style/tab-n-l.png', 'admin/style/tab-n-r.png', 'inc/clearbricks/_common.php', 'inc/clearbricks/common/lib.crypt.php', 'inc/clearbricks/common/lib.date.php', 'inc/clearbricks/common/lib.files.php', 'inc/clearbricks/common/lib.form.php', 'inc/clearbricks/common/lib.html.php', 'inc/clearbricks/common/lib.http.php', 'inc/clearbricks/common/lib.l10n.php', 'inc/clearbricks/common/lib.text.php', 'inc/clearbricks/common/tz.dat', 'inc/clearbricks/common/_main.php', 'inc/clearbricks/dblayer/class.cursor.php', 'inc/clearbricks/dblayer/class.mysql.php', 'inc/clearbricks/dblayer/class.pgsql.php', 'inc/clearbricks/dblayer/class.sqlite.php', 'inc/clearbricks/dblayer/dblayer.php', 'inc/clearbricks/dbschema/class.dbschema.php', 'inc/clearbricks/dbschema/class.dbstruct.php', 'inc/clearbricks/dbschema/class.mysql.dbschema.php', 'inc/clearbricks/dbschema/class.pgsql.dbschema.php', 'inc/clearbricks/dbschema/class.sqlite.dbschema.php', 'inc/clearbricks/diff/lib.diff.php', 'inc/clearbricks/diff/lib.unified.diff.php', 'inc/clearbricks/filemanager/class.filemanager.php', 'inc/clearbricks/html.filter/class.html.filter.php', 'inc/clearbricks/html.validator/class.html.validator.php', 'inc/clearbricks/image/class.image.meta.php', 'inc/clearbricks/image/class.image.tools.php', 'inc/clearbricks/mail/class.mail.php', 'inc/clearbricks/mail/class.socket.mail.php', 'inc/clearbricks/net/class.net.socket.php', 'inc/clearbricks/net.http/class.net.http.php', 'inc/clearbricks/net.http.feed/class.feed.parser.php', 'inc/clearbricks/net.http.feed/class.feed.reader.php', 'inc/clearbricks/net.xmlrpc/class.net.xmlrpc.php', 'inc/clearbricks/pager/class.pager.php', 'inc/clearbricks/rest/class.rest.php', 'inc/clearbricks/session.db/class.session.db.php', 'inc/clearbricks/template/class.template.php', 'inc/clearbricks/text.wiki2xhtml/class.wiki2xhtml.php', 'inc/clearbricks/url.handler/class.url.handler.php', 'inc/clearbricks/zip/class.unzip.php', 'inc/clearbricks/zip/class.zip.php', 'themes/default/tpl/.htaccess', 'themes/default/tpl/404.html', 'themes/default/tpl/archive.html', 'themes/default/tpl/archive_month.html', 'themes/default/tpl/category.html', 'themes/default/tpl/home.html', 'themes/default/tpl/post.html', 'themes/default/tpl/search.html', 'themes/default/tpl/tag.html', 'themes/default/tpl/tags.html', 'themes/default/tpl/user_head.html', 'themes/default/tpl/_flv_player.html', 'themes/default/tpl/_footer.html', 'themes/default/tpl/_head.html', 'themes/default/tpl/_mp3_player.html', 'themes/default/tpl/_top.html');
                $remfolders = array('inc/clearbricks/common', 'inc/clearbricks/dblayer', 'inc/clearbricks/dbschema', 'inc/clearbricks/diff', 'inc/clearbricks/filemanager', 'inc/clearbricks/html.filter', 'inc/clearbricks/html.validator', 'inc/clearbricks/image', 'inc/clearbricks/mail', 'inc/clearbricks/net', 'inc/clearbricks/net.http', 'inc/clearbricks/net.http.feed', 'inc/clearbricks/net.xmlrpc', 'inc/clearbricks/pager', 'inc/clearbricks/rest', 'inc/clearbricks/session.db', 'inc/clearbricks/template', 'inc/clearbricks/text.wiki2xhtml', 'inc/clearbricks/url.handler', 'inc/clearbricks/zip', 'inc/clearbricks', 'themes/default/tpl');
                foreach ($remfiles as $f) {
                    @unlink(DC_ROOT . '/' . $f);
                }
                foreach ($remfolders as $f) {
                    @rmdir(DC_ROOT . '/' . $f);
                }
            }
            if (version_compare($version, '2.3.1', '<')) {
                # Remove unecessary file
                @unlink(DC_ROOT . '/' . 'inc/libs/clearbricks/.hgignore');
            }
            if (version_compare($version, '2.4.0', '<=')) {
                # setup media_exclusion
                $strReq = 'UPDATE ' . $core->prefix . 'setting ' . "SET setting_value = '/\\.php\$/i' " . "WHERE setting_id = 'media_exclusion' " . "AND setting_value = '' ";
                $core->con->execute($strReq);
            }
            if (version_compare($version, '2.5', '<=')) {
                # Try to disable daInstaller plugin if it has been installed outside the default plugins directory
                $path = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
                $default = path::real(dirname(__FILE__) . '/../../plugins/');
                foreach ($path as $root) {
                    if (!is_dir($root) || !is_readable($root)) {
                        continue;
                    }
                    if (substr($root, -1) != '/') {
                        $root .= '/';
                    }
                    if (($p = @dir($root)) === false) {
                        continue;
                    }
                    if (path::real($root) == $default) {
                        continue;
                    }
                    if (($d = @dir($root . 'daInstaller')) === false) {
                        continue;
                    }
                    $f = $root . '/daInstaller/_disabled';
                    if (!file_exists($f)) {
                        @file_put_contents($f, '');
                    }
                }
            }
            if (version_compare($version, '2.5.1', '<=')) {
                // Flash enhanced upload no longer needed
                @unlink(DC_ROOT . '/' . 'inc/swf/swfupload.swf');
            }
            if (version_compare($version, '2.6', '<=')) {
                // README has been replaced by README.md and CONTRIBUTING.md
                @unlink(DC_ROOT . '/' . 'README');
                // trackbacks are now merged into posts
                @unlink(DC_ROOT . '/' . 'admin/trackbacks.php');
                # daInstaller has been integrated to the core.
                # Try to remove it
                $path = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
                foreach ($path as $root) {
                    if (!is_dir($root) || !is_readable($root)) {
                        continue;
                    }
                    if (substr($root, -1) != '/') {
                        $root .= '/';
                    }
                    if (($p = @dir($root)) === false) {
                        continue;
                    }
                    if (($d = @dir($root . 'daInstaller')) === false) {
                        continue;
                    }
                    files::deltree($root . '/daInstaller');
                }
                # Some settings change, prepare db queries
                $strReqFormat = 'INSERT INTO ' . $core->prefix . 'setting';
                $strReqFormat .= ' (setting_id,setting_ns,setting_value,setting_type,setting_label)';
                $strReqFormat .= ' VALUES(\'%s\',\'system\',\'%s\',\'string\',\'%s\')';
                $strReqSelect = 'SELECT count(1) FROM ' . $core->prefix . 'setting';
                $strReqSelect .= ' WHERE setting_id = \'%s\'';
                $strReqSelect .= ' AND setting_ns = \'system\'';
                $strReqSelect .= ' AND blog_id IS NULL';
                # Add date and time formats
                $date_formats = array('%Y-%m-%d', '%m/%d/%Y', '%d/%m/%Y', '%Y/%m/%d', '%d.%m.%Y', '%b %e %Y', '%e %b %Y', '%Y %b %e', '%a, %Y-%m-%d', '%a, %m/%d/%Y', '%a, %d/%m/%Y', '%a, %Y/%m/%d', '%B %e, %Y', '%e %B, %Y', '%Y, %B %e', '%e. %B %Y', '%A, %B %e, %Y', '%A, %e %B, %Y', '%A, %Y, %B %e', '%A, %Y, %B %e', '%A, %e. %B %Y');
                $time_formats = array('%H:%M', '%I:%M', '%l:%M', '%Hh%M', '%Ih%M', '%lh%M');
                if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
                    $date_formats = array_map(create_function('$f', 'return str_replace(\'%e\',\'%#d\',$f);'), $date_formats);
                }
                $rs = $core->con->select(sprintf($strReqSelect, 'date_formats'));
                if ($rs->f(0) == 0) {
                    $strReq = sprintf($strReqFormat, 'date_formats', serialize($date_formats), 'Date formats examples');
                    $core->con->execute($strReq);
                }
                $rs = $core->con->select(sprintf($strReqSelect, 'time_formats'));
                if ($rs->f(0) == 0) {
                    $strReq = sprintf($strReqFormat, 'time_formats', serialize($time_formats), 'Time formats examples');
                    $core->con->execute($strReq);
                }
                # Add repository URL for themes and plugins as daInstaller move to core
                $rs = $core->con->select(sprintf($strReqSelect, 'store_plugin_url'));
                if ($rs->f(0) == 0) {
                    $strReq = sprintf($strReqFormat, 'store_plugin_url', 'http://update.dotaddict.org/dc2/plugins.xml', 'Plugins XML feed location');
                    $core->con->execute($strReq);
                }
                $rs = $core->con->select(sprintf($strReqSelect, 'store_theme_url'));
                if ($rs->f(0) == 0) {
                    $strReq = sprintf($strReqFormat, 'store_theme_url', 'http://update.dotaddict.org/dc2/themes.xml', 'Themes XML feed location');
                    $core->con->execute($strReq);
                }
            }
            if (version_compare($version, '2.7', '<=')) {
                # Some new settings should be initialized, prepare db queries
                $strReqFormat = 'INSERT INTO ' . $core->prefix . 'setting';
                $strReqFormat .= ' (setting_id,setting_ns,setting_value,setting_type,setting_label)';
                $strReqFormat .= ' VALUES(\'%s\',\'system\',\'%s\',\'string\',\'%s\')';
                $strReqCount = 'SELECT count(1) FROM ' . $core->prefix . 'setting';
                $strReqCount .= ' WHERE setting_id = \'%s\'';
                $strReqCount .= ' AND setting_ns = \'system\'';
                $strReqCount .= ' AND blog_id IS NULL';
                $strReqSelect = 'SELECT setting_value FROM ' . $core->prefix . 'setting';
                $strReqSelect .= ' WHERE setting_id = \'%s\'';
                $strReqSelect .= ' AND setting_ns = \'system\'';
                $strReqSelect .= ' AND blog_id IS NULL';
                # Add nb of posts for home (first page), copying nb of posts on every page
                $rs = $core->con->select(sprintf($strReqCount, 'nb_post_for_home'));
                if ($rs->f(0) == 0) {
                    $rs = $core->con->select(sprintf($strReqSelect, 'nb_post_per_page'));
                    $strReq = sprintf($strReqFormat, 'nb_post_for_home', $rs->f(0), 'Nb of posts on home (first page only)');
                    $core->con->execute($strReq);
                }
            }
            if (version_compare($version, '2.8.1', '<=')) {
                # switch from jQuery 1.11.1 to 1.11.2
                $strReq = 'UPDATE ' . $core->prefix . 'setting ' . " SET setting_value = '1.11.3' " . " WHERE setting_id = 'jquery_version' " . " AND setting_ns = 'system' " . " AND setting_value = '1.11.1' ";
                $core->con->execute($strReq);
                # setup media_exclusion (cope with php, php5, php7, … rather than only .php)
                $strReq = 'UPDATE ' . $core->prefix . 'setting ' . " SET setting_value = '/\\.php[0-9]*\$/i' " . " WHERE setting_id = 'media_exclusion' " . " AND setting_ns = 'system' " . " AND setting_value = '/\\.php\$/i' ";
                $core->con->execute($strReq);
                # Some new settings should be initialized, prepare db queries
                $strReq = 'INSERT INTO ' . $core->prefix . 'setting' . ' (setting_id,setting_ns,setting_value,setting_type,setting_label)' . ' VALUES(\'%s\',\'system\',\'%s\',\'boolean\',\'%s\')';
                $core->con->execute(sprintf($strReq, 'no_search', '0', 'Disable internal search system'));
            }
            if (version_compare($version, '2.8.2', '<=')) {
                # Update flie exclusion upload regex
                $strReq = 'UPDATE ' . $core->prefix . 'setting ' . " SET setting_value = '/\\.(phps?|pht(ml)?|phl)[0-9]*\$/i' " . " WHERE setting_id = 'media_exclusion' " . " AND setting_ns = 'system' " . " AND (setting_value = '/\\.php[0-9]*\$/i' " . "   OR setting_value = '/\\.php\$/i') ";
                $core->con->execute($strReq);
            }
            if (version_compare($version, '2.9', '<=')) {
                # Some new settings should be initialized, prepare db queries
                $strReq = 'INSERT INTO ' . $core->prefix . 'setting' . ' (setting_id,setting_ns,setting_value,setting_type,setting_label)' . ' VALUES(\'%s\',\'system\',\'%s\',\'%s\',\'%s\')';
                $core->con->execute(sprintf($strReq, 'media_video_width', '400', 'integer', 'Media video insertion width'));
                $core->con->execute(sprintf($strReq, 'media_video_height', '300', 'integer', 'Media video insertion height'));
                $core->con->execute(sprintf($strReq, 'media_flash_fallback', '1', 'boolean', 'Flash player fallback for audio and video media'));
            }
            $core->setVersion('core', DC_VERSION);
            $core->blogDefaults();
            # Drop content from session table if changes or if needed
            if ($changes != 0 || $cleanup_sessions) {
                $core->con->execute('DELETE FROM ' . $core->prefix . 'session ');
            }
            # Empty templates cache directory
            try {
                $core->emptyTemplatesCache();
            } catch (Exception $e) {
            }
            return $changes;
        } catch (Exception $e) {
            throw new Exception(__('Something went wrong with auto upgrade:') . ' ' . $e->getMessage());
        }
    }
    # No upgrade?
    return false;
}
示例#15
0
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK -----------------------------------------
require dirname(__FILE__) . '/../inc/admin/prepend.php';
dcPage::check('admin');
# -- Loading themes --
$core->themes = new dcThemes($core);
$core->themes->loadModules($core->blog->themes_path, null);
# -- Page helper --
$list = new adminThemesList($core->themes, $core->blog->themes_path, $core->blog->settings->system->store_theme_url);
adminThemesList::$distributed_modules = explode(',', DC_DISTRIB_THEMES);
# -- Theme screenshot --
if (!empty($_GET['shot']) && $list->modules->moduleExists($_GET['shot'])) {
    $f = path::real(empty($_GET['src']) ? $core->blog->themes_path . '/' . $_GET['shot'] . '/screenshot.jpg' : $core->blog->themes_path . '/' . $_GET['shot'] . '/' . path::clean($_GET['src']));
    if (!file_exists($f)) {
        $f = dirname(__FILE__) . '/images/noscreenshot.png';
    }
    http::cache(array_merge(array($f), get_included_files()));
    header('Content-Type: ' . files::getMimeType($f));
    header('Content-Length: ' . filesize($f));
    readfile($f);
    exit;
}
# -- Display module configuration page --
if ($list->setConfiguration($core->blog->settings->system->theme)) {
    # Get content before page headers
    include $list->includeConfiguration();
    # Gather content
    $list->getConfiguration();
示例#16
0
 public static function dropImage($img)
 {
     $img = path::real(self::imagesPath() . '/' . $img);
     if (is_writable(dirname($img))) {
         @unlink($img);
         @unlink(dirname($img) . '/.' . basename($img, '.png') . '_sq.jpg');
         @unlink(dirname($img) . '/.' . basename($img, '.png') . '_m.jpg');
         @unlink(dirname($img) . '/.' . basename($img, '.png') . '_s.jpg');
         @unlink(dirname($img) . '/.' . basename($img, '.png') . '_sq.jpg');
         @unlink(dirname($img) . '/.' . basename($img, '.png') . '_t.jpg');
     }
 }
示例#17
0
<?php

# -- BEGIN LICENSE BLOCK ---------------------------------------
#
# This file is part of Dotclear 2.
#
# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK -----------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
    return;
}
l10n::set(dirname(__FILE__) . '/locales/' . $_lang . '/main');
$css_file = path::real($core->blog->public_path) . '/custom_style.css';
if (!is_file($css_file) && !is_writable(dirname($css_file))) {
    throw new Exception(sprintf(__('File %s does not exist and directory %s is not writable.'), $css_file, dirname($css_file)));
}
if (isset($_POST['css'])) {
    @($fp = fopen($css_file, 'wb'));
    fwrite($fp, $_POST['css']);
    fclose($fp);
    dcPage::message(__('Style sheet upgraded.'), true, true);
}
$css_content = is_file($css_file) ? file_get_contents($css_file) : '';
echo '<p class="area"><label>' . __('Style sheet:') . '</label> ' . form::textarea('css', 60, 20, html::escapeHTML($css_content)) . '</p>';
示例#18
0
    trigger_error('Unable to open config file', E_USER_ERROR);
    exit;
}
require DC_RC_PATH;
if (empty($_GET['pf'])) {
    header('Content-Type: text/plain');
    http::head(404, 'Not Found');
    exit;
}
$allow_types = array('png', 'jpg', 'jpeg', 'gif', 'css', 'js', 'swf');
$pf = path::clean($_GET['pf']);
$paths = array_reverse(explode(PATH_SEPARATOR, DC_PLUGINS_ROOT));
# Adding admin/res folder here to load some stuff
$paths[] = dirname(__FILE__) . '/swf';
foreach ($paths as $m) {
    $PF = path::real($m . '/' . $pf);
    if ($PF !== false) {
        break;
    }
}
unset($paths);
if ($PF === false || !is_file($PF) || !is_readable($PF)) {
    header('Content-Type: text/plain');
    http::head(404, 'Not Found');
    exit;
}
if (!in_array(files::getExtension($PF), $allow_types)) {
    header('Content-Type: text/plain');
    http::head(404, 'Not Found');
    exit;
}
示例#19
0
 /**
  * Directory creation.
  *
  * Creates directory $f. If $r is true, attempts to create needed parents
  * directories.
  *
  * @param string	$f		Directory to create
  * @param boolean	$r		Create parent directories
  */
 public static function makeDir($f, $r = false)
 {
     if (empty($f)) {
         return;
     }
     if (DIRECTORY_SEPARATOR == '\\') {
         $f = str_replace('/', '\\', $f);
     }
     if (is_dir($f)) {
         return;
     }
     if ($r) {
         $dir = path::real($f, false);
         $dirs = array();
         while (!is_dir($dir)) {
             array_unshift($dirs, basename($dir));
             $dir = dirname($dir);
         }
         foreach ($dirs as $d) {
             $dir .= DIRECTORY_SEPARATOR . $d;
             if ($d != '' && !is_dir($dir)) {
                 self::makeDir($dir);
             }
         }
     } else {
         if (@mkdir($f) === false) {
             throw new Exception(__('Unable to create directory.'));
         }
         self::inheritChmod($f);
     }
 }
示例#20
0
    }
}
if (isset($_SERVER['DC_RC_PATH'])) {
    define('DC_RC_PATH', $_SERVER['DC_RC_PATH']);
} elseif (isset($_SERVER['REDIRECT_DC_RC_PATH'])) {
    define('DC_RC_PATH', $_SERVER['REDIRECT_DC_RC_PATH']);
} else {
    define('DC_RC_PATH', dirname(__FILE__) . '/config.php');
}
if (!is_file(DC_RC_PATH)) {
    $path = strpos($_SERVER['PHP_SELF'], '/admin') !== false ? '' : 'admin/';
    __error('Unable to open config file', 'There doesn\'t seem to be a <strong>config.php</strong> file. ' . 'I need this before we can get started. Need more help? ' . '<a href="http://doc.dotclear.net/2.0/admin/install">We got it</a>. ' . 'You can <a href="' . $path . 'install">create a <strong>config.php</strong> ' . 'file through a web interface</a>, but this doesn\'t work for all ' . 'server setups. The safest way is to manually create the file.', 10);
}
require DC_RC_PATH;
# Constants
define('DC_ROOT', path::real(dirname(__FILE__) . '/..'));
define('DC_VERSION', '2.1.6');
define('DC_DIGESTS', dirname(__FILE__) . '/digests');
define('DC_L10N_ROOT', dirname(__FILE__) . '/../locales');
define('DC_L10N_UPDATE_URL', 'http://services.dotclear.net/dc2.l10n/?version=%s');
if (!defined('DC_VENDOR_NAME')) {
    define('DC_VENDOR_NAME', 'Dotclear');
}
if (!defined('DC_XMLRPC_URL')) {
    define('DC_XMLRPC_URL', '%1$sxmlrpc/%2$s');
}
if (!defined('DC_ADMIN_SSL')) {
    define('DC_ADMIN_SSL', false);
}
if (defined('DC_FORCE_SCHEME_443') && DC_FORCE_SCHEME_443) {
    http::$https_scheme_on_443 = true;
 public function setCacheDir($dir)
 {
     if (!is_dir($dir)) {
         throw new Exception($dir . ' is not a valid directory.');
     }
     if (!is_writable($dir)) {
         throw new Exception($dir . ' is not writable.');
     }
     $this->cache_dir = path::real($dir) . '/';
 }
示例#22
0
 function __getRelPath($f)
 {
     if ($this->__inJail($f)) {
         $f = path::real($f);
         return preg_replace('|^' . preg_quote($this->root, '|') . '|', '', $f);
     }
     return false;
 }
示例#23
0
 /**
 This method registers a module in modules list. You should use this to
 register a new module.
 
 <var>$permissions</var> is a comma separated list of permissions for your
 module. If <var>$permissions</var> is null, only super admin has access to
 this module.
 
 <var>$priority</var> is an integer. Modules are sorted by priority and name.
 Lowest priority comes first.
 
 @param	name			<b>string</b>		Module name
 @param	desc			<b>string</b>		Module description
 @param	author		<b>string</b>		Module author name
 @param	version		<b>string</b>		Module version
 @param	properties	<b>array</b>		extra properties
 (currently available keys : permissions, priority, type)
 */
 public function registerModule($name, $desc, $author, $version, $properties = array())
 {
     if ($this->disabled_mode) {
         $this->disabled_meta = array_merge($properties, array('root' => $this->mroot, 'name' => $name, 'desc' => $desc, 'author' => $author, 'version' => $version, 'enabled' => false, 'root_writable' => is_writable($this->mroot)));
         return;
     }
     # Fallback to legacy registerModule parameters
     if (!is_array($properties)) {
         $args = func_get_args();
         $properties = array();
         if (isset($args[4])) {
             $properties['permissions'] = $args[4];
         }
         if (isset($args[5])) {
             $properties['priority'] = (int) $args[5];
         }
     }
     # Default module properties
     $properties = array_merge(array('permissions' => null, 'priority' => 1000, 'standalone_config' => false, 'type' => null, 'enabled' => true, 'requires' => array()), $properties);
     # Check module type
     if (self::$type !== null && $properties['type'] !== null && $properties['type'] != self::$type) {
         $this->errors[] = sprintf(__('Module "%s" has type "%s" that mismatch required module type "%s".'), '<strong>' . html::escapeHTML($name) . '</strong>', '<em>' . html::escapeHTML($properties['type']) . '</em>', '<em>' . html::escapeHTML(self::$type) . '</em>');
         return;
     }
     # Check module perms on admin side
     $permissions = $properties['permissions'];
     if ($this->ns == 'admin') {
         if ($permissions == '' && !$this->core->auth->isSuperAdmin()) {
             return;
         } elseif (!$this->core->auth->check($permissions, $this->core->blog->id)) {
             return;
         }
     }
     # Check module install on multiple path
     if ($this->id) {
         $module_exists = array_key_exists($name, $this->modules_names);
         $module_overwrite = $module_exists ? version_compare($this->modules_names[$name], $version, '<') : false;
         if (!$module_exists || $module_exists && $module_overwrite) {
             $this->modules_names[$name] = $version;
             $this->modules[$this->id] = array_merge($properties, array('root' => $this->mroot, 'name' => $name, 'desc' => $desc, 'author' => $author, 'version' => $version, 'root_writable' => is_writable($this->mroot)));
         } else {
             $path1 = path::real($this->moduleInfo($name, 'root'));
             $path2 = path::real($this->mroot);
             $this->errors[] = sprintf(__('Module "%s" is installed twice in "%s" and "%s".'), '<strong>' . $name . '</strong>', '<em>' . $path1 . '</em>', '<em>' . $path2 . '</em>');
         }
     }
 }
示例#24
0
function display_theme_details($id, $details, $current)
{
    global $core;
    $screenshot = 'images/noscreenshot.png';
    if (file_exists($core->blog->themes_path . '/' . $id . '/screenshot.jpg')) {
        $screenshot = 'blog_theme.php?shot=' . rawurlencode($id);
    }
    $radio_id = 'theme_' . html::escapeHTML($id);
    $theme_url = http::concatURL($core->blog->url, $core->blog->settings->themes_url . '/' . $id);
    $has_conf = file_exists(path::real($core->blog->themes_path . '/' . $id) . '/_config.php');
    $has_css = file_exists(path::real($core->blog->themes_path . '/' . $id) . '/style.css');
    $parent = $core->themes->moduleInfo($id, 'parent');
    $has_parent = (bool) $parent;
    if ($has_parent) {
        $is_parent_present = $core->themes->moduleExists($parent);
    }
    $res = '<div class="theme-details' . ($current ? ' current-theme' : '') . '">' . '<div class="theme-shot"><img src="' . $screenshot . '" alt="" /></div>' . '<div class="theme-info">' . '<h3>' . form::radio(array('theme', $radio_id), html::escapeHTML($id), $current, '', '', $has_parent && !$is_parent_present) . ' ' . '<label class="classic" for="' . $radio_id . '">' . html::escapeHTML($details['name']) . '</label></h3>' . '<p><span class="theme-desc">' . html::escapeHTML($details['desc']) . '</span> ' . '<span class="theme-author">' . sprintf(__('by %s'), html::escapeHTML($details['author'])) . '</span> ' . '<span class="theme-version">' . sprintf(__('version %s'), html::escapeHTML($details['version'])) . '</span> ';
    if ($has_parent) {
        if ($is_parent_present) {
            $res .= '<span class="theme-parent-ok">' . sprintf(__('(built on "%s")'), html::escapeHTML($parent)) . '</span> ';
        } else {
            $res .= '<span class="theme-parent-missing">' . sprintf(__('(requires "%s")'), html::escapeHTML($parent)) . '</span> ';
        }
    }
    if ($has_css) {
        $res .= '<a class="theme-css" href="' . $theme_url . '/style.css">' . __('Stylesheet') . '</a>';
    }
    $res .= '</p>';
    $res .= '</div>' . '<div class="theme-actions">';
    if ($current && $has_conf) {
        $res .= '<p><a href="blog_theme.php?conf=1" class="button">' . __('Theme configuration') . '</a></p>';
    }
    if ($current) {
        # --BEHAVIOR-- adminCurrentThemeDetails
        $res .= $core->callBehavior('adminCurrentThemeDetails', $core, $id, $details);
    }
    $res .= '</div>' . '</div>';
    return $res;
}
示例#25
0
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
    return;
}
global $core;
//PARAMS
# Translations
l10n::set(dirname(__FILE__) . '/locales/' . $_lang . '/main');
# Default values
$default_about = false;
# Settings
$my_about = $core->blog->settings->themes->qrazytimes2_about;
# About
$html_fileabout = path::real($core->blog->themes_path) . '/' . $core->blog->settings->system->theme . '/tpl/_about.html';
if (!is_file($html_fileabout) && !is_writable(dirname($html_fileabout))) {
    throw new Exception(sprintf(__('File %s does not exist and directory %s is not writable.'), $css_fileabout, dirname($html_fileabout)));
}
// POST ACTIONS
if (!empty($_POST)) {
    try {
        $core->blog->settings->addNamespace('themes');
        # About
        if (!empty($_POST['qrazytimes2_about'])) {
            $my_about = $_POST['qrazytimes2_about'];
        } elseif (empty($_POST['qrazytimes2_about'])) {
            $my_about = $default_about;
        }
        $core->blog->settings->themes->put('qrazytimes2_about', $my_about, 'boolean', 'Display About', true);
        if (isset($_POST['about'])) {
示例#26
0
 public function run()
 {
     if (file_exists(JELIX_APP_PATH)) {
         throw new Exception("this application is already created");
     }
     $this->createDir(JELIX_APP_PATH);
     if ($p = $this->getOption('-wwwpath')) {
         $wwwpath = path::real(JELIX_APP_PATH . $p, false) . '/';
     } else {
         $wwwpath = JELIX_APP_WWW_PATH;
     }
     $this->createDir(JELIX_APP_REAL_TEMP_PATH);
     $this->createDir(JELIX_APP_CLI_TEMP_PATH);
     $this->createDir(JELIX_APP_TEMP_PATH);
     $this->createDir($wwwpath);
     $this->createDir(JELIX_APP_VAR_PATH);
     $this->createDir(JELIX_APP_LOG_PATH);
     $this->createDir(JELIX_APP_CONFIG_PATH);
     $this->createDir(JELIX_APP_CONFIG_PATH . 'index/');
     $this->createDir(JELIX_APP_VAR_PATH . 'overloads/');
     $this->createDir(JELIX_APP_VAR_PATH . 'themes/');
     $this->createDir(JELIX_APP_VAR_PATH . 'themes/default/');
     $this->createDir(JELIX_APP_VAR_PATH . 'uploads/');
     $this->createDir(JELIX_APP_VAR_PATH . 'sessions/');
     $this->createDir(JELIX_APP_PATH . 'modules');
     $this->createDir(JELIX_APP_PATH . 'plugins');
     $this->createDir(JELIX_APP_PATH . 'plugins/coord/');
     $this->createDir(JELIX_APP_PATH . 'plugins/tpl/');
     $this->createDir(JELIX_APP_PATH . 'plugins/tpl/common');
     $this->createDir(JELIX_APP_PATH . 'plugins/tpl/html');
     $this->createDir(JELIX_APP_PATH . 'plugins/tpl/text');
     $this->createDir(JELIX_APP_PATH . 'plugins/db/');
     $this->createDir(JELIX_APP_PATH . 'plugins/auth/');
     $this->createDir(JELIX_APP_PATH . 'responses');
     $this->createDir(JELIX_APP_PATH . 'scripts');
     $param = array();
     $param['default_id'] = $GLOBALS['APPNAME'] . JELIXS_INFO_DEFAULT_IDSUFFIX;
     if ($this->getOption('-nodefaultmodule')) {
         $param['tplname'] = 'jelix~defaultmain';
         $param['modulename'] = 'jelix';
     } else {
         // note: since module name are used for name of generated name,
         // only this characters are allowed
         $param['modulename'] = preg_replace('/([^a-zA-Z_0-9])/', '_', $GLOBALS['APPNAME']);
         $param['tplname'] = $param['modulename'] . '~main';
     }
     $param['config_file'] = 'index/config.ini.php';
     $param['rp_temp'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_REAL_TEMP_PATH, true);
     $param['rp_var'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_VAR_PATH, true);
     $param['rp_log'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_LOG_PATH, true);
     $param['rp_conf'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CONFIG_PATH, true);
     $param['rp_www'] = jxs_getRelativePath(JELIX_APP_PATH, $wwwpath, true);
     $param['rp_cmd'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CMD_PATH, true);
     $param['rp_jelix'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_LIB_PATH, true);
     $param['rp_app'] = jxs_getRelativePath($wwwpath, JELIX_APP_PATH, true);
     $this->createFile(JELIX_APP_PATH . '.htaccess', 'htaccess_deny', $param);
     $this->createFile(JELIX_APP_PATH . 'project.xml', 'project.xml.tpl', $param);
     $this->createFile(JELIX_APP_CONFIG_PATH . 'defaultconfig.ini.php', 'var/config/defaultconfig.ini.php.tpl', $param);
     $this->createFile(JELIX_APP_CONFIG_PATH . 'dbprofils.ini.php', 'var/config/dbprofils.ini.php.tpl', $param);
     $this->createFile(JELIX_APP_CONFIG_PATH . 'index/config.ini.php', 'var/config/index/config.ini.php.tpl', $param);
     $this->createFile(JELIX_APP_PATH . 'responses/myHtmlResponse.class.php', 'myHtmlResponse.class.php.tpl', $param);
     $this->createFile($wwwpath . 'index.php', 'www/index.php.tpl', $param);
     $this->createFile($wwwpath . '.htaccess', 'htaccess_allow', $param);
     $param['php_rp_temp'] = $this->convertRp($param['rp_temp']);
     $param['php_rp_var'] = $this->convertRp($param['rp_var']);
     $param['php_rp_log'] = $this->convertRp($param['rp_log']);
     $param['php_rp_conf'] = $this->convertRp($param['rp_conf']);
     $param['php_rp_www'] = $this->convertRp($param['rp_www']);
     $param['php_rp_cmd'] = $this->convertRp($param['rp_cmd']);
     $this->createFile(JELIX_APP_PATH . 'application.init.php', 'application.init.php.tpl', $param);
     $param['rp_temp_app'] = $param['rp_temp'];
     $param['php_rp_temp_app'] = $param['php_rp_temp'];
     $param['rp_temp'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_TEMP_PATH, true);
     $param['rp_temp_cli'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CLI_TEMP_PATH, true);
     $param['php_rp_temp'] = $this->convertRp($param['rp_temp']);
     $param['php_rp_temp_cli'] = $this->convertRp($param['rp_temp_cli']);
     $this->createFile(JELIX_APP_PATH . 'jelix-scripts.init.php', 'jelix-scripts.init.php.tpl', $param);
     $param['rp_temp'] = jxs_getRelativePath(JELIX_APP_PATH, JELIX_APP_CLI_TEMP_PATH, true);
     $param['php_rp_temp'] = $this->convertRp($param['rp_temp']);
     $this->createFile(JELIX_APP_PATH . 'application-cli.init.php', 'application.init.php.tpl', $param);
     $moduleok = true;
     if (!$this->getOption('-nodefaultmodule')) {
         try {
             $cmd = jxs_load_command('createmodule');
             $cmd->init(array('-addinstallzone' => true), array('module' => $param['modulename']));
             $cmd->run();
             $this->createFile(JELIX_APP_PATH . 'modules/' . $param['modulename'] . '/templates/main.tpl', 'main.tpl.tpl', $param);
         } catch (Exception $e) {
             $moduleok = false;
             echo "The module has not been created because of this error: " . $e->getMessage() . "\nHowever the application has been created\n";
         }
     }
     if ($this->getOption('-withcmdline')) {
         if (!$this->getOption('-nodefaultmodule') && $moduleok) {
             $agcommand = jxs_load_command('createctrl');
             $options = array('-cmdline' => true);
             $agcommand->init($options, array('module' => $GLOBALS['APPNAME'], 'name' => 'default', 'method' => 'index'));
             $agcommand->run();
         }
         $agcommand = jxs_load_command('createentrypoint');
         $options = array('-type' => 'cmdline');
         $parameters = array('name' => $GLOBALS['APPNAME']);
         $agcommand->init($options, $parameters);
         $agcommand->run();
     }
 }
示例#27
-1
 public function run()
 {
     $appPath = $this->getParam('path');
     $appPath = $this->getRealPath($appPath);
     $appName = basename($appPath);
     $appPath .= '/';
     if (file_exists($appPath . '/jelix-app.json') || file_exists($appPath . '/project.xml')) {
         throw new Exception("this application is already created");
     }
     $this->config = JelixScript::loadConfig($appName);
     $this->config->infoWebsite = $this->config->newAppInfoWebsite;
     $this->config->infoLicence = $this->config->newAppInfoLicence;
     $this->config->infoLicenceUrl = $this->config->newAppInfoLicenceUrl;
     $this->config->infoLocale = $this->config->newAppInfoLocale;
     $this->config->infoCopyright = $this->config->newAppInfoCopyright;
     $this->config->initAppPaths($appPath);
     App::setEnv('jelix-scripts');
     JelixScript::checkTempPath();
     if ($p = $this->getOption('-wwwpath')) {
         $wwwpath = path::real($appPath . $p, false) . '/';
     } else {
         $wwwpath = App::wwwPath();
     }
     $this->createDir($appPath);
     $this->createDir(App::tempBasePath());
     $this->createDir($wwwpath);
     $varPath = App::varPath();
     $configPath = App::configPath();
     $this->createDir($varPath);
     $this->createDir(App::logPath());
     $this->createDir($configPath);
     $this->createDir($configPath . 'index/');
     $this->createDir($varPath . 'overloads/');
     $this->createDir($varPath . 'themes/');
     $this->createDir($varPath . 'themes/default/');
     $this->createDir($varPath . 'uploads/');
     $this->createDir($varPath . 'sessions/');
     $this->createDir($varPath . 'mails/');
     $this->createDir($appPath . 'install');
     $this->createDir($appPath . 'modules');
     $this->createDir($appPath . 'plugins');
     $this->createDir($appPath . 'responses');
     $this->createDir($appPath . 'tests');
     $this->createDir(App::scriptsPath());
     $param = array();
     if ($this->getOption('-nodefaultmodule')) {
         $param['tplname'] = 'jelix~defaultmain';
         $param['modulename'] = 'jelix';
     } else {
         $moduleName = $this->getOption('-modulename');
         if (!$moduleName) {
             // note: since module name are used for name of generated name,
             // only this characters are allowed
             $moduleName = preg_replace('/([^a-zA-Z_0-9])/', '_', $appName);
         }
         $param['modulename'] = $moduleName;
         $param['tplname'] = $moduleName . '~main';
     }
     $param['config_file'] = 'index/config.ini.php';
     $param['rp_temp'] = $this->getRelativePath($appPath, App::tempBasePath());
     $param['rp_var'] = $this->getRelativePath($appPath, App::varPath());
     $param['rp_log'] = $this->getRelativePath($appPath, App::logPath());
     $param['rp_conf'] = $this->getRelativePath($appPath, $configPath);
     $param['rp_www'] = $this->getRelativePath($appPath, $wwwpath);
     $param['rp_cmd'] = $this->getRelativePath($appPath, App::scriptsPath());
     $param['rp_jelix'] = $this->getRelativePath($appPath, JELIX_LIB_PATH);
     $param['rp_vendor'] = '';
     foreach (array(LIB_PATH . 'vendor/', LIB_PATH . '../vendor/', LIB_PATH . '../../../') as $path) {
         if (file_exists($path)) {
             $param['rp_vendor'] = $this->getRelativePath($appPath, realpath($path) . '/');
             break;
         }
     }
     $param['rp_app'] = $this->getRelativePath($wwwpath, $appPath);
     $this->createFile(App::logPath() . '.dummy', 'dummy.tpl', array());
     $this->createFile(App::varPath() . 'mails/.dummy', 'dummy.tpl', array());
     $this->createFile(App::varPath() . 'sessions/.dummy', 'dummy.tpl', array());
     $this->createFile(App::varPath() . 'overloads/.dummy', 'dummy.tpl', array());
     $this->createFile(App::varPath() . 'themes/default/.dummy', 'dummy.tpl', array());
     $this->createFile(App::varPath() . 'uploads/.dummy', 'dummy.tpl', array());
     $this->createFile($appPath . 'plugins/.dummy', 'dummy.tpl', array());
     $this->createFile(App::scriptsPath() . '.dummy', 'dummy.tpl', array());
     $this->createFile(App::tempBasePath() . '.dummy', 'dummy.tpl', array());
     $this->createFile($appPath . '.htaccess', 'htaccess_deny', $param, "Configuration file for Apache");
     $this->createFile($appPath . '.gitignore', 'git_ignore.tpl', $param, ".gitignore");
     $this->createFile($appPath . 'jelix-app.json', 'jelix-app.json.tpl', $param, "Project description file");
     $this->createFile($appPath . 'composer.json', 'composer.json.tpl', $param, "Composer file");
     $this->createFile($appPath . 'cmd.php', 'cmd.php.tpl', $param, "Script for developer commands");
     $this->createFile($configPath . 'mainconfig.ini.php', 'var/config/mainconfig.ini.php.tpl', $param, "Main configuration file");
     $this->createFile($configPath . 'localconfig.ini.php.dist', 'var/config/localconfig.ini.php.tpl', $param, "Configuration file for specific environment");
     $this->createFile($configPath . 'profiles.ini.php', 'var/config/profiles.ini.php.tpl', $param, "Profiles file");
     $this->createFile($configPath . 'profiles.ini.php.dist', 'var/config/profiles.ini.php.tpl', $param, "Profiles file for your repository");
     $this->createFile($configPath . 'preferences.ini.php', 'var/config/preferences.ini.php.tpl', $param, "Preferences file");
     $this->createFile($configPath . 'urls.xml', 'var/config/urls.xml.tpl', $param, "URLs mapping file");
     $this->createFile($configPath . 'index/config.ini.php', 'var/config/index/config.ini.php.tpl', $param, "Entry point configuration file");
     $this->createFile($appPath . 'responses/myHtmlResponse.class.php', 'responses/myHtmlResponse.class.php.tpl', $param, "Main response class");
     $this->createFile($appPath . 'install/installer.php', 'installer/installer.php.tpl', $param, "Installer script");
     $this->createFile($appPath . 'tests/runtests.php', 'tests/runtests.php', $param, "Tests script");
     $temp = dirname(rtrim(App::tempBasePath(), '/'));
     if ($temp != rtrim($appPath, '/')) {
         if (file_exists($temp . '/.gitignore')) {
             $gitignore = file_get_contents($temp . '/.gitignore') . "\n" . $appName . "/*\n";
             file_put_contents($temp . '/.gitignore', $gitignore);
         } else {
             file_put_contents($temp . '/.gitignore', $appName . "/*\n");
         }
     } else {
         $gitignore = file_get_contents($appPath . '.gitignore') . "\n" . basename(rtrim(App::tempBasePath(), '/')) . "/*\n";
         file_put_contents($appPath . '.gitignore', $gitignore);
     }
     $this->createFile($wwwpath . 'index.php', 'www/index.php.tpl', $param, "Main entry point");
     $this->createFile($wwwpath . '.htaccess', 'htaccess_allow', $param, "Configuration file for Apache");
     $param['php_rp_temp'] = $this->convertRp($param['rp_temp']);
     $param['php_rp_var'] = $this->convertRp($param['rp_var']);
     $param['php_rp_log'] = $this->convertRp($param['rp_log']);
     $param['php_rp_conf'] = $this->convertRp($param['rp_conf']);
     $param['php_rp_www'] = $this->convertRp($param['rp_www']);
     $param['php_rp_cmd'] = $this->convertRp($param['rp_cmd']);
     $param['php_rp_jelix'] = $this->convertRp($param['rp_jelix']);
     if ($param['rp_vendor']) {
         $param['php_rp_vendor'] = $this->convertRp($param['rp_vendor']);
         $this->createFile($appPath . 'application.init.php', 'application2.init.php.tpl', $param, "Bootstrap file");
     } else {
         $this->createFile($appPath . 'application.init.php', 'application.init.php.tpl', $param, "Bootstrap file");
     }
     $installer = new \Jelix\Installer\Installer(new \Jelix\Installer\Reporter\Console('warning'));
     $installer->installApplication();
     $moduleok = true;
     if (!$this->getOption('-nodefaultmodule')) {
         try {
             $cmd = JelixScript::getCommand('createmodule', $this->config);
             $options = $this->getCommonActiveOption();
             $options['-addinstallzone'] = true;
             $options['-noregistration'] = true;
             $cmd->initOptParam($options, array('module' => $param['modulename']));
             $cmd->run();
             $this->createFile($appPath . 'modules/' . $param['modulename'] . '/templates/main.tpl', 'module/main.tpl.tpl', $param, "Main template");
         } catch (Exception $e) {
             $moduleok = false;
             echo "The module has not been created because of this error: " . $e->getMessage() . "\nHowever the application has been created\n";
         }
     }
     if ($this->getOption('-withcmdline')) {
         if (!$this->getOption('-nodefaultmodule') && $moduleok) {
             $agcommand = JelixScript::getCommand('createctrl', $this->config);
             $options = $this->getCommonActiveOption();
             $options['-cmdline'] = true;
             $agcommand->initOptParam($options, array('module' => $param['modulename'], 'name' => 'default', 'method' => 'index'));
             $agcommand->run();
         }
         $agcommand = JelixScript::getCommand('createentrypoint', $this->config);
         $options = $this->getCommonActiveOption();
         $options['-type'] = 'cmdline';
         $parameters = array('name' => $param['modulename']);
         $agcommand->initOptParam($options, $parameters);
         $agcommand->run();
     }
 }