Page MenuHomeCode

No OneTemporary

This document is not UTF8. It was detected as ISO-8859-1 (Latin 1) and converted to UTF8 for display.
diff --git a/controllers/profile.php b/controllers/profile.php
--- a/controllers/profile.php
+++ b/controllers/profile.php
@@ -1,308 +1,308 @@
<?php
/*
* Zed
* (c) 2010, Dereckson, some rights reserved
* Released under BSD license
*
* This code is maintained in // with Azhàr
*
* User profile
*/
//Loads language file
lang_load('profile.conf');
//Gets perso nickname from URL
$who = $url[1];
switch ($who) {
case 'edit':
$mode = 'edit';
$who = $CurrentPerso->nickname;
break;
case 'random':
$mode = 'view';
$who = $db->sql_query_express("SELECT perso_id FROM " . TABLE_PROFILES . " ORDER BY rand() LIMIT 1");
break;
default:
$mode = 'view';
}
if (!$who) {
message_die(GENERAL_ERROR, "Who?", "URL error");
}
//Libs
require_once('includes/objects/profile.php');
require_once('includes/objects/profilecomment.php');
require_once('includes/objects/profilephoto.php');
//Gets perso information
require_once('includes/objects/perso.php');
$perso = Perso::get($who);
if ($perso->lastError) {
message_die(GENERAL_ERROR, $perso->lastError, "Error");
}
$smarty->assign('perso', $perso);
//Gets profile
$profile = new Profile($perso->id);
//Handles form
if ($_POST['EditProfile']) {
$profile->load_from_form();
$profile->updated = time();
$profile->save_to_database();
$mode = 'view';
} elseif ($_POST['UserAccount']) {
- $smarty->assign('WAP', "Your form haven't been handled. Remember Dereckson to code this, profile.php line 59.");
- //$perso->load_from_form(false);
- $mode = 'view';
+ $smarty->assign('WAP', "This form have been deprecated. You can write instead settings in the SmartLine");
} elseif ($_POST['message_type'] == 'private_message') {
//Sends a message
require_once('includes/objects/message.php');
$msg = new Message();
$msg->from = $CurrentPerso->id;
$msg->to = $perso->id;
$msg->text = $_POST['message'];
$msg->send();
if ($msg->from == $msg->to) {
$smarty->assign('NOTIFY', lang_get('MessageSentSelf'));
} else {
$smarty->assign('NOTIFY', lang_get('MessageSent'));
}
} elseif ($_POST['message_type'] == 'profile_comment') {
//New profile comment
$comment = new ProfileComment();
$comment->author = $CurrentPerso->id;
$comment->perso_id = $perso->id;
$comment->text = $_POST['message'];
$comment->publish();
$smarty->assign('NOTIFY', lang_get('CommentPublished'));
} elseif ($_FILES['photo']) {
#We've a file !
$hash = md5(microtime() . serialize($_FILES));
$extension = get_extension($_FILES['photo']['name']);
$filename = $CurrentPerso->id . '_' . $hash . '.' . $extension;
#We ignore $_FILES[photo][error] 4, this means no file has been uploaded
#(so user doesn't want upload a new file)
#See http:/www.php.net/features.file-upload and http://www.php.net/manual/en/features.file-upload.errors.php about common errors
#Not valid before PHP 4.2.0
switch ($_FILES['photo']['error']) {
case 0:
#There is no error, the file uploaded with success.
if (!move_uploaded_file($_FILES['photo']['tmp_name'], PHOTOS_DIR . '/' . $filename)) {
$errors[] = "Upload successful, but error saving it.";
} else {
//Attaches the picture to the profile
$photo = new ProfilePhoto();
$photo->name = $filename;
$photo->perso_id = $CurrentPerso->id;
$photo->description = $_POST['description'];
if ($photo->avatar) $photo->promote_to_avatar();
$photo->save_to_database();
//Generates thumbnail
if (!$photo->generate_thumbnail()) {
$smarty->assign('WAP', "Error generating thumbnail.");
}
$smarty->assign('NOTIFY', lang_get('PhotoUploaded'));
$mode = 'view';
}
break;
case 1:
$errors[] = "The file is too large.";
break;
#TODO : more explicit error messages
default:
$errors[] = "Unknown error (#" . $_FILES['photo']['error'] . ")";
break;
}
if (count($errors)) {
$smarty->assign('WAP', join($errors, '<br />'));
}
} elseif ($_POST['id']) {
//Edits photo properties
$photo = new ProfilePhoto($_POST['id']);
if ($photo->lastError) {
$smarty->assign('WAP', $photo->lastError);
$mode = 'view';
} elseif ($photo->perso_id != $CurrentPerso->id) {
$smarty->assign('WAP', lang_get('NotYourPic'));
$mode = 'view';
} else {
//OK
$wereAvatar = $photo->avatar;
$photo->load_from_form();
if (!$wereAvatar && $photo->avatar) {
//Promote to avatar
$photo->promote_to_avatar();
}
$photo->save_to_database();
}
}
//Prepares output
if ($profile->text) {
//Profile
$smarty->assign('PROFILE_TEXT', $profile->text);
$smarty->assign('PROFILE_FIXEDWIDTH', $profile->fixedwidth);
}
if ($mode == 'view') {
require_once('includes/objects/profilephoto.php');
//Self profile?
$self = $CurrentPerso->id == $profile->perso_id;
- //Gets profiles comments, photos
+ //Gets profiles comments, photos, tags
$comments = ProfileComment::get_comments($profile->perso_id);
$photos = ProfilePhoto::get_photos($profile->perso_id);
+ $tags = $profile->get_cached_tags();
//Records timestamp, to be able to track new comments
if ($self) $CurrentPerso->set_flag('profile.lastvisit', time());
//Template
$smarty->assign('PROFILE_COMMENTS', $comments);
$smarty->assign('PROFILE_SELF', $self);
+ if ($tags) $smarty->assign('PROFILE_TAGS', $tags);
$smarty->assign('USERNAME', $perso->username);
$smarty->assign('NAME', $perso->name ? $perso->name : $perso->nickname);
$template = 'profile.tpl';
} elseif ($mode == 'edit') {
switch ($url[2]) {
case 'profile':
$smarty->assign('USERNAME', $perso->name);
$smarty->assign('DIJIT', true);
$css[] = THEME . '/forms.css';
$template = 'profile_edit.tpl';
break;
case 'account':
$smarty->assign('user', $CurrentUser);
$smarty->assign('DIJIT', true);
$css[] = THEME . '/forms.css';
$template = 'user_account.tpl';
break;
case '':
$smarty->assign('NOTIFY', "What do you want to edit ? Append /profile, /account or /photos to the URL");
break;
case 'photo':
case 'photos':
$smarty->assign('USERNAME', $perso->name);
switch ($action = $url[3]) {
case '':
//Nothing to do
break;
case 'delete':
//Deletes a picture
if (!$id = $url[4]) {
$smarty->assign('WAP', "URL error. Parameter missing: picture id.");
} else {
$photo = new ProfilePhoto($id);
if ($photo->lastError) {
//Probably an non existent id (e.g. double F5, photo already deleted)
$smarty->assign('WAP', $photo->lastError);
} elseif ($photo->perso_id != $CurrentPerso->id) {
$smarty->assign('WAP', lang_get('NotYourPic'));
} else {
//OK we can delete it
$photo->delete();
$smarty->assign('NOTIFY', lang_get('PictureDeleted'));
}
}
break;
case 'edit':
if (!$id = $url[4]) {
$smarty->assign('WAP', "URL error. Parameter missing: picture id.");
} else {
$photo = new ProfilePhoto($id);
if ($photo->lastError) {
//Probably an non existent id (e.g. double F5, photo already deleted)
$smarty->assign('WAP', $photo->lastError);
} elseif ($photo->perso_id != $CurrentPerso->id) {
$smarty->assign('WAP', lang_get('NotYourPic'));
} else {
//Photo information edit form
$smarty->assign('photo', $photo);
$template = 'profile_photo_edit.tpl';
}
}
break;
case 'avatar':
//Promotes a picture to avatar
if (!$id = $url[4]) {
$smarty->assign('WAP', "URL error. Parameter missing: picture id.");
} else {
$photo = new ProfilePhoto($id);
if ($photo->lastError) {
$smarty->assign('WAP', $photo->lastError);
} elseif ($photo->perso_id != $CurrentPerso->id) {
$smarty->assign('WAP', lang_get('NotYourPic'));
} else {
//OK, promote it to avatar
$photo->promote_to_avatar();
$photo->save_to_database();
$smarty->assign('NOTIFY', lang_get('PromotedToAvatar'));
}
}
break;
default:
$smarty->assign('WAP', "Unknown URL. To delete a picture it's /delete/<picture id>. To edit it /edit/<picture id>");
break;
}
if (!$template) {
$photos = ProfilePhoto::get_photos($profile->perso_id);
if (!$smarty->_tpl_vars['NOTIFY'])
$smarty->assign('NOTIFY', "Your feedback is valued. Report any bug or suggestion on the graffiti wall.");
$template = 'profile_photo.tpl';
}
break;
default:
$smarty->assign('WAP', "URL error. You can use /edit with profile, account or photos.");
break;
}
}
//
// HTML output
//
//Photos
if (count($photos) || $photo) {
$smarty->assign('URL_PICS', PHOTOS_URL);
$css[] = 'lightbox.css';
$smarty->assign('PAGE_JS', array('prototype.js', 'effects.js', 'lightbox.js'));
$smarty->assign('PICS', $photos);
}
//Serves header
$css[] = THEME . "/profile.css";
$smarty->assign('PAGE_CSS', $css);
$smarty->assign('PAGE_TITLE', $perso->name);
include('header.php');
//Serves content
if ($template) $smarty->display($template);
//Serves footer
include('footer.php');
?>
\ No newline at end of file
diff --git a/css/zed/profile.css b/css/zed/profile.css
--- a/css/zed/profile.css
+++ b/css/zed/profile.css
@@ -1,124 +1,140 @@
-@charset "utf-8";
-
-/* -------------------------------------------------------------
- Zed
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Author: Dereckson
- Tags: space retro futurist
- Filename: profile.css
- Version: 1.0
- Created: 2010-01-27
- Updated: 2010-02-11
- Licence: Creative Commons BY 3.0
- ------------------------------------------------------------- */
-
-/* -------------------------------------------------------------
- Profile header
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
-.profile_id {
- height: 40px;
- line-height: 1.2em;
- background-color: black;
- color: white;
-}
-
-.profile_id H1 {
- color: #04acf8;
-}
-
-.profile_info {
- float: right;
- font-size: 0.90em;
- padding-right: 1em;
-}
-
-.profile_info a {
- color: white;
-}
-
-.profile_info a:hover {
- color: white;
- font-weight: bold;
-}
-
-.profile_nick {
- float: left;
- margin-top: 0;
- height: 30px;
- padding-left: 12px;
- padding-top: 10px;
- font-size: 1.25em;
- font-weight: 500;
- border-left: solid #04acf8 6px;
-}
-
-/* -------------------------------------------------------------
- Profile
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
-.profile {
- background-color: black;
- color: white;
- margin-bottom: 20px;
- border: 2px solid #04acf8;
-}
-
-.profile_text {
- margin-left: 10px;
- margin-right: 10px;
- padding-top: 1em;
- font-size: 1em;
- text-align: justify;
-}
-
-.profile_text img {
- border: 0px;
-}
-
-.profile_text.fixedwidth {
- font-family: "Fixedsys Excelsior 3.01", Fixedsys, Fixed;
- white-space: pre;
-}
-
-
-/* -------------------------------------------------------------
- Profile comments
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
-.profile_comments {
- background-color: #fafafa;
- border: solid 1px #dedede;
-}
-
-.profile_comments_info {
- font-style: italic;
-}
-
-.profile_comments_text {
- font-size: 1.25em;
-}
-
-/* -------------------------------------------------------------
- Profile editor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
-.photos {
-}
-
-.photo img {
- margin: 8px 0px 12px 20px;
- border: 0;
-}
-
-.photo {
- float: left;
-}
-
-/* -------------------------------------------------------------
- Profile sidebar
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
-#sidebar {
- color: white;
-}
+@charset "utf-8";
+
+/* -------------------------------------------------------------
+ Zed
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ Author: Dereckson
+ Tags: space retro futurist
+ Filename: profile.css
+ Version: 1.0
+ Created: 2010-01-27
+ Updated: 2010-02-11
+ Licence: Creative Commons BY 3.0
+ ------------------------------------------------------------- */
+
+/* -------------------------------------------------------------
+ Profile header
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+.profile_id {
+ height: 40px;
+ line-height: 1.2em;
+ background-color: black;
+ color: white;
+}
+
+.profile_id H1 {
+ color: #04acf8;
+}
+
+.profile_info {
+ float: right;
+ font-size: 0.90em;
+ padding-right: 1em;
+}
+
+.profile_info a {
+ color: white;
+}
+
+.profile_info a:hover {
+ color: white;
+ font-weight: bold;
+}
+
+.profile_nick {
+ float: left;
+ margin-top: 0;
+ height: 30px;
+ padding-left: 12px;
+ padding-top: 10px;
+ font-size: 1.25em;
+ font-weight: 500;
+ border-left: solid #04acf8 6px;
+}
+
+/* -------------------------------------------------------------
+ Profile
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+.profile {
+ background-color: black;
+ color: white;
+ margin-bottom: 20px;
+ border: 2px solid #04acf8;
+}
+
+.profile_text, .profile_message, .profile_tags {
+ margin-left: 10px;
+ margin-right: 10px;
+}
+
+.profile_text {
+ padding-top: 1em;
+ font-size: 1em;
+ text-align: justify;
+}
+
+.profile_text img {
+ border: 0px;
+}
+
+.profile_text.fixedwidth {
+ font-family: "Fixedsys Excelsior 3.01", Fixedsys, Fixed;
+ white-space: pre;
+}
+
+.profile_separator_light {
+ height: 1em;
+ border-bottom: 1px solid #04acf8;
+}
+
+.profile_tags dt {
+ font-weight: 900;
+ color: #04acf8;
+}
+
+.profile_tags dd {
+ text-align: justify;
+}
+
+/* -------------------------------------------------------------
+ Profile comments
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+.profile_comments {
+ background-color: #fafafa;
+ border: solid 1px #dedede;
+}
+
+.profile_comments_info {
+ font-style: italic;
+}
+
+.profile_comments_text {
+ font-size: 1.25em;
+}
+
+/* -------------------------------------------------------------
+ Profile editor
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+.photos {
+}
+
+.photo img {
+ margin: 8px 0px 12px 20px;
+ border: 0;
+}
+
+.photo {
+ float: left;
+}
+
+/* -------------------------------------------------------------
+ Profile sidebar
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+#sidebar {
+ color: white;
+}
diff --git a/includes/cache/cache.php b/includes/cache/cache.php
new file mode 100644
--- /dev/null
+++ b/includes/cache/cache.php
@@ -0,0 +1,46 @@
+<?php
+
+/*
+ * Zed
+ * (c) 2010, Dereckson, some rights reserved
+ * Released under BSD license
+ *
+ * Cache calling class.
+ *
+ * 0.1 2010-07-06 22:45 Initial version [DcK]
+ *
+ */
+
+class Cache {
+ /*
+ * Gets the cache instance, initializing it if needed
+ * @eturn Cache the cache instance, or null if nothing is cached
+ */
+ static function load () {
+ global $Config;
+ if (
+ !array_key_exists('cache', $Config) ||
+ !array_key_exists('engine', $Config['cache'])
+ ) {
+ //cache is not configured or engine is not specified
+ return null;
+ }
+
+ $engine = $Config['cache']['engine'];
+ $engine_file = 'includes/cache/' . $engine . '.php';
+ $engine_class = 'Cache' . ucfirst($engine);
+
+ if (!file_exists($engine_file)) {
+ message_die(GENERAL_ERROR, "Can't initialize $engine cache engine.<br />$engine_file not found.", 'Cache');
+ }
+
+ require_once($engine_file);
+ if (!class_exists($engine_class)) {
+ message_die(GENERAL_ERROR, "Can't initialize $engine cache engine.<br />$engine_class class not found.", 'Cache');
+ }
+
+ return call_user_func(array($engine_class, 'load'));
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/includes/cache/memcached.php b/includes/cache/memcached.php
new file mode 100644
--- /dev/null
+++ b/includes/cache/memcached.php
@@ -0,0 +1,83 @@
+<?php
+/*
+ * Zed
+ * (c) 2010, Dereckson, some rights reserved
+ * Released under BSD license
+ *
+ * Cache class: memcached
+ *
+ * 0.1 2010-07-06 22:55 Initial version [DcK]
+ *
+ * !!! This class uses the Memcached extension AND NOT the Memcache ext !!!!
+ *
+ * References:
+ * - http://www.php.net/manual/en/book/memcached.php
+ * - http://memcached.org
+ *
+ * This class implements a singleton pattern.
+ *
+ */
+
+class CacheMemcached {
+
+ /*
+ * @var CacheMemcached the current cache instance
+ */
+ static $instance = null;
+
+ /*
+ * @var Memcached the Memcached object
+ */
+ private $memcached = null;
+
+ /*
+ * Gets the cache instance, initializing it if needed
+ * @eturn Cache the cache instance, or null if nothing is cached
+ */
+ static function load () {
+ //Checks extension is okay
+ if (!extension_loaded('memcached')) {
+ if (extension_loaded('memcache')) {
+ message_die(GENERAL_ERROR, "Can't initialize $engine cache engine.<br />PHP extension memcached not loaded.<br /><strong>!!! This class uses the Memcached extension AND NOT the Memcache extension (this one is loaded) !!!</strong>", 'Cache');
+ } else {
+ message_die(GENERAL_ERROR, "Can't initialize $engine cache engine.<br />PHP extension memcached not loaded.", 'Cache');
+ }
+ }
+
+ //Creates the Memcached object if needed
+ if (self::$instance === null) {
+ global $Config;
+
+ self::$instance = new CacheMemcached();
+ self::$instance->memcached = new Memcached();
+ self::$instance->memcached->addServer(
+ $Config['cache']['server'],
+ $Config['cache']['port']
+ );
+ }
+
+ return self::$instance;
+ }
+
+ /*
+ * Gets the specified key's data
+ */
+ function get ($key) {
+ return $this->memcached->get($key);
+ }
+
+ /*
+ * Sets the specified data at the specified key
+ */
+ function set ($key, $value) {
+ return $this->memcached->set($key, $value);
+ }
+
+ /*
+ * Deletes the specified key's data
+ */
+ function delete ($key) {
+ return $this->memcached->delete($key);
+ }
+}
+?>
\ 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,182 +1,193 @@
<?php
/*
* Zed
* (c) 2010, Dereckson, some rights reserved
* Released under BSD license
*
* Autogenerable configuration file
*/
////////////////////////////////////////////////////////////////////////////////
/// ///
/// 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'] = 'Je balaye les petits ewoks comme le vent balaye les feuilles mortes';
//When reading files, buffer size
define('BUFFER_SIZE', 4096);
////////////////////////////////////////////////////////////////////////////////
/// ///
/// III. Script URLs ///
/// ///
////////////////////////////////////////////////////////////////////////////////
/*
* 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';
*
* 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]
*
*
* 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.
//To use
//
//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 ///
/// ///
////////////////////////////////////////////////////////////////////////////////
-//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 ///
+/// ///
+////////////////////////////////////////////////////////////////////////////////
+
+
+$Config['cache']['engine'] = 'memcached';
+$Config['cache']['server'] = 'localhost';
+$Config['cache']['port'] = 11211;
+
?>
\ No newline at end of file
diff --git a/includes/objects/profile.php b/includes/objects/profile.php
--- a/includes/objects/profile.php
+++ b/includes/objects/profile.php
@@ -1,91 +1,110 @@
<?php
/*
* Zed
* (c) 2010, Dereckson, some rights reserved
* Released under BSD license
*
* Profile class.
*
* 0.1 2010-01-02 16:49 Autogenerated by Pluton Scaffolding
* Import from Azhàr
* 0.2 2010-07-05 03:56 Tags
*
*/
class Profile {
public $perso_id;
public $text;
public $updated;
public $fixedwidth;
function __construct ($perso_id) {
$this->perso_id = $perso_id;
$this->load_from_database();
}
//Loads the object Profile (ie fill the properties) from the $_POST array
function load_from_form ($read_boolean = true) {
if (array_key_exists('perso_id', $_POST)) $this->perso_id = $_POST['perso_id'];
if (array_key_exists('text', $_POST)) $this->text = $_POST['text'];
if (array_key_exists('updated', $_POST)) $this->updated = $_POST['updated'];
if ($read_boolean) {
if (array_key_exists('fixedwidth', $_POST)) $this->fixedwidth = $_POST['fixedwidth'];
}
}
//Loads the object Profile (ie fill the properties) from the database
function load_from_database () {
global $db;
$id = $db->sql_escape($this->perso_id);
$sql = "SELECT * FROM " . TABLE_PROFILES . " WHERE perso_id = '$id'";
if ( !($result = $db->sql_query($sql)) ) message_die(SQL_ERROR, "Unable to query azhar_profiles", '', __LINE__, __FILE__, $sql);
if (!$row = $db->sql_fetchrow($result)) {
$this->lastError = "Profile unkwown: " . $this->perso_id;
return false;
}
$this->text = $row['profile_text'];
$this->updated = $row['profile_updated'];
$this->fixedwidth = $row['profile_fixedwidth'];
return true;
}
//Saves the object to the database
function save_to_database () {
global $db;
$perso_id = $db->sql_escape($this->perso_id);
$text = $db->sql_escape($this->text);
$updated = $db->sql_escape($this->updated);
$fixedwidth = $this->fixedwidth ? 1 : 0;
$sql = "REPLACE INTO " . TABLE_PROFILES . " (`perso_id`, `profile_text`, `profile_updated`, `profile_fixedwidth`) VALUES ('$perso_id', '$text', '$updated', '$fixedwidth')";
if (!$db->sql_query($sql)) {
message_die(SQL_ERROR, "Unable to save", '', __LINE__, __FILE__, $sql);
}
}
///
/// Tags
///
- function get_tags ($class) {
+ function get_tags () {
global $db;
$id = $db->sql_escape($this->perso_id);
- $sql = "SELECT tag_code, tag_class FROM" . TABLE_PROFILES_TAGS
+ $sql = "SELECT tag_code, tag_class FROM " . TABLE_PROFILES_TAGS
. " WHERE perso_id = '$id'";
- if (!$db->sql_query($sql)) {
+ if (!$result = $db->sql_query($sql)) {
message_die(SQL_ERROR, "Can't get tags", '', __LINE__, __FILE__, $sql);
}
$tags = array();
- while (!$row = $db->sql_fetchrow($result)) {
+ while ($row = $db->sql_fetchrow($result)) {
$tags[$row['tag_class']][] = $row['tag_code'];
}
return $tags;
}
+
+ function get_cached_tags () {
+ require_once('includes/cache/cache.php');
+ $cache = Cache::load();
+ $key = 'zed_profile_tags_' . $this->perso_id;
+ if (!$tags_html = $cache->get($key)) {
+ //Regenerates tags cached html snippet
+ global $smarty;
+ $tags = $this->get_tags();
+ if (count($tags)) {
+ $smarty->assign('tags', $tags);
+ $tags_html = $smarty->fetch('profile_tags.tpl');
+ } else {
+ $tags_html = " ";
+ }
+ $cache->set($key, $tags_html);
+ }
+ return $tags_html;
+ }
}
?>
\ No newline at end of file
diff --git a/skins/zed/profile.tpl b/skins/zed/profile.tpl
--- a/skins/zed/profile.tpl
+++ b/skins/zed/profile.tpl
@@ -1,76 +1,80 @@
<!-- Profile -->
<div class="clear">&nbsp;</div>
<div class="grid_11 alpha">
<!-- Profile header -->
<div class="profile_id clearfix">
<h1 class="profile_nick">{$perso->name}</h1>
<div class="profile_info">
{$perso->location}&nbsp;<br />
{if $perso->is_online()}{#Online#}{/if}
</div>
</div>
<div class="clear">&nbsp;</div>
<div class="profile">
{if $PICS}
<!-- Photos -->
<div class="profile_photos">
{foreach from=$PICS item=photo}
<a rel="lightbox" href="{$URL_PICS}/{$photo->name}" title="{$photo->description}"><img src="{$URL_PICS}/tn/{$photo->name}" alt="{$photo->description}" /></a>
{/foreach}
</div>
{/if}
<!-- Text -->
<div class="profile_text{if $PROFILE_FIXEDWIDTH} fixedwidth{/if}">{if $PROFILE_TEXT != ""}{if $PROFILE_FIXEDWIDTH}{$PROFILE_TEXT}{else}{$PROFILE_TEXT|nl2br}{/if}{else}{if $PROFILE_SELF}<a href="{get_url('who')}/edit/profile">{/if}<img src="{#StaticContentURL#}/img/zed/empty_profile.png" width="642" height="392" alt="Be creative ! Fill this space with your best words." />{if $PROFILE_SELF}</a>{/if}{/if}</div>
+
+{$PROFILE_TAGS}
+
+ <!-- Leave a message -->
<div class="profile_separator_light"></div>
<div class="profile_message">
<h2 id="Message">{#DropMessage#}</h2>
<form method="post" action="{get_url('who')}/{$perso->nickname}">
<div class="grid_4 alpha">
<input type="radio" name="message_type" value="private_message" checked onclick="document.getElementById('MessageSubmit').value = '{#Send#}';">{sprintf(#SendMessage#, $NAME)}
</div>
<div class="grid_6 omega">
<input type="radio" name="message_type" value="profile_comment" onclick="document.getElementById('MessageSubmit').value = '{#Publish#}';">{sprintf(#AddComment#, $NAME)}
</div>
<p><textarea rows="7" cols="64" name="message"></textarea></p>
<p><input id="MessageSubmit" type="submit" name="MessageSubmit" value="{#Send#}" /></p>
</form>
</div>
</div>
</div>
<!-- User content -->
<div class="grid_5 omega">
<div class="sidebar_border"></div>
<div id="sidebar">
<div class="border_top"></div>
<div class="sidebar_content">
{if $PROFILE_SELF}
<!-- {{counter name=section}|romanize}. edit profile, account, photos -->
<h2>{#EditMyPage#}</h2>
<ul>
<li><a href="{get_url('who','edit','profile')}">{#EditProfile#}</a></li>
<li><a href="{get_url('settings','perso')}">{#EditAccount#}</a></li>
<li><a href="{get_url('who','edit','photos')}">{if $PICS}{#ManagePhotos#}{else}{#AddPhoto#}{/if}</a></li>
</ul>
{/if}
<!-- {{counter name=section}|romanize}. sidebar placeholder/explanation -->
<h2>Sidebar</h2>
<p>Here will be published new art submission, request/offers post it, external content imported, etc.</p>
</div>
<div class="border_bottom"></div>
</div>
</div>
{if $PROFILE_COMMENTS}
<!-- Profile comments -->
<div class="grid_16 alpha omega profile_comments" id="comments" style="margin-bottom: 1em;">
{foreach from=$PROFILE_COMMENTS item=comment}
<div class="comment black">
<div class="profile_comments_text"><p>{$comment->text|nl2br}</p></div>
<div class="profile_comments_info">-- <a href="{get_url('who')}/{$comment->author}">{$comment->authorname}</a>, {get_hypership_time($comment->date)}</div>
</div>
{/foreach}
</div>
{/if}
diff --git a/skins/zed/profile_tags.tpl b/skins/zed/profile_tags.tpl
new file mode 100644
--- /dev/null
+++ b/skins/zed/profile_tags.tpl
@@ -0,0 +1,10 @@
+ <!-- Tags -->
+ <div class="profile_separator_light"></div>
+ <div class="profile_tags">
+ <dl>
+{foreach from=$tags key=class item=tags_class}
+ <dt>{$class}</dt>
+ <dd>{foreach from=$tags_class item=tag name=tags}<nobr>{$tag}</nobr>{if !$smarty.foreach.tags.last}, {/if}{/foreach}</dd>
+{/foreach}
+ </dl>
+ </div>
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 25, 04:30 (2 h, 23 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21087
Default Alt Text
(36 KB)

Event Timeline