Page MenuHomeCode

No OneTemporary

diff --git a/apps/hotglue/common.inc.php b/apps/hotglue/common.inc.php
index d6077a6..762b3a9 100644
--- a/apps/hotglue/common.inc.php
+++ b/apps/hotglue/common.inc.php
@@ -1,548 +1,548 @@
<?php
/**
* common.inc.php
* Common hotglue infrastructure
*
* Copyright Gottfried Haider, Danja Vasiliev 2010.
* This source code is licensed under the GNU General Public License.
* See the file COPYING for more details.
*/
@require_once('config.inc.php');
require_once('html.inc.php');
require_once('modules.inc.php');
/**
* save a page in the cache
*
* @param string $category cache category (e.g. 'page')
* @param string $name item name
* @param string $out content
* @return true if successful, false if not
*/
function cache_output($category, $name, $out)
{
// check if cache dir exists
$f = CONTENT_DIR.'/cache';
if (!is_dir($f)) {
$m = umask(0000);
if (!@mkdir($f, 0777)) {
umask($m);
log_msg('error', 'common: cannot create cache directory '.quot($f));
return false;
}
umask($m);
}
// check if category subdirectory exists
$f .= '/'.$category;
if (!is_dir($f)) {
$m = umask(0000);
if (!@mkdir($f, 0777)) {
umask($m);
log_msg('error', 'common: cannot create cache directory '.quot($f));
return false;
}
umask($m);
}
// save file
$f .= '/'.$name;
$m = umask(0111);
if (!file_put_contents($f, $out)) {
umask($m);
log_msg('error', 'common: error writing cache file '.quot($f));
return false;
}
umask($m);
log_msg('debug', 'common: cached '.$category.' '.quot($name));
return true;
}
/**
* setup a default html page
*
* see html.inc.php.
* @param bool $add_glue true for adding the glue code
*/
function default_html($add_glue)
{
html_title(SITE_NAME);
$favicon = FAVICON;
if (!empty($favicon)) {
if (is_url($favicon)) {
html_favicon($favicon);
} else {
html_favicon(base_url().$favicon);
}
}
if (USE_MIN_FILES) {
html_add_css(base_url().'css/reset.min.css', 1);
} else {
html_add_css(base_url().'css/reset.css', 1);
}
// 2 can be used for third-party components
html_add_css(base_url().'css/main.css', 3);
if ($add_glue) {
html_add_css(base_url().'css/glue.css', 4);
}
if ($add_glue) {
$jquery = JQUERY;
if (is_url($jquery)) {
html_add_js($jquery, 1);
} else {
html_add_js(base_url().$jquery, 1);
}
// 2 can be used for third-party components
html_add_js(base_url().'js/glue.js', 3);
html_add_js_var('$.glue.base_url', base_url());
html_add_js_var('$.glue.conf.show_frontend_errors', SHOW_FRONTEND_ERRORS);
html_add_js_var('$.glue.version', glue_version());
}
}
/**
* remove a page from the cache
*
* @param string $category cache category (e.g. 'page')
* @param string $name item name
*/
function drop_cache($category, $name)
{
$f = CONTENT_DIR.'/cache/'.$category.'/'.$name;
if (@unlink($f)) {
log_msg('debug', 'common: dropped cache of '.$category.' '.quot($name));
}
}
/**
* return the glue version with api.version.patchlevel
*
* @return array (with length three)
*/
function glue_version()
{
$a = expl('.', HOTGLUE_VERSION);
$ret = array(0, 0, 0);
for ($i=0; $i < count($a); $i++) {
$ret[$i] = $a[$i];
}
return $ret;
}
/**
* invoke a hook when an update was detected
*/
function handle_updates()
{
$new = glue_version();
$write_file = false;
if (($s = @file_get_contents(CONTENT_DIR.'/version')) !== false) {
// parse version
$a = expl('.', $s);
$old = array(0, 0, 0);
for ($i=0; $i < count($a); $i++) {
$old[$i] = $a[$i];
}
// check if an update happened
if ($old != $new) {
log_msg('info', 'common: detected hotglue update from version '.implode('.', $old).' to '.implode('.', $new));
// hook
invoke_hook('glue_update', array('old'=>$old, 'new'=>$new));
$write_file = true;
}
} else {
$write_file = true;
}
if ($write_file) {
$m = umask(0111);
@file_put_contents(CONTENT_DIR.'/version', implode('.', $new));
umask($m);
}
}
/**
* check if the user is authenticated or not
*
* @return true if authenticated, false if not
*/
function is_auth()
{
if (AUTH_METHOD == 'none') {
log_msg('debug', 'common: auth success (auth_method none)');
return true;
} elseif (AUTH_METHOD == 'basic') {
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
if ($_SERVER['PHP_AUTH_USER'] == AUTH_USER && $_SERVER['PHP_AUTH_PW'] == AUTH_PASSWORD) {
log_msg('debug', 'common: auth success (auth_method basic)');
return true;
} else {
log_msg('info', 'common: auth failure (auth_method basic)');
return false;
}
} else {
log_msg('debug', 'common: no auth data (auth_method basic)');
return false;
}
} elseif (AUTH_METHOD == 'digest') {
if (isset($_SERVER['PHP_AUTH_DIGEST'])) {
log_msg('debug', 'common: auth digest '.var_dump_inl($_SERVER['PHP_AUTH_DIGEST']));
$res = http_digest_check(array(AUTH_USER=>AUTH_PASSWORD), SITE_NAME);
if ($res == 0) {
log_msg('debug', 'common: auth success (auth_method digest)');
return true;
} else {
log_msg('info', 'common: auth failure '.$res.' (auth_method digest)');
return false;
}
}
} else {
log_msg('error', 'common: invalid or missing AUTH_METHOD config setting');
return false;
}
}
/**
* check if a page can be served from the cache
*
* @param string $category cache category (e.g. 'page')
* @param string $name item name
* @param int $max_age serve from cache when younger than $max_age seconds
* @return bool true if the page can be served from cache, false if not
*/
function is_cached($category, $name, $max_age)
{
$f = CONTENT_DIR.'/cache/'.$category.'/'.$name;
if (!is_file($f)) {
return false;
}
// check the file's age
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
clearstatcache(true, realpath($f));
} else {
clearstatcache();
}
$age = filemtime($f);
if ($max_age < abs(time()-$age)) {
return false;
} else {
return true;
}
}
/**
* check if an object exists
*
* @param $s object (e.g. page.rev.obj)
* @return bool
*/
function object_exists($s)
{
$a = expl('.', $s);
// we need not check if any of $a[..] is empty as the resulting string
// cannot be a file anyway
if (2 < count($a) && is_file(CONTENT_DIR.'/'.str_replace('.', '/', $s))) {
return true;
} else {
return false;
}
}
/**
* turn short page names into canonical ones
*
* if $s is not a page, the string is not altered.
* @param string &$s reference to the page name
*/
function page_canonical(&$s)
{
$a = expl('.', $s);
// assume head revision
if (count($a) == 1) {
$s .= '.head';
}
}
/**
* check if a page exists
*
* this function can also be used with object names (e.g. page.rev.obj).
* @param $s page
* @return bool
*/
function page_exists($s)
{
$a = expl('.', $s);
if (1 < count($a) && !empty($a[0]) && !empty($a[1]) && is_dir(CONTENT_DIR.'/'.$a[0].'/'.$a[1])) {
return true;
} else {
return false;
}
}
/**
* return the short pagename if possible, otherwise the long one
*
* @param $s page
* @return string
*/
function page_short($s)
{
$a = expl('.', $s);
if (count($a) == 1) {
return $s;
} elseif (count($a) == 2 && $a[1] == 'head') {
return $a[0];
} elseif (count($a) == 2) {
return $s;
} else {
return '';
}
}
/**
* prompt user for authentication
*
* @param bool $header_only only send header information
* this function does not return.
*/
function prompt_auth($header_only = false)
{
if (AUTH_METHOD == 'none') {
// nothing to do here
} elseif (AUTH_METHOD == 'basic') {
header('WWW-Authenticate: Basic realm="'.str_replace("\"", '', SITE_NAME).'"');
header($_SERVER['SERVER_PROTOCOL'].' 401 Unauthorized');
} elseif (AUTH_METHOD == 'digest') {
http_digest_prompt(SITE_NAME);
} else {
log_msg('error', 'common: invalid or missing AUTH_METHOD config setting');
}
// TODO (listed): we need hotglue theming here
die();
}
// TODO: document
function resolve_aliases($s, $name = '')
{
// base url
$s = str_replace('$BASEURL$', base_url(), $s);
$s = str_replace('$baseurl$', base_url(), $s);
// version number
$s = str_replace('$GLUE$', HOTGLUE_VERSION, $s);
$s = str_replace('$glue$', HOTGLUE_VERSION, $s);
//Zed local moves
- $s = str_replace('%NORTH', '/do.php/local_move/north?redirectTo=/', $s);
- $s = str_replace('%EAST', '/do.php/local_move/east?redirectTo=/', $s);
- $s = str_replace('%SOUTH', '/do.php/local_move/south?redirectTo=/', $s);
- $s = str_replace('%WEST', '/do.php/local_move/west?redirectTo=/', $s);
- $s = str_replace('%UP', '/do.php/local_move/up?redirectTo=/', $s);
- $s = str_replace('%DOWN', '/do.php/local_move/down?redirectTo=/', $s);
- $s = preg_replace('/%MOVE (.*)/', '/do.php/local_move/?redirectTo=$1?redirectTo=/', $s);
+ $s = str_replace('%NORTH', ZED_URL . '/do.php/local_move/north?redirectTo=/', $s);
+ $s = str_replace('%EAST', ZED_URL . '/do.php/local_move/east?redirectTo=/', $s);
+ $s = str_replace('%SOUTH', ZED_URL . '/do.php/local_move/south?redirectTo=/', $s);
+ $s = str_replace('%WEST', ZED_URL . '/do.php/local_move/west?redirectTo=/', $s);
+ $s = str_replace('%UP', ZED_URL . '/do.php/local_move/up?redirectTo=/', $s);
+ $s = str_replace('%DOWN', ZED_URL . '/do.php/local_move/down?redirectTo=/', $s);
+ $s = preg_replace('/%MOVE (.*)/', ZED_URL . '/do.php/local_move/?redirectTo=$1?redirectTo=/', $s);
if (!empty($name)) {
// current object
$s = str_replace('$OBJ$', $name, $s);
$s = str_replace('$obj$', $name, $s);
// current page
$s = str_replace('$PAGE$', implode('.', array_slice(expl('.', $name), 0, 2)), $s);
$s = str_replace('$page$', implode('.', array_slice(expl('.', $name), 0, 2)), $s);
// pagename
$s = str_replace('$PAGENAME$', array_shift(expl('.', $name)), $s);
$s = str_replace('$pagename$', array_shift(expl('.', $name)), $s);
// revision
$s = str_replace('$REV$', array_shift(array_slice(expl('.', $name), 1, 1)), $s);
$s = str_replace('$rev$', array_shift(array_slice(expl('.', $name), 1, 1)), $s);
}
return $s;
}
// TODO: document
function resolve_relative_urls($s)
{
$attrs = array('href', 'src');
foreach ($attrs as $attr) {
$start = 0;
while (($start = strpos($s, $attr.'="', $start)) !== false) {
if (($end = strpos($s, '"', $start+strlen($attr)+2)) !== false) {
$link = substr($s, $start+strlen($attr)+2, $end-$start-strlen($attr)-2);
if (!is_url($link) && substr($link, 0, 1) != '#') {
// add base url for relative links that are not directed towards anchors
log_msg('debug', 'common: resolving relative url '.quot($link));
if (SHORT_URLS) {
$link = base_url().$link;
} else {
$link = base_url().'?'.$link;
}
} else {
log_msg('debug', 'common: not resolving url '.quot($link));
}
$start = $end+1;
} else {
break;
}
}
}
return $s;
}
/**
* output a cached page to the client
*
* @param string $category cache category (e.g. 'page')
* @param string $name item name
* @return true if successful, false if not
*/
function serve_cached($category, $name)
{
$f = CONTENT_DIR.'/cache/'.$category.'/'.$name;
if (@readfile($f)) {
log_msg('info', 'common: serving '.$category.' '.quot($name).' from cache');
return true;
} else {
log_msg('error', 'common: cannot serve '.$category.' '.quot($name).' from cache');
return false;
}
}
/**
* return the starting page
*
* @return string
*/
function startpage()
{
// read the starting page information from the content dir
// or fall back to the one defined in the configuration
$s = @file_get_contents(CONTENT_DIR.'/startpage');
if ($s !== false && 0 < strlen($s)) {
return $s;
} else {
$s = DEFAULT_PAGE;
page_canonical($s);
return $s;
}
}
/**
* move an uploaded file to the shared directory of a page
*
* this function reuses existing files when possible.
* @param string $fn filename of newly uploaded file (most likely in /tmp)
* @param string $page page or pagename
* @param string $orig_fn the original filename on the client machine (optional)
* @param bool &$existed set to true if the filename returned did already exist
* before
* @return filename inside the shared directory or false in case of error
*/
function upload_file($fn, $page, $orig_fn = '', &$existed = false)
{
// default to the temporary filename
if ($orig_fn == '') {
$orig_fn = $fn;
}
$a = expl('.', $page);
if (count($a) < 1 || !is_dir(CONTENT_DIR.'/'.$a[0])) {
log_msg('error', 'common: page '.quot($page).' does not exist, cannot move uploaded file');
// not sure if we ought to remove the file in /tmp here (probably not)
return false;
}
// create shared directory if it doesn't exist yet
$d = CONTENT_DIR.'/'.$a[0].'/shared';
if (!is_dir($d)) {
$m = umask(0000);
if (!@mkdir($d, 0777)) {
umask($m);
log_msg('error', 'common: cannot create shared directory '.quot($d).', cannot move uploaded file');
// not sure if we ought to remove the file in /tmp here (probably not)
return false;
}
umask($m);
}
// check if file is already in shared directory
if (($f = dir_has_same_file($d, $fn, $orig_fn)) !== false) {
log_msg('info', 'common: reusing file '.quot($f).' instead of newly uploaded file as they don\'t differ');
@unlink($fn);
$existed = true;
return $f;
} else {
// at least give it a unique name
$f = unique_filename($d, basename($orig_fn));
$m = umask(0111);
if (!@move_uploaded_file($fn, $d.'/'.$f)) {
umask($m);
log_msg('error', 'common: error moving uploaded file to '.quot($d.'/'.$f));
// not sure if we ought to remove the file in /tmp here (probably not)
return false;
} else {
umask($m);
log_msg('info', 'common: moved uploaded file to '.quot($d.'/'.$f));
$existed = false;
return $f;
}
}
}
/**
* check whether the string is a valid, canonical page name
*
* the function does not check if the page exists or not.
* @param string $s string to check
* @return bool
*/
function valid_pagename($s)
{
$a = expl('.', $s);
if (count($a) != 2) {
return false;
} elseif (empty($a[0]) || empty($a[1])) {
return false;
} elseif (in_array($a[0], array('cache', 'shared'))) {
// reserved page names
// TODO (later): we're missing the log file here
// TODO (later): we're also missing $arg0 of controllers here
// TODO (later): we're missing all the files directly in the
// content directory here (this might not be an issue on all
// os)
return false;
} elseif (in_array($a[1], array('shared'))) {
// reserved revision names
return false;
} elseif (is_file($a[0]) || is_dir($a[0]) || is_link($a[0])) {
// same name as existing file names in the root directory
// this is an issue when using the RewriteRule
return false;
} else {
return true;
}
}
?>
diff --git a/apps/hotglue/config.inc.php b/apps/hotglue/config.inc.php
index f257832..a1ce681 100644
--- a/apps/hotglue/config.inc.php
+++ b/apps/hotglue/config.inc.php
@@ -1,111 +1,112 @@
<?php
/**
* These are the default configuration settings of this hotglue
* installation. Do not edit this file directly but overwrite specific
* variables by setting them in the user-config.inc.php file, which
* will not be overwritten by future updates.
*/
error_reporting(E_ALL); // see php documentation
// try to include user configuration
@include('user-config.inc.php');
/**
* Gets the server URL
* @todo find a way to detect https:// on non standard port
*
* @return string the server URL
*/
function get_server_url () {
switch ($port = $_SERVER['SERVER_PORT']) {
case '80':
- return "http://$_SERVER[SERVER_NAME]";
+ return "http://$_SERVER[SERVER_NAME]/";
case '443':
- return "https://$_SERVER[SERVER_NAME]";
+ return "https://$_SERVER[SERVER_NAME]/";
default:
- return "http://$_SERVER[SERVER_NAME]:$_SERVER[SERVER_PORT]";
+ return "http://$_SERVER[SERVER_NAME]:$_SERVER[SERVER_PORT]/";
}
}
// otherwise fall back to these defaults
@define('ALWAYS_PROMPT_CREATE_PAGE', false); // invoke the "create page" controller when trying to access a non-existing page even if the user is not logged in yet (otherwise they receive a 404)
@define('AUTH_METHOD', 'none'); // can be digest, basic or none
@define('AUTH_USER', 'admin');
@define('AUTH_PASSWORD', 'changeme');
-@define('BASE_URL', get_server_url() . '/apps/hotglue/');
+@define('BASE_URL', get_server_url() . 'apps/hotglue/');
+@define('ZED_URL', '');
@define('CACHE_TIME', 60*60); // cache time in seconds (zero to disable)
@define('CONTENT_DIR', 'content'); // content directory, must be writable
@define('DEFAULT_PAGE', 'start');
@define('FAVICON', 'img/favicon.ico'); // can be empty or an absolute url
@define('HOTGLUE_VERSION', '0.99.1'); // expected api.version.patchlevel
@define('IE8_COMPAT', true); // try to be compatible with internet explorer 8 in viewing mode
@define('JQUERY', 'js/jquery-1.4.4.min.js');// can be an absolute url
@define('LOCK_TIME', 5000); // maximum time in ms to wait for an object lock
@define('LOG_FILE', 'content/log.txt'); // log file, must be writable
@define('LOG_LEVEL', 'warn'); // minimum log level (can be error, warn, info, debug)
@define('SHORT_URLS', false); // use short urls
@define('SHOW_FRONTEND_ERRORS', true);
@define('SITE_NAME', 'hotglue 1.0');
@define('SNAPSHOT_MAX_AGE', 60*60*24*7); // auto- revisions are automatically deleted after n seconds (zero to disable)
@define('SNAPSHOT_MIN_AGE', 60*60); // auto- revisions are created every n seconds (zero to disable)
@define('USE_MIN_FILES', true); // use minified files if possible (see also JQUERY define)
// default modules
@define('IMAGE_JPEG_QUAL', 80); // quality for jpeg resizing (0 < 100)
@define('IMAGE_PNG_QUAL', 5); // quality for png resizing (9 < 0)
@define('IMAGE_RESIZING', true); // resize uploaded images on the server (needs gd installed)
@define('IMAGE_UPLOAD_RESIZE_LARGER', '120%'); // automatically resize uploaded image when larger than n% of window width or height (set to 0% to disable)
@define('IMAGE_UPLOAD_RESIZE_TO', '80%'); // target size in n% of window width or height
@define('OBJECT_DEFAULT_COLORS', '#61b9cf #ff00ff #ffff00'); // default colors for new objects (space-separated string)
@define('PAGE_DEFAULT_GRID_X', 50); // default grid x spacing in px
@define('PAGE_DEFAULT_GRID_Y', 50); // default grid y spacing in px
@define('PAGE_GUIDES_X', ''); // show a grid line after n horizontal px (space-separated string)
@define('PAGE_GUIDES_Y', ''); // show a grid line after n vertical px (space-separated string)
@define('PAGES_NEED_AUTH', true); // page browser needs authentication
@define('REVISIONS_NEED_AUTH', true); // revisions browser needs authentication
@define('TEXT_AUTO_BR', true); // automatically add <br> elements for newlines
@define('VIDEO_START_ON_CLICK', true); // start video on click when autoplay is off
/**
* use this function to get the site's base url
*
* @return string base url (not html-encoded)
*/
function base_url()
{
global $base_url_cached;
//dieprint_r("Hello, we're in base_url and the cached value is $base_url_cached");
$temp = BASE_URL;
if (!empty($temp)) {
return $temp;
} elseif (!isset($base_url_cached)) {
if (empty($_SERVER['HTTPS'])) {
$base_url_cached = 'http://'.$_SERVER['HTTP_HOST'];
if ($_SERVER['SERVER_PORT'] != '80') {
$base_url_cached .= $_SERVER['SERVER_PORT'];
}
} else {
$base_url_cached = 'https://'.$_SERVER['HTTP_HOST'];
if ($_SERVER['SERVER_PORT'] != '443') {
$base_url_cached .= $_SERVER['SERVER_PORT'];
}
}
$base_url_cached .= dirname($_SERVER['PHP_SELF']);
// make sure we have a trailing slash at the end
if (substr($base_url_cached, -1) != '/') {
$base_url_cached .= '/';
}
}
return $base_url_cached;
}
?>
diff --git a/apps/hotglue/module_object.inc.php b/apps/hotglue/module_object.inc.php
index 6998759..afeb87e 100644
--- a/apps/hotglue/module_object.inc.php
+++ b/apps/hotglue/module_object.inc.php
@@ -1,143 +1,143 @@
<?php
/**
* module_object.inc.php
* Module for handling general object properties
*
* Copyright Gottfried Haider, Danja Vasiliev 2010.
* This source code is licensed under the GNU General Public License.
* See the file COPYING for more details.
*/
@require_once('config.inc.php');
require_once('common.inc.php');
require_once('html.inc.php');
require_once('util.inc.php');
// module_image.inc.php has more information on what's going on inside modules
// (they can be easier than that one though)
function object_alter_render_early($args)
{
$elem = &$args['elem'];
$obj = $args['obj'];
if (!elem_has_class($elem, 'object')) {
return false;
}
if (!empty($obj['object-height'])) {
elem_css($elem, 'height', $obj['object-height']);
}
if (!empty($obj['object-left'])) {
elem_css($elem, 'left', $obj['object-left']);
}
if (!empty($obj['object-opacity'])) {
elem_css($elem, 'opacity', $obj['object-opacity']);
}
elem_css($elem, 'position', 'absolute');
if (!empty($obj['object-top'])) {
elem_css($elem, 'top', $obj['object-top']);
}
if (!empty($obj['object-width'])) {
elem_css($elem, 'width', $obj['object-width']);
}
if (!empty($obj['object-zindex'])) {
elem_css($elem, 'z-index', $obj['object-zindex']);
}
return true;
}
function object_alter_render_late($args)
{
$elem = $args['elem'];
$html = &$args['html'];
$obj = $args['obj'];
if (!elem_has_class($args['elem'], 'object')) {
return false;
}
if (!$args['edit']) {
// add links only for viewing
if (!empty($obj['object-link'])) {
$link = $obj['object-link'];
// resolve any aliases
$link = resolve_aliases($link, $obj['name']);
if (!is_url($link) && substr($link, 0, 1) != '#' && substr($link, 0, 1) != '/') {
// add base url for relative links that are not directed towards anchors, nor /links
if (SHORT_URLS) {
$link = base_url().urlencode($link);
} else {
$link = base_url().'?'.urlencode($link);
}
}
// <a> can include block elements in html5
if (substr($html, -1) == "\n") {
$html = substr($html, 0, -1);
}
- $html = '<a href="'.htmlspecialchars($link, ENT_COMPAT, 'UTF-8').'">'."\n\t".str_replace("\n", "\n\t", $html)."\n".'</a>'."\n";
+ $html = '<a href="'.htmlspecialchars($link, ENT_COMPAT, 'UTF-8').'" target="_parent">'."\n\t".str_replace("\n", "\n\t", $html)."\n".'</a>'."\n";
return true;
}
}
return false;
}
function object_alter_save($args)
{
$elem = $args['elem'];
$obj = &$args['obj'];
if (!elem_has_class($elem, 'object')) {
return false;
}
if (elem_css($elem, 'height') !== NULL) {
$obj['object-height'] = elem_css($elem, 'height');
} else {
unset($obj['object-height']);
}
if (elem_css($elem, 'left') !== NULL) {
$obj['object-left'] = elem_css($elem, 'left');
} else {
unset($obj['object-left']);
}
if (elem_css($elem, 'opacity') !== NULL) {
$obj['object-opacity'] = elem_css($elem, 'opacity');
} else {
unset($obj['object-opacity']);
}
if (elem_css($elem, 'top') !== NULL) {
$obj['object-top'] = elem_css($elem, 'top');
} else {
unset($obj['object-top']);
}
if (elem_css($elem, 'width') !== NULL) {
$obj['object-width'] = elem_css($elem, 'width');
} else {
unset($obj['object-width']);
}
if (elem_css($elem, 'z-index') !== NULL) {
$obj['object-zindex'] = elem_css($elem, 'z-index');
} else {
unset($obj['object-zindex']);
}
return true;
}
function object_render_page_early($args)
{
if ($args['edit']) {
html_add_js(base_url().'modules/object/object-edit.js');
// add default colors
html_add_js_var('$.glue.conf.object.default_colors', expl(' ', OBJECT_DEFAULT_COLORS));
}
}
?>
diff --git a/controllers/builder.php b/controllers/builder.php
index dd43ff8..9a7eaaf 100644
--- a/controllers/builder.php
+++ b/controllers/builder.php
@@ -1,137 +1,137 @@
<?php
/**
* Builder
*
* Zed. The immensity of stars. The HyperShip. The people.
*
* (c) 2010, Dereckson, some rights reserved.
* Released under BSD license.
*
* @package Zed
* @subpackage Controllers
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @copyright 2010 Sébastien Santoro aka Dereckson
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
* @version 0.1
* @link http://scherzo.dereckson.be/doc/zed
* @link http://zed.dereckson.be/
* @filesource
*/
require_once('includes/content/zone.php');
//
// Helper methods
//
/**
* Determines if a specified location is buildable
*
* @param GeoLocation $location the location to check
* @param string if the location isn't buidable, a textual description of why.
* @return bool true if the location is buildable ; otherwise, false
*
* @todo create a build.xml document to set what's buildable, and by who
*/
function is_buildable ($location, &$error = '') {
//We currently allow build only in the hypership tower and core.
if (!$location->body->hypership) {
$error = "You can only invoke the HyperShip builder facilities inside the HyperShip.";
return false;
}
//if ($build_location->place->code == "001") {
// //Don't allow custom builds in the corridor (T?C?)
//}
if ($build_location->place->code == "003") {
message_die("Bays aren't buildable.");
return false;
}
return true;
}
//
// Determines mode and initializes resources
//
switch ($build_mode = $url[1]) {
case 'map':
require_once('includes/geo/octocube.php');
$build_mode = 'map';
//Get zones at this floor
if ($CurrentPerso->location->global == 'B00001002') {
$point = GeoPoint3D::fromString($CurrentPerso->location->local);
$sector = GeoOctocube::get_sector_from_point3D($point);
$pattern = GeoOctocube::get_rlike_pattern_from_sector($sector, $point->z);
$zones = ContentZone::search($CurrentPerso->location->global, $pattern, true);
} else {
message_die(GENERAL_ERROR, "Can't map this area.", "Builder :: Map");
}
//Template
define('DOJO', true);
$smarty->assign('zones', $zones);
$template = "builder_map.tpl";
break;
case '':
case 'hotglue':
//Temporary initialization code, to allow some build during the Zed alphatest
$build_location = $CurrentPerso->location;
$build_mode = 'hotglue';
$error = '';
if (!is_buildable($build_location, $error)) {
message_die(GENERAL_ERROR, $error, "Can't build");
}
//Gets or creates a new zone at build location
$zone = ContentZone::at($build_location->global, $build_location->local, true);
switch ($zone->type) {
case 'hotglue':
//All rulez
break;
case '':
//New zone
$zone->title = "Sandbox hotglue zone for $build_location->global $build_location->local";
$zone->type = 'hotglue';
$zone->save_to_database();
break;
default:
message_die("This isn't a zone managed by hotglue.");
}
unset($error);
//Template
$smarty->assign('location', $build_location);
$smarty->assign('zone', $zone);
- $smarty->assign('IFRAME_SRC', '/apps/hotglue/?zone_' . $zone->id . '/edit');
+ $smarty->assign('IFRAME_SRC', '/apps/hotglue/index.php?zone_' . $zone->id . '/edit');
$template = 'builder_hotglue.tpl';
break;
default:
message_die(GENERAL_ERROR, "Unknown build mode: $build_mode");
}
//
// HTML output
//
//Serves header
$smarty->assign('PAGE_TITLE', 'Builder');
include('header.php');
//Serves content
$smarty->display($template);
//Serves footer
include('footer.php');
?>
diff --git a/includes/config.php b/includes/config.php
index c5e0507..1ae179a 100644
--- a/includes/config.php
+++ b/includes/config.php
@@ -1,250 +1,261 @@
<?php
/**
* Autogenerable configuration file
*
* Zed. The immensity of stars. The HyperShip. The people.
*
* (c) 2010, Dereckson, some rights reserved.
* Released under BSD license.
*
* @package Zed
* @subpackage Keruald
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @copyright 2010 Sébastien Santoro aka Dereckson
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version 0.1
* @link http://scherzo.dereckson.be/doc/zed
* @link http://zed.dereckson.be/
* @filesource
*/
////////////////////////////////////////////////////////////////////////////////
/// ///
/// I. SQL configuration ///
/// ///
////////////////////////////////////////////////////////////////////////////////
//SQL configuration
$Config['sql']['product'] = 'MySQL'; //Only MySQL is currently implemented
$Config['sql']['host'] = 'localhost';
$Config['sql']['username'] = 'zed';
$Config['sql']['password'] = 'zed';
$Config['sql']['database'] = 'zed';
//SQL tables
$prefix = '';
define('TABLE_API_KEYS', $prefix . 'api_keys');
define('TABLE_COMMENTS', $prefix . 'comments');
define('TABLE_CONTENT_FILES', $prefix . 'content_files');
define('TABLE_CONTENT_LOCATIONS', $prefix . 'content_locations');
define('TABLE_CONTENT_ZONES', $prefix . 'content_zones');
define('TABLE_CONTENT_ZONES_LOCATIONS', $prefix . 'content_zones_locations');
define('TABLE_LOG', $prefix . 'log');
define('TABLE_LOG_SMARTLINE', $prefix . 'log_smartline');
define('TABLE_MESSAGES', $prefix . 'messages');
define('TABLE_MOTD', $prefix . 'motd');
define('TABLE_PAGES', $prefix . 'pages');
define('TABLE_PAGES_EDITS', $prefix . 'pages_edits');
define('TABLE_PERSOS', $prefix . 'persos');
define('TABLE_PERSOS_FLAGS', $prefix . 'persos_flags');
define('TABLE_PERSOS_NOTES', $prefix . 'persos_notes');
define('TABLE_PORTS', $prefix . 'ports');
define('TABLE_PROFILES', $prefix . 'profiles');
define('TABLE_PROFILES_COMMENTS', $prefix . 'profiles_comments');
define('TABLE_PROFILES_PHOTOS', $prefix . 'profiles_photos');
define('TABLE_PROFILES_TAGS', $prefix . 'profiles_tags');
define('TABLE_REGISTRY', $prefix . 'registry');
define('TABLE_SESSIONS', $prefix . 'sessions');
define('TABLE_SHIPS', $prefix . 'ships');
define('TABLE_USERS', $prefix . 'users');
define('TABLE_USERS_INVITES', $prefix . 'users_invites');
define('TABLE_USERS_OPENID', $prefix . 'users_openid');
//Geo tables
define('TABLE_BODIES', $prefix . 'geo_bodies');
define('TABLE_LOCATIONS', $prefix . 'geo_locations'); //Well... it's a view
define('TABLE_PLACES', $prefix . 'geo_places');
////////////////////////////////////////////////////////////////////////////////
/// ///
/// II. Site configuration ///
/// ///
////////////////////////////////////////////////////////////////////////////////
//Default theme
$Config['DefaultTheme'] = "Zed";
//Dates
date_default_timezone_set("UTC");
//Secret key, used for some verification hashes in URLs or forms.
$Config['SecretKey'] = 'Lorem ipsum dolor';
//When reading files, buffer size
define('BUFFER_SIZE', 4096);
////////////////////////////////////////////////////////////////////////////////
/// ///
/// III. Script URLs ///
/// ///
////////////////////////////////////////////////////////////////////////////////
/*
* Apache httpd, without mod_rewrite:
*
* Subdirectory:
* - $Config['SiteURL'] = 'http://zed.dereckson.be/hypership/index.php';
* - $Config['BaseURL'] = '/hypership/index.php';
*
* Root directory:
* - $Config['SiteURL'] = 'http://zed.dereckson.be/index.php';
* - $Config['BaseURL'] = '/index.php';
*
* Apache httpd, with mod_rewrite:
*
* Subdirectory:
* - $Config['SiteURL'] = 'http://zed.dereckson.be/hypership';
* - $Config['BaseURL'] = '/hypership';
*
* In .htaccess or your vhost definition:
* RewriteEngine On
* RewriteBase /hypership/
* RewriteCond %{REQUEST_FILENAME} !-f
* RewriteCond %{REQUEST_FILENAME} !-d
* RewriteRule . /hypership/index.php [L]
*
* Root directory:
* - $Config['SiteURL'] = 'http://zed.dereckson.be';
* - $Config['BaseURL'] = '';
*
* In .htaccess or your vhost definition:
* RewriteEngine On
* RewriteBase /
* RewriteCond %{REQUEST_FILENAME} !-f
* RewriteCond %{REQUEST_FILENAME} !-d
* RewriteRule . /index.php [L]
*
* nginx:
*
* Use same config.php settings than Apache httpd, with mod_rewrite.
*
* In your server block:
* location / {
* #Serves static files if they exists, with one month cache
* if (-f $request_filename) {
* expires 30d;
* break;
* }
*
* #Sends all non existing file or directory requests to index.php
* if (!-e request_filename) {
* rewrite ^(.+)$ /index.php last;
* #Or if you use a subdirectory:
* #rewrite ^(.+)$ /hypership/index.php last;
* }
* }
*
* location ~ \.php$ {
* #Your instructions to pass query to your FastCGI process, like:
* fastcgi_pass 127.0.0.1:9000;
* fastcgi_param SCRIPT_FILENAME /var/www/zed$fastcgi_script_name;
* include fastcgi_params;
* }
*
*
* If you don't want to specify the server domain, you can use get_server_url:
* $Config['SiteURL'] = get_server_url() . '/hypership';
* $Config['SiteURL'] = get_server_url();
*
*
*
* !!! No trailing slash !!!
*
*/
$Config['SiteURL'] = get_server_url();
$Config['BaseURL'] = '';
//AJAX callbacks URL
$Config['DoURL'] = $Config['SiteURL'] . "/do.php";
////////////////////////////////////////////////////////////////////////////////
/// ///
/// IV. Static content ///
/// ///
////////////////////////////////////////////////////////////////////////////////
//Where the static content is located?
//Static content = 4 directories: js, css, img and content
//On default installation, those directories are at site root.
//To improve site performance, you can use a CDN for that.
//
//Recommanded setting: $Config['StaticContentURL'] = $Config['SiteURL'];
//Or if Zed is the site root: $Config['StaticContentURL'] = '';
//With CoralCDN: $Config['StaticContentURL'] = . '.nyud.net';
//
$Config['StaticContentURL'] = '';
//$Config['StaticContentURL'] = get_server_url() . '.nyud.net';
//Scenes
define('SCENE_DIR', 'content/scenes');
define('SCENE_URL', $Config['StaticContentURL'] . '/' . SCENE_DIR);
//Stories
define('STORIES_DIR', "content/stories");
//Profile's photos
define('PHOTOS_DIR', 'content/users/_photos');
define('PHOTOS_URL', $Config['StaticContentURL'] . '/' . PHOTOS_DIR);
//ImageMagick paths
//Be careful on Windows platform convert could match the NTFS convert command.
$Config['ImageMagick']['convert'] = 'convert';
$Config['ImageMagick']['mogrify'] = 'mogrify';
$Config['ImageMagick']['composite'] = 'composite';
$Config['ImageMagick']['identify'] = 'identify';
////////////////////////////////////////////////////////////////////////////////
/// ///
/// V. Caching ///
/// ///
////////////////////////////////////////////////////////////////////////////////
/*
* Some data (Smarty, OpenID and sessions) are cached in the cache directory.
*
* Security tip: you can move this cache directory outside the webserver tree.
*/
define('CACHE_DIR', 'cache');
/*
* Furthermore, you can also enable a cache engine, like memcached, to store
* data from heavy database queries, or frequently accessed stuff.
*
* To use memcached:
* - $Config['cache']['engine'] = 'memcached';
* - $Config['cache']['server'] = 'localhost';
* - $Config['cache']['port'] = 11211;
*
* To disable cache:
* - $Config['cache']['engine'] = 'void';
* (or don't write nothing at all)
*/
$Config['cache']['engine'] = 'void';
////////////////////////////////////////////////////////////////////////////////
/// ///
/// VI. Sessions ///
/// ///
////////////////////////////////////////////////////////////////////////////////
//If you want to use a common table of sessions / user handling
//with several websites, specify a different resource id for each site.
$Config['ResourceID'] = 21;
//PHP variables
ini_set('session.serialize_handler', 'wddx');
ini_set('session.save_path', CACHE_DIR . '/sessions');
ini_set('session.gc_maxlifetime', 345600); //4 days, for week-end story pause and continue url
+
+////////////////////////////////////////////////////////////////////////////////
+/// ///
+/// VII. Builder ///
+/// ///
+////////////////////////////////////////////////////////////////////////////////
+
+//Zed can invoke a slighty modified version of HOTGLUE to build zones.
+$Config['builder']['hotglue']['enable'] = true;
+$Config['builder']['hotglue']['URL'] = '/apps/hotglue/index.php';
+
?>

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 11, 17:40 (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21063
Default Alt Text
(38 KB)

Event Timeline