Page MenuHomeCode

No OneTemporary

diff --git a/controllers/motd.php b/controllers/motd.php
index d62dc7c..559a6a0 100644
--- a/controllers/motd.php
+++ b/controllers/motd.php
@@ -1,41 +1,41 @@
<?php
/*
* Azhàr, faeries intranet
* (c) 2009-2010, Wolfæym, some rights reserved
* Released under BSD license
*
* Raw text or HTML content
*/
//Loads smarty language file
lang_load('motd.conf');
//
// Handles form
//
if ($_REQUEST['text']) {
require_once('includes/objects/motd.php');
$motd = new MOTD();
$motd->text = $_REQUEST['text'];
- $motd->user_id = $CurrentUser->id;
- $motd->saveToDatabase();
+ $motd->perso_id = $CurrentPerso->id;
+ $motd->save_to_database();
$smarty->assign('WAP', lang_get('Published'));
}
//
// HTML output
//
//Serves header
$smarty->assign('PAGE_TITLE', lang_get('PushMessage'));
include('header.php');
//Serves content
$smarty->display('motd_add.tpl');
//Servers footer
include('footer.php');
?>
\ No newline at end of file
diff --git a/includes/objects/motd.php b/includes/objects/motd.php
new file mode 100644
index 0000000..0c42856
--- /dev/null
+++ b/includes/objects/motd.php
@@ -0,0 +1,70 @@
+<?php
+
+/*
+ * Zed
+ * (c) 2010, Dereckson, some rights reserved
+ * Released under BSD license
+ *
+ * MOTD class.
+ *
+ * 0.1 2010-02-03 21:11 Import from Azhàr
+ *
+ */
+
+class MOTD {
+
+ public $id;
+ public $perso_id;
+ public $text;
+ public $date;
+
+ function __construct ($id = '') {
+ if ($id) {
+ $this->id = $id;
+ return $this->load_from_database();
+ } else {
+ $this->date = time();
+ return true;
+ }
+ }
+
+ //Loads the object MOTD (ie fill the properties) from the $_POST array
+ function load_from_form () {
+ if (array_key_exists('perso_id', $_POST)) $this->user_id = $_POST['user_id'];
+ if (array_key_exists('text', $_POST)) $this->text = $_POST['text'];
+ if (array_key_exists('date', $_POST)) $this->date = $_POST['date'];
+ }
+
+ //Loads the object MOTD (ie fill the properties) from the database
+ function load_from_database () {
+ global $db;
+ $id = $db->sql_escape($this->id);
+ $sql = "SELECT * FROM " . TABLE_MOTD . " WHERE motd_id = '" . $id . "'";
+ if ( !($result = $db->sql_query($sql)) ) message_die(SQL_ERROR, "Unable to query azhar_motd", '', __LINE__, __FILE__, $sql);
+ if (!$row = $db->sql_fetchrow($result)) {
+ $this->lastError = "MOTD unkwown: " . $this->id;
+ return false;
+ }
+ $this->perso_id = $row['perso_id'];
+ $this->text = $row['motd_text'];
+ $this->date = $row['motd_date'];
+ return true;
+ }
+
+ //Saves the object to the database
+ function save_to_database () {
+ global $db;
+ $id = $this->id ? "'" . $db->sql_escape($this->id) . "'" : 'NULL';
+ $perso_id = $db->sql_escape($this->perso_id);
+ $text = $db->sql_escape($this->text);
+ $date = $db->sql_escape($this->date);
+
+ $sql = "REPLACE INTO " . TABLE_MOTD . " (`motd_id`, `perso_id`, `motd_text`, `motd_date`) VALUES ($id, '$perso_id', '$text', '$date')";
+ if (!$db->sql_query($sql)) {
+ message_die(SQL_ERROR, "Unable to save", '', __LINE__, __FILE__, $sql);
+ }
+ }
+}
+
+?>
+
diff --git a/index.php b/index.php
index 369d08b..c880f2b 100644
--- a/index.php
+++ b/index.php
@@ -1,190 +1,194 @@
<?php
/*
* Zed
* (c) 2010, Dereckson, some rights reserved
* Released under BSD license
*
* Application entry point
*/
////////////////////////////////////////////////////////////////////////////////
///
/// Initialization
///
//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->config_dir = $current_dir;
$smarty->config_vars['StaticContentURL'] = $Config['StaticContentURL'];
//Loads language files
define('LANG', 'fr');
lang_load('core.conf');
if ($CurrentUser->id < 1000) {
//Anonymous user, proceed to login
if (array_key_exists('LastUsername', $_COOKIE))
$smarty->assign('username', $_COOKIE['LastUsername']);
if (array_key_exists('LastOpenID', $_COOKIE))
$smarty->assign('OpenID', $_COOKIE['LastOpenID']);
$smarty->assign('LoginError', $LoginError);
$smarty->display('login.tpl');
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) {
$perso->save_to_database();
$smarty->assign('NOTIFY', lang_get('NewCharacterCreated'));
$CurrentPerso = $perso;
set_info('perso_id', $perso->id);
$CurrentPerso->setflag("site.lastlogin", $_SERVER['REQUEST_TIME']);
} else {
$smarty->assign('WAP', join("<br />", $errors));
$smarty->assign('perso', $perso);
}
}
if ($_GET['action'] == 'perso.logout') {
//User wants to change perso
$CurrentPerso = null;
set_info('perso_id', null);
clean_session();
} 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.");
}
set_info('perso_id', $CurrentPerso->id);
$CurrentPerso->setflag("site.lastlogin", $_SERVER['REQUEST_TIME']);
}
if (!$CurrentPerso) {
switch ($count = Perso::get_persos_count($CurrentUser->id)) {
case 0:
//Create a perso
$smarty->display("perso_create.tpl");
exit;
case 1:
//Autoselect
$CurrentPerso = Perso::get_first_perso($CurrentUser->id);
set_info('perso_id', $CurrentPerso->id);
$CurrentPerso->setflag("site.lastlogin", $_SERVER['REQUEST_TIME']);
break;
default:
//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");
////////////////////////////////////////////////////////////////////////////////
///
/// Calls the specific controller to serve the requested page
///
$url = get_current_url_fragments();
switch ($controller = $url[0]) {
case '':
include('controllers/home.php');
break;
case 'request':
case 'page':
case 'explore':
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;
default:
//TODO: returns a 404 error
dieprint_r($url, 'Unknown URL');
}
?>
\ No newline at end of file
diff --git a/lang/en/core.conf b/lang/en/core.conf
index 30a5754..870239c 100644
--- a/lang/en/core.conf
+++ b/lang/en/core.conf
@@ -1,121 +1,134 @@
#Zed language config file
#Language: English
#Code: en
#Author: Dereckson
###
### Site configuration
###
SiteTitle = Zed
Product = "<strong>Zed 0.1</strong>, alpha technical preview"
###
### General stuff
###
_t = ":"
###
### Login
###
Login = Login
Password = Password
OK = OK
LoginNotFound = Login not found.
IncorrectPassword = Incorrect password.
JaMata = Ja mata!
WelcomeBack = Welcome back.
OpenID = OpenID
Logout = Logout
###
### Errors
###
UnauthorizedAccess = "Unauthorized access"
SQLError = "SQL Error"
line = line
Error = Error
BackToHome = "Back to homepage"
FatalErrorScreen = Fatal error screen
FatalErrorInterrupt = Fatal error breaking screen
GeneralError = General error
PageNotFound = "Page not found"
###
### Homepage
###
Welcome = Welcome
WelcomeText = "<p>Welcome to the Zed alpha technical preview. Zed, it's a mix between a gallery, a place to meet new and existing friends, with some RPG inspiration.<br />
The concept is to have each information stored at physical places in a virtual world, like the 80s cyberspace vision. Another goal is to build a community sharing values like cooperation, freedom, ethic.</p>"
###
### Homepage - messages
###
#messages.tpl, Reply
Reply = Reply
#messages.tpl, the X link title
DeleteThisMessage = Delete this message
#home.php, messages error
MessageDeleted = Message deleted.
NotYourMessage = This message is not one of yours.
MessageAlreadyDeleted = Message already deleted.
###
### Perso create/select
###
NewCharacterCreated = New character created
CreateCharacter = Create a character
EditCharacter = Edit %s information
NoSexSpecified = "Pick a sex, or '<em>Neutral</em>' if you don't want to tell it."
NoNicknameSpecified = "You must pick a nickname, it's like your login to identify your character."
NoFullnameSpecified = "All beings must have a name."
NoRaceSpecified = "You've to specify a race: '<em>humanoid</em>' for human and co.<br />If you don't want to specify a race, use the generic '<em>being</em>'."
NicknameUnavailable = "This nickname is already used.<br />Choose a more original one."
PickPerso = Pick your perso
SwapPerso = "Swap perso (%s's logout)"
NewLocationNotify = "You're slowly awaking in a place you don't recognize."
###
### Places
###
UnknownBody = "Unknown asteroid"
UnknownPlace = "Unknown place"
WherePlace = "%s @ %s"
SpaceAround = "Space around %s"
hypership = hypership
asteroid = asteroid
moon = moon
planet = planet
star = star
orbital = orbital
###
### Stories
###
InvalidStoryGUID = "In story mode, you can't use previous/back URL."
ExpiredStorySession = "Story choices URL are temporary.<br />You can't bookmark them or use in another session."
###
### Requests
###
-Title = Title
\ No newline at end of file
+Title = Title
+
+###
+### MOTD
+###
+
+PushMessage = Push a message to the header
+TextToAdd = Text to add
+TextToAddWarning = Warning: once published, it can't be (easily) removed.
+Rendering = How it will be printed?
+RenderingWhere = "At the top right header corner:"
+DummyPlaceholder = Here your message.
+Push = Push
+Published = Published :)
\ No newline at end of file
diff --git a/lang/fr/core.conf b/lang/fr/core.conf
index 06f9db3..e7feedb 100644
--- a/lang/fr/core.conf
+++ b/lang/fr/core.conf
@@ -1,122 +1,136 @@
#Zed language config file
#Language: English
#Code: fr
#Author: Dereckson
###
### Site configuration
###
SiteTitle = Zed
Product = "<strong>Zed 0.1</strong>, alpha technical preview"
###
### General stuff
###
_t = " :"
###
### Login
###
Login = Login
Password = Password
OK = OK
LoginNotFound = Login introuvable.
IncorrectPassword = Mot de passe incorrect.
JaMata = Ja mata!
WelcomeBack = Welcome back.
OpenID = OpenID
Logout = Déconnexion
###
### Homepage
###
Welcome = Bienvenue
WelcomeText = "<p>Bienvenue sur la version alpha de Zed, un hybride un peu étrange entre une galerie, un endroit où rencontrer ses amis ou s'en faire de nouveaux, avec une légère inspiration RPG, dans un environnement galactique inspiré des romans de la Culture de Iain M. Banks.</p>
<p>Le concept est d'expérimenter ce qui se passe lorsque chaque information est dans un espace précis, un peu comme la vision cyberpunk des années 80 du cyberespace. Un autre but est de créer une communauté partagant des valeurs de respect, de coopération, de liberté et d'éthique.</p>"
###
### Homepage - Messages
###
#messages.tpl, Reply
Reply = Répondre
#messages.tpl, the X link title
DeleteThisMessage = Effacer ce message
#home.php, messages error
MessageDeleted = Message effacé.
NotYourMessage = Hey, ce message appartient à autrui !
MessageAlreadyDeleted = Message déjà effacé
###
### Errors
###
UnauthorizedAccess = "Accès non autorisé"
SQLError = "Erreur dans la requête SQL"
line = ligne
Error = Erreur
BackToHome = "Retour à la page d'accueil"
FatalErrorScreen = Fatal error screen
FatalErrorInterrupt = Fatal error screen (interruption)
GeneralError = "Erreur"
PageNotFound = "Cette page n'existe pas."
###
### Perso create/select
###
NewCharacterCreated = Nouveau perso créé.
CreateCharacter = Nouveau perso
EditCharacter = Éditer les infos de %s
NoSexSpecified = "Pick a sex, or '<em>Neutral</em>' if you don't want to tell it."
NoNicknameSpecified = "You must pick a nickname, it's like your login to identify your character."
NoFullnameSpecified = "All beings must have a name."
NoRaceSpecified = "You've to specify a race: '<em>humanoid</em>' for human and co.<br />If you don't want to specify a race, use the generic '<em>being</em>'."
NicknameUnavailable = "This nickname is already used.<br />Choose a more original one."
PickPerso = "Sélectionnez votre perso"
SwapPerso = "Changer de perso (déco %s)"
NewLocationNotify = "Vous vous réveillez lentement dans un endroit inconnu"
###
### Places
###
UnknownBody = "Astéroïde inconnu"
UnknownPlace = "Endroit inconnu"
WherePlace = "%2$s, %1$s."
SpaceAround = "%s et l'espace autour"
hypership = hypership
asteroid = astéroïde
moon = lune
planet = planète
star = étoile
orbital = orbitale
###
### Stories
###
InvalidStoryGUID = "En mode récit, il n'est pas possible <br />d'utiliser les boutons précédents et suivants."
ExpiredStorySession = "Les URL de choix sont temporaires.<br />Il n'est pas possible de les bookmark pour y revenir."
###
### Requests
###
-Title = Titre
\ No newline at end of file
+Title = Titre
+
+###
+### MOTD
+###
+
+
+PushMessage = Publier un message tout en haut
+TextToAdd = Texte à ajouter
+TextToAddWarning = "Une fois publié, ne peut être facilement enlevé."
+Rendering = Aperçu
+RenderingWhere = "Coin supérieur droit de la page :"
+DummyPlaceholder = Lorem ipsum dolor.
+Push = Publier
+Published = Publié :)
\ No newline at end of file
diff --git a/skins/zed/motd_add.tpl b/skins/zed/motd_add.tpl
new file mode 100644
index 0000000..9d03daf
--- /dev/null
+++ b/skins/zed/motd_add.tpl
@@ -0,0 +1,33 @@
+<!-- MOTD preview code -->
+<script>
+ function updateWall () {
+ wallTextValue = document.getElementById("WallText").value;
+ wallText = wallTextValue ? wallTextValue : "{#DummyPlaceholder#}";
+ document.getElementById("wall_message").innerHTML = wallText;
+ }
+</script>
+
+<!-- Add something on the MOTD -->
+
+<h1>{#PushMessage#}</h1>
+<form method="post">
+ <label for="WallAddText">{#TextToAdd#}{#_t#}</label><br />
+ <input type="text" maxlength="80" size="80" id="WallText" name="text" onblur="updateWall();" onkeyup="updateWall();" onchange="updateWall();" />
+ <input type="submit" value="{#Push#}" />
+</form>
+<em>{#TextToAddWarning#}</em>
+
+<h2>{#Rendering#}</h2>
+<div class="grid_4 alpha">
+ <p><em>{#RenderingWhere#}</em></p>
+</div>
+<div class="grid_12 omega">
+ <div class="wall">
+ <p>
+ <span id="wall_message">{#DummyPlaceholder#}</span>
+ <br /><span class="wall_info">-- <a href="{get_url('who', $CurrentPerso->nickname)}">{$CurrentPerso->name}</a></span>
+ </p>
+ <div class="clear"></div>
+ </div>
+ <div class="clear"></div>
+</div>
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Fri, Nov 15, 18:17 (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21044
Default Alt Text
(17 KB)

Event Timeline