Page Menu
Home
Code
Search
Configure Global Search
Log In
Files
F212031
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
30 KB
Subscribers
None
View Options
diff --git a/README b/README
--- a/README
+++ b/README
@@ -1,128 +1,166 @@
ZzzzzzZ zz
Z z z The spatial gallery / social network / lounge
z z (c) 2010, Dereckson, some rights reserved.
z zzzzz zzzzz
z z z z z 0.1 alpha technical preview
z zzzzzzz z z
z z z z Last update hypership time: 5.096
z Z z z z z
ZzzzzzZ zzzzz zzzzzz
+=========
+ INSTALL
+=========
+
+ * Zed is a PHP 5.3 application.
+
+ * You can import dev/schema-mysql.sql as original SQL schema
+
+ * The configuration file is includes/config.php
+
+ * Files are cached in 3 directories of the cache folder, sets appropriate
+ write permissions to:
+ compiled openid sessions
+
+ * Zed needs but doesn't include in its code the Janrain OpenID PHP libraries:
+ http://www.janrain.com/openid-enabled - http://github.com/openid/php-openid
+
+ Put the Auth folder somewhere in your include_dir path.
+
+ bcmath and GDM php extensions are recommended (required?) for OpenID.
+ Our dev environment outputs a white page without error if GDM isn't here.
+
+ If you don't wish to enable OpenID, replace your includes/login.php by
+ http://bitbucket.org/dereckson/zed/src/0ffd1b08f33c/includes/login.php
+
+ * Another used PHP extension is the WDDX one, to store session information in
+ a human-readable format, easier to debug.
+
+ If you don't want that, comment the following line from includes/config.php:
+ ini_set('session.serialize_handler', 'wddx');
+
+=========
+ UPGRADE
+=========
+
+ * For our main prod install, we use a script exporting last repo revision with
+ hg archive and applying a patch to config.php.
+
===========
LOCATIONS
===========
* Global location is a 9 letters code
<B,S> <body or spaceship id> <place where you are in this body/spaceship>
zerofilled 5 digits zerofilled 3 digits
You can also find 6 digits expressions e.g. B00001 is the hypership
* Local location varies of the place.
- On hypership core (B00001002): Sector C<0-8> Level <z> Zone <x-y>
- 0 is the gravity center
- 1-8 the 8 cubes surrounding it: 1-4 below, 5-8 above
- On the ship tower (B00001001): Sector T<z> Couloir <1-6>
- z is the level
- couloir depends of your x, y position (polar coordinates could help)
=================
HYPERSHIP TIME?
=================
- * the amount of days since hypership launch, July 3rd 2010 00:00 UTC
+ * The amount of days since hypership launch, July 3rd 2010 00:00 UTC
* So the decimal part is like internet time, but in GMT and not CET/CEST
===============
SIDE PROJECTS
===============
* A pazaak game, to have something to play
* Will be an Arzakon client
=================
I WANT TO HELP!
=================
* You can create new SmartLine commands
* You can translate it in a new language
Start point: http://zed.dereckson.be/lang/en/core.conf
* You can code a bit of adventure, places description, stuff to do
as long you don't transform it in ogame clone (we're building a community
who want or don't want to play, but not a mechanic game)
and as long no money is involved (if you ask why, read Iain M. Banks novels)
in the hypership (in far asteroids, orbitals, planets you do what you want)
============
KNOWN BUGS
============
* Javascript get_hypership_time will returns 5.94 instead 5.094
Some %03d to add in /js/misc.js
* All URLs outside homepage will return Unknown URL
Well... only the home controller is coded.
* The floater rendering adds a black line under Opera
dojox.layout.floatingPane bug, need to check with last dojo version
* API /location query will break indent on location->body->location
beautify XML code to improve
* do.php allows any local location move, discarding FrL status
=======================
API - General methods
=======================
* /api.php/time
Returns hypership time
Public access
* /api.php/perso/<perso_id>
Returns perso object
Created only to test extensively recursivity of api xml output
It's disabled since 10.811 on zed.dereckson.be, if you need an alternative,
open a bug report with the fields you need. Ship API should be able to manage
inventory if user is on. Ship API must also be able to get/set custom flags.
Requires a key
* /api.php/location/<location code or name>
Returns location object
Tip: to get the full name, use string eg /api.php/location/Zeta?format=string
Requires a key
* GET/POST API parameters
- key
API key, ask it at zed at dereckson be, object [DEV] api key request
- format
- preview print_r representation, so you've an idea of the object
- json json_encode() output
- php serialize() output
- wddx WDDX were an early universal serialization attempt
- xml XML document
- string output "as is" (or if it's an object, calls __toString())
============
API - Ship
=============
* /api.php/ship/authenticate/<perso nickname>
=================
ACKNOWLEDGEMENT
=================
Elfix, to have let me figure a regexp correction, instead to throw away regexp
validation for places local location.
diff --git a/cache/openid/index.html b/cache/openid/index.html
new file mode 100644
--- /dev/null
+++ b/cache/openid/index.html
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd"
+ >
+<html lang="en">
+<head>
+ <title>Restricted directory</title>
+ <link rel="Stylesheet" href="../../css/zed/theme.css" type="text/css" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+</head>
+<body>
+ <div style="width: 960px; margin: auto; margin-top: 3em;">
+ <h1 style="font-size: 3em;">Zed</h1>
+ <h2>Restricted directory</h2>
+ <p>As you can guess from the URL, this directory contains <em>OpenID</em> cached information.</p>
+
+ <h3>Security tip</h3>
+ <p>To improve security, please move the <tt>/cache</tt> directory outside the webserver hierarchy.</p>
+ </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/includes/config.php b/includes/config.php
--- a/includes/config.php
+++ b/includes/config.php
@@ -1,239 +1,246 @@
<?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_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. 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/sessions');
-ini_set('session.gc_maxlifetime', 345600); //4 days, for week-end story pause and continue url
-
-
-////////////////////////////////////////////////////////////////////////////////
-/// ///
-/// VI. Caching ///
+/// 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
?>
diff --git a/includes/login.php b/includes/login.php
--- a/includes/login.php
+++ b/includes/login.php
@@ -1,136 +1,133 @@
<?php
/**
* Login/logout
*
* 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
*
* @todo reenable OpenID
* @todo Pick between DumbStore and FileStore and cleans the file accordingly.
*/
-if (!file_exists('/dev/urandom')) {
- //We're on Windows, without reliable source of random numbers
- define('Auth_OpenID_RAND_SOURCE', null);
-}
+require_once('Auth/OpenID/Consumer.php');
+require_once('Auth/OpenID/FileStore.php');
+
-//require_once('Auth/OpenID/Consumer.php');
-//require_once('Auth/OpenID/DumbStore.php');
-//require_once('Auth/OpenID/FileStore.php');
-
-/*
+/**
+ * Gets an Auth_OpenID_Consumer instance
+ *
+ * @return Auth_OpenID_Consumer the instance
+ */
function get_openid_consumer () {
if (!file_exists('/dev/urandom')) {
- //We're on Windows, without reliable source of random numbers
+ //We don't have a reliable source of random numbers
define('Auth_OpenID_RAND_SOURCE', null);
}
- $fs = new Auth_OpenID_FileStore('cache/openid');
+ $fs = new Auth_OpenID_FileStore(CACHE_DIR . '/openid');
return new Auth_OpenID_Consumer($fs);
}
-*/
+/**
+ * Logs in the user if the OpenID is recognized.
+ * Otherwise, sets an error message.
+ *
+ * @param string $url The OpenID URL
+ */
function openid_login ($url) {
global $db, $_SESSION, $LoginError, $LoginSuccessful;
$url = $db->sql_escape($url);
$sql = 'SELECT user_id FROM ' . TABLE_USERS_OPENID
. " WHERE openid_url LIKE '$url'";
if ($user_id = $db->sql_query_express($sql)) {
$sql = "UPDATE " . TABLE_SESSIONS . " SET user_id = '$user_id' WHERE session_id LIKE '$_SESSION[ID]'";
- if (!$db->sql_query($sql)) message_die(SQL_ERROR, "Impossible de procéder à la connexion", '', __LINE__, __FILE__, $sql);
+ if (!$db->sql_query($sql)) message_die(SQL_ERROR, "Can't update session table", '', __LINE__, __FILE__, $sql);
$LoginSuccessful = true;
setcookie("LastOpenID", $url, time() + 2592000);
header("location: " . get_url());
} else {
- $LoginError = "To join Zed, you need an invite. Read the source to get one.";
+ $LoginError = "Read the source to get an invite.";
}
}
-if ($_GET['action'] == 'openid.login') {
- $LoginError = "OpenID temporarily disabled.";
-/*
+$action = isset($_GET['action']) ? $_GET['action'] : '';
+
+if ($action == 'openid.login') {
//Gets Auth_OpenID_Consumer instance
- $fs = new Auth_OpenID_DumbStore("rien n'est sûr mais c'est une piste");
- //$fs = new Auth_OpenID_FileStore('cache/openid');
- $consumer = new Auth_OpenID_Consumer($fs);
- //$consumer = get_openid_consumer();
+ $consumer = get_openid_consumer();
//Completes the OpenID transaction
$reply = $consumer->complete(get_server_url() . $_SERVER['REQUEST_URI']);
if ($reply->status == Auth_OpenID_SUCCESS) {
openid_login($reply->endpoint->claimed_id);
} elseif ($reply->message) {
- $LoginError = "[OpenID] $reply->message";
+ //TODO: $reply->message could be rather long and won't fit in the UI
+ //space. You can wish to add code to print $LoginError elsewhere if
+ //too long.
+ $LoginError = "[OpenID] $reply->message";
} else {
$LoginError = "[OpenID] $reply->status";
}
-*/
-} elseif ($_POST['LogIn']) {
+} elseif (isset($_POST['LogIn'])) {
//User have filled login form
if ($_POST['openid']) {
- $LoginError = "OpenID temporarily disabled.";
-/*
//Gets Auth_OpenID_Consumer instance
- $fs = new Auth_OpenID_DumbStore("rien n'est sûr mais c'est une piste");
- //$fs = new Auth_OpenID_FileStore('cache/openid');
- $consumer = new Auth_OpenID_Consumer($fs);
- //$consumer = get_openid_consumer();
+ $consumer = get_openid_consumer();
//Starts the OpenID transaction and redirects user to provider url
if ($request = $consumer->begin($_POST['openid'])) {
$url = $request->redirectURL(get_server_url(), "$Config[SiteURL]/?action=openid.login", false);
header("location: $url");
$LoginError = '<a href="' . $url . '">Click here to continue login</a>';
} else {
$LoginError = 'Invalid OpenID URL.';
}
-*/
} else {
//GESTION LOGIN
$Login = $_POST['username'];
$sql = "SELECT user_password, user_id FROM " . TABLE_USERS . " WHERE username = '$Login'";
if ( !($result = $db->sql_query($sql)) ) message_die(SQL_ERROR, "Impossible d'interroger le listing des utilisateurs", '', __LINE__, __FILE__, $sql);
if ($row = $db->sql_fetchrow($result)) {
if (!$row['user_password']) {
$LoginError = "This account exists but haven't a password defined. Use OpenID or contact dereckson (at) espace-win.org to fix that.";
} elseif ($row['user_password'] != md5($_POST['password'])) {
//PASS NOT OK
$LoginError = "Incorrect password.";
} else {
login($row[user_id], $Login);
$LoginSuccessful = true;
}
} else {
//Idiot proof facility
//Redirects people using login page as invitation claim page
$code = $db->sql_escape($_POST['password']);
$sql = "SELECT * FROM " . TABLE_USERS_INVITES . " WHERE invite_code = '$code'";
if (!$result = $db->sql_query($sql)) {
message_die(SQL_ERROR, "Can't get invites", '', __LINE__, __FILE__, $sql);
}
if ($row = $db->sql_fetchrow($result)) {
$url = get_url('invite', $_POST['password']);
header('location: ' . $url);
}
//Login not found
$LoginError = "Login not found.";
}
}
-} elseif ($_POST['LogOut'] || $_GET['action'] == "user.logout") {
+} elseif (isset($_POST['LogOut']) || $action == "user.logout") {
Logout();
}
?>
diff --git a/index.php b/index.php
--- a/index.php
+++ b/index.php
@@ -1,230 +1,230 @@
<?php
/**
* Application entry point
*
* Zed. The immensity of stars. The HyperShip. The people.
*
* (c) 2010, Dereckson, some rights reserved.
* Released under BSD license.
*
* @package Zed
* @subpackage EntryPoints
* @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
* @todo Consider to split the different tasks (especially
* perso select/create into several files)
*/
////////////////////////////////////////////////////////////////////////////////
///
/// Initialization
///
//Keruald (formelly Pluton) library
include('includes/core.php');
//Session
$IP = encode_ip($_SERVER["REMOTE_ADDR"]);
require_once('includes/story/story.php'); //this class can be stored in session
session_start();
$_SESSION[ID] = session_id();
session_update(); //updates or creates the session
include("includes/login.php"); //login/logout
$CurrentUser = get_logged_user(); //Gets current user infos
//Gets current perso
require_once('includes/objects/perso.php');
if ($perso_id = $CurrentUser->session['perso_id']) {
$CurrentPerso = new Perso($perso_id);
}
//Skin and accent to load
define('THEME', $CurrentUser->session['Skin']);
define('ACCENT', $CurrentUser->session['Skin_accent']);
//Loads Smarty
require('includes/Smarty/Smarty.class.php');
$smarty = new Smarty();
$current_dir = dirname(__FILE__);
$smarty->template_dir = $current_dir . '/skins/' . THEME;
-$smarty->compile_dir = $current_dir . '/cache/compiled';
-$smarty->cache_dir = $current_dir . '/cache';
+$smarty->compile_dir = CACHE_DIR . '/compiled';
+$smarty->cache_dir = CACHE_DIR;
$smarty->config_dir = $current_dir;
$smarty->config_vars['StaticContentURL'] = $Config['StaticContentURL'];
//Loads language files
initialize_lang();
lang_load('core.conf');
//Gets URL
$url = get_current_url_fragments();
//If the user isn't logged in (is anonymous), prints login/invite page & dies.
if ($CurrentUser->id < 1000) {
include('controllers/anonymous.php');
exit;
}
////////////////////////////////////////////////////////////////////////////////
///
/// Perso selector
///
//Handles form
if ($_POST['form'] == 'perso.create') {
$perso = new Perso();
$perso->load_from_form();
$perso->user_id = $CurrentUser->id;
//Validates forms
if (!$perso->name) $errors[] = lang_get("NoFullnameSpecified");
if (!$perso->race) {
$errors[] = lang_get("NoRaceSpecified");
$perso->race = "being";
}
if (!$perso->sex) $errors[] = lang_get("NoSexSpecified");
if (!$perso->nickname) {
$errors[] = lang_get("NoNicknameSpecified");
} else if (!Perso::is_available_nickname($perso->nickname)) {
$errors[] = lang_get("UnavailableNickname");
}
//Save or prints again forms
if (!$errors) {
//Saves perso, logs in
$perso->save_to_database();
$smarty->assign('NOTIFY', lang_get('NewCharacterCreated'));
$CurrentPerso = $perso;
set_info('perso_id', $perso->id);
$CurrentPerso->set_flag("site.lastlogin", $_SERVER['REQUEST_TIME']);
//Notifies inviter
require_once('includes/objects/message.php');
require_once('includes/objects/invite.php');
$message = new Message();
$message->from = 0;
$message->to = invite::who_invited($perso->id);
$message->text = sprintf(
lang_get('InvitePersoCreated'),
$perso->name,
get_server_url() . get_url('who', $perso->nickname)
);
$message->send();
} else {
$smarty->assign('WAP', join("<br />", $errors));
$smarty->assign('perso', $perso);
}
}
if ($_GET['action'] == 'perso.logout' && $CurrentPerso != null) {
//User wants to change perso
$CurrentPerso->on_logout();
$CurrentPerso = null;
} elseif ($_GET['action'] == 'perso.select') {
//User have selected a perso
$CurrentPerso = new Perso($_GET['perso_id']);
if ($CurrentPerso->user_id != $CurrentUser->id) {
//Hack
message_die(HACK_ERROR, "This isn't your perso.");
}
$CurrentPerso->on_select();
}
if (!$CurrentPerso) {
switch ($count = Perso::get_persos_count($CurrentUser->id)) {
case 0:
//User have to create a perso
$smarty->display("perso_create.tpl");
exit;
case 1:
//Autoselects only perso
$CurrentPerso = Perso::get_first_perso($CurrentUser->id);
$CurrentPerso->on_select();
break;
default:
//User have to pick a perso
$persos = Perso::get_persos($CurrentUser->id);
$smarty->assign("PERSOS", $persos);
$smarty->display("perso_select.tpl");
$_SESSION['UserWithSeveralPersos'] = true;
exit;
}
}
//Assigns current perso object as Smarty variable
$smarty->assign('CurrentPerso', $CurrentPerso);
////////////////////////////////////////////////////////////////////////////////
///
/// Tasks to execute before calling the URL controller:
/// - assert the perso is somewhere
/// - executes the smartline
///
//If the perso location is unknown, ejects it to an asteroid
if (!$CurrentPerso->location_global) {
require_once('includes/geo/place.php');
$smarty->assign('NOTIFY', lang_get('NewLocationNotify'));
$CurrentPerso->move_to(GeoPlace::get_start_location());
}
//SmartLine
include("includes/SmartLine/ZedSmartLine.php");
//Redirects user to user request controller if site.requests flag on
if (defined('PersoSelected') && array_key_exists('site.requests', $CurrentPerso->flags) && $CurrentPerso->flags['site.requests']) {
include('controllers/persorequest.php');
}
////////////////////////////////////////////////////////////////////////////////
///
/// Calls the specific controller to serve the requested page
///
switch ($controller = $url[0]) {
case '':
include('controllers/home.php');
break;
case 'request':
case 'page':
case 'explore':
case 'ship':
case 'settings':
include("controllers/$controller.php");
break;
case 'who':
include('controllers/profile.php'); //Azhàr controller
break;
case 'push':
include('controllers/motd.php'); //Azhàr controller
break;
case 'quux':
//It's like a test/debug console/sandbox, you put what you want into
if (file_exists('dev/quux.php')) {
include('dev/quux.php');
} else {
message_die(GENERAL_ERROR, "Quux lost in Hollywood.", "Nay");
}
break;
default:
//TODO: returns a 404 error
dieprint_r($url, 'Unknown URL');
}
?>
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Nov 25, 04:26 (2 h, 22 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21219
Default Alt Text
(30 KB)
Attached To
rZEDHG ZedLegacy
Event Timeline
Log In to Comment