diff --git a/dev/schema-mysql.sql b/dev/schema-mysql.sql index deb5d1a..4071632 100644 --- a/dev/schema-mysql.sql +++ b/dev/schema-mysql.sql @@ -1,625 +1,625 @@ -- phpMyAdmin SQL Dump -- version 3.3.3 -- http://www.phpmyadmin.net -- -- Serveur: localhost -- Généré le : Sam 17 Juillet 2010 à 19:37 -- Version du serveur: 5.5.4 -- Version de PHP: 5.3.2 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Base de données: `zed` -- -- -------------------------------------------------------- -- -- Structure de la table `api_keys` -- CREATE TABLE IF NOT EXISTS `api_keys` ( `key_guid` varchar(36) NOT NULL, `key_active` tinyint(1) unsigned NOT NULL DEFAULT '1', `key_description` tinytext, `key_hits` bigint(20) NOT NULL DEFAULT '0', `key_lastcall` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`key_guid`), KEY `key_active` (`key_active`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Contenu de la table `api_keys` -- -- -------------------------------------------------------- -- -- Doublure de structure pour la vue `content` -- CREATE TABLE IF NOT EXISTS `content` ( `content_id` mediumint(8) unsigned ,`location_global` varchar(9) ,`location_local` varchar(255) ,`location_k` smallint(5) unsigned ,`content_path` varchar(255) ,`user_id` smallint(5) ,`perso_id` smallint(5) ,`content_title` varchar(255) ); -- -------------------------------------------------------- -- -- Structure de la table `content_files` -- CREATE TABLE IF NOT EXISTS `content_files` ( `content_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `content_path` varchar(255) NOT NULL, `user_id` smallint(5) NOT NULL, `perso_id` smallint(5) NOT NULL, `content_title` varchar(255) NOT NULL, PRIMARY KEY (`content_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; -- -- Contenu de la table `content_files` -- -- -------------------------------------------------------- -- -- Structure de la table `content_locations` -- CREATE TABLE IF NOT EXISTS `content_locations` ( `location_global` varchar(9) NOT NULL, `location_local` varchar(255) NOT NULL, `location_k` smallint(5) unsigned NOT NULL, `content_id` mediumint(8) unsigned NOT NULL, PRIMARY KEY (`location_global`,`location_local`,`location_k`), KEY `content_id` (`content_id`), KEY `location_global` (`location_global`,`location_local`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Contenu de la table `content_locations` -- -- -------------------------------------------------------- -- -- Structure de la table `geo_bodies` -- CREATE TABLE IF NOT EXISTS `geo_bodies` ( `body_code` mediumint(5) unsigned zerofill NOT NULL AUTO_INCREMENT, `body_name` varchar(31) NOT NULL, `body_status` set('hypership','asteroid','moon','planet','star','orbital','hidden') DEFAULT NULL, `body_location` varchar(15) DEFAULT NULL, `body_description` text, PRIMARY KEY (`body_code`), KEY `body_status` (`body_status`), FULLTEXT KEY `text` (`body_name`,`body_description`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; -- -- Contenu de la table `geo_bodies` -- INSERT INTO `geo_bodies` (`body_code`, `body_name`, `body_status`, `body_location`, `body_description`) VALUES (00001, 'Hypership', 'hypership', NULL, NULL), (00002, 'Xen', 'asteroid', NULL, NULL), (00003, 'Kaos', 'asteroid', NULL, NULL); -- -------------------------------------------------------- -- -- Doublure de structure pour la vue `geo_locations` -- CREATE TABLE IF NOT EXISTS `geo_locations` ( `location_code` varchar(9) ,`location_name` varchar(255) ); -- -------------------------------------------------------- -- -- Structure de la table `geo_places` -- CREATE TABLE IF NOT EXISTS `geo_places` ( `place_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `body_code` mediumint(5) unsigned zerofill NOT NULL, `place_code` smallint(3) unsigned zerofill NOT NULL, `place_name` varchar(255) NOT NULL, `place_description` longtext NOT NULL, `location_local_format` varchar(63) DEFAULT NULL, `place_status` set('start','hidden') DEFAULT NULL, PRIMARY KEY (`place_id`), UNIQUE KEY `body_id` (`body_code`,`place_code`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Contenu de la table `geo_places` -- INSERT INTO `geo_places` (`place_id`, `body_code`, `place_code`, `place_name`, `place_description`, `location_local_format`, `place_status`) VALUES (1, 00001, 001, 'Tour', 'Tour circulaire, surplombant l''hypership, offrant une vue circulaire sur l''espace (ou l''ultraespace, ou l''hyperespace) et une rotonde aux derniers étages.\r\n\r\n== Toponymie numérique ==\r\nChaque niveau (correspondant à un secteur, identifié par la lettre T suivi du niveau, en partant du haut) est divisé en 6 couloirs d''approximativement 60°.', '/^(T[1-9][0-9]*C[1-6])$/', NULL), (2, 00001, 002, 'Core', 'Le coeur de l''hypership, son centre de gravité et les 8 cubes l''entourant.\r\n\r\n== Toponymie numérique ==\r\nLe core est divisé en 9 secteurs : C0 pour le centre de gravité, C1 à C4 pour les cubes de la couche inférieure, C5 à C8 pour les cubes de la couche supérieure.', NULL, NULL), (3, 00002, 001, 'Algir', '', NULL, NULL), (4, 00003, 001, 'Zeta', '', NULL, 'start'), (5, 00001, 003, 'Bays', 'Baies permettant d''accueillir divers vaisseaux au sein de l''hypership.', NULL, NULL); -- -------------------------------------------------------- -- -- Structure de la table `log_smartline` -- CREATE TABLE IF NOT EXISTS `log_smartline` ( `command_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `perso_id` smallint(5) unsigned DEFAULT NULL, `command_time` int(10) DEFAULT NULL, `command_text` varchar(255) DEFAULT NULL, `isError` tinyint(1) DEFAULT '0', PRIMARY KEY (`command_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -- Contenu de la table `log_smartline` -- -- -------------------------------------------------------- -- -- Structure de la table `messages` -- CREATE TABLE IF NOT EXISTS `messages` ( `message_id` mediumint(9) NOT NULL AUTO_INCREMENT, `message_date` int(11) NOT NULL DEFAULT '0', `message_from` varchar(4) NOT NULL DEFAULT '0', `message_to` varchar(4) NOT NULL DEFAULT '0', `message_text` longtext NOT NULL, `message_flag` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`message_id`), KEY `message_to` (`message_to`), KEY `message_flag` (`message_flag`), KEY `message_date` (`message_date`), KEY `inbox` (`message_to`,`message_flag`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -- Contenu de la table `messages` -- -- -------------------------------------------------------- -- -- Structure de la table `motd` -- CREATE TABLE IF NOT EXISTS `motd` ( `motd_id` int(11) NOT NULL AUTO_INCREMENT, `perso_id` int(11) NOT NULL, `motd_text` varchar(255) NOT NULL, `motd_date` int(10) NOT NULL, PRIMARY KEY (`motd_id`), KEY `perso_id` (`perso_id`), KEY `motd_date` (`motd_date`), FULLTEXT KEY `motd_text` (`motd_text`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=25 ; -- -- Contenu de la table `motd` -- INSERT INTO `motd` (`motd_id`, `perso_id`, `motd_text`, `motd_date`) VALUES (24, 4960, 'You''re on the *DEVELOPMENT AND TESTING server (database zed, using the repo hg)*', 1279161701); -- -------------------------------------------------------- -- -- Structure de la table `pages` -- CREATE TABLE IF NOT EXISTS `pages` ( `page_id` int(11) NOT NULL AUTO_INCREMENT, `page_code` varchar(31) NOT NULL, `page_title` varchar(255) NOT NULL, `page_content` longtext NOT NULL, PRIMARY KEY (`page_id`), UNIQUE KEY `page_code` (`page_code`), FULLTEXT KEY `page_text` (`page_code`,`page_title`,`page_content`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; -- -- Contenu de la table `pages` -- INSERT INTO `pages` (`page_id`, `page_code`, `page_title`, `page_content`) VALUES (3, 'ArtworkCredits', 'Artwork credits', '

Login screen

\r\n

Wires and blocks use following tutorials:

\r\n\r\n

Hypership

\r\n

Gallery tower

\r\n

Technical schemas Dereckson. In the future, some could contain technical shapes Photoshop brushes, by scully7491.

\r\n

Portholes structure (c) Richard Carpenter, Six Revisions.
\r\nA tutorial is available here.

\r\n

When the hypership is in hyperspace mode, portholes prints a colored background by ilco.
\r\nWhen reaching a system, it prints a scene excerpt.

\r\n

Core cancelled sector

\r\n

Photographies: Jérôme
\r\nEditing: Dereckson

\r\n

Scenes

\r\n

Xen and Kaos

\r\n

Scene composed from 2 wallpapers from Interfacelift, n° 587 and 781.

\r\n

Future sources

\r\n

Fasticon

\r\n

It''s possible in the future some http://www.fasticon.com/ icons are added.

\r\n

Comic Tiger

\r\n

(c) Dirceu Veiga - FastIcon Studio.
\r\nLicense: All Icons on the Fast Icon "Download" page are are FREEWARE, but to use our Icons in your software, web site, in a theme or other project, you need our permission first. You don''t need permission for personal use our Icons on your computer.

'); -- -------------------------------------------------------- -- -- Structure de la table `pages_edits` -- CREATE TABLE IF NOT EXISTS `pages_edits` ( `page_edit_id` int(11) NOT NULL AUTO_INCREMENT, `page_code` varchar(255) DEFAULT NULL, `page_version` smallint(6) NOT NULL DEFAULT '0', `page_title` varchar(255) NOT NULL DEFAULT '', `page_content` longtext, `page_edit_reason` varchar(255) DEFAULT NULL, `page_edit_user_id` smallint(4) unsigned DEFAULT NULL, `page_edit_time` int(10) DEFAULT NULL, PRIMARY KEY (`page_edit_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; -- -- Contenu de la table `pages_edits` -- -- -------------------------------------------------------- -- -- Structure de la table `persos` -- CREATE TABLE IF NOT EXISTS `persos` ( `user_id` smallint(4) DEFAULT NULL, `perso_id` smallint(4) NOT NULL DEFAULT '0', `perso_name` varchar(255) NOT NULL DEFAULT '', `perso_nickname` varchar(31) NOT NULL DEFAULT '', `perso_race` varchar(31) NOT NULL DEFAULT '', `perso_sex` enum('M','F','N','2') NOT NULL DEFAULT 'M', `perso_avatar` varchar(255) DEFAULT NULL, `location_global` varchar(9) DEFAULT 'B00001001', `location_local` varchar(255) DEFAULT NULL, PRIMARY KEY (`perso_id`), UNIQUE KEY `nickname` (`perso_nickname`), KEY `race` (`perso_race`), KEY `user_id` (`user_id`), KEY `location_global` (`location_global`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Contenu de la table `persos` -- INSERT INTO `persos` (`user_id`, `perso_id`, `perso_name`, `perso_nickname`, `perso_race`, `perso_sex`, `perso_avatar`, `location_global`, `location_local`) VALUES (2600, 4960, 'Lorem Ipsum', 'demo', 'humanoid', 'M', '', 'B00003001', '1'); -- -------------------------------------------------------- -- -- Structure de la table `persos_flags` -- CREATE TABLE IF NOT EXISTS `persos_flags` ( `flag_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `perso_id` smallint(6) NOT NULL DEFAULT '0', `flag_key` varchar(255) NOT NULL, `flag_value` varchar(512) NOT NULL, PRIMARY KEY (`flag_id`), UNIQUE KEY `persoflag` (`perso_id`,`flag_key`), KEY `perso_id` (`perso_id`), KEY `flag_key` (`flag_key`), KEY `flag` (`flag_key`(127),`flag_value`(199)) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=459 ; -- -------------------------------------------------------- -- -- Structure de la table `persos_notes` -- CREATE TABLE IF NOT EXISTS `persos_notes` ( `perso_id` smallint(4) NOT NULL, `note_code` varchar(63) NOT NULL, `note_text` longtext NOT NULL, PRIMARY KEY (`perso_id`,`note_code`), KEY `perso_id` (`perso_id`), KEY `note_code` (`note_code`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Contenu de la table `persos_notes` -- -- -------------------------------------------------------- -- -- Structure de la table `ports` -- CREATE TABLE IF NOT EXISTS `ports` ( `port_id` smallint(6) NOT NULL AUTO_INCREMENT, `location_global` char(9) NOT NULL, `location_local` varchar(255) NOT NULL, `port_name` varchar(63) NOT NULL, `port_status` set('hidden','requiresPTA') NOT NULL, PRIMARY KEY (`port_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Contenu de la table `ports` -- INSERT INTO `ports` (`port_id`, `location_global`, `location_local`, `port_name`, `port_status`) VALUES (1, 'B00003001', '3', 'Le Dôme de Thétys', ''), (2, 'B00001003', '', 'Hypership''s general bays', ''); -- -------------------------------------------------------- -- -- Structure de la table `profiles` -- CREATE TABLE IF NOT EXISTS `profiles` ( `perso_id` int(11) NOT NULL, `profile_text` longtext NOT NULL, `profile_updated` int(10) NOT NULL, `profile_fixedwidth` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`perso_id`), KEY `profile_fixedwidth` (`profile_fixedwidth`), KEY `profile_updated` (`profile_updated`), FULLTEXT KEY `profile` (`profile_text`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Contenu de la table `profiles` -- -- -------------------------------------------------------- -- -- Structure de la table `profiles_comments` -- CREATE TABLE IF NOT EXISTS `profiles_comments` ( `comment_id` mediumint(9) NOT NULL AUTO_INCREMENT, `perso_id` smallint(5) unsigned NOT NULL, `comment_author` smallint(5) unsigned NOT NULL, `comment_date` int(10) NOT NULL, `comment_text` text NOT NULL, PRIMARY KEY (`comment_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; -- -- Contenu de la table `profiles_comments` -- -- -------------------------------------------------------- -- -- Structure de la table `profiles_photos` -- CREATE TABLE IF NOT EXISTS `profiles_photos` ( `photo_id` int(11) NOT NULL AUTO_INCREMENT, `perso_id` smallint(6) NOT NULL, `photo_name` varchar(63) NOT NULL, `photo_description` varchar(63) NOT NULL, `photo_avatar` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`photo_id`), UNIQUE KEY `photo_name` (`photo_name`), KEY `user_id` (`perso_id`), KEY `photo_avatar` (`photo_avatar`), KEY `user_avatar` (`perso_id`,`photo_avatar`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -- Contenu de la table `profiles_photos` -- -- -------------------------------------------------------- -- -- Structure de la table `profiles_tags` -- CREATE TABLE IF NOT EXISTS `profiles_tags` ( `perso_id` int(11) NOT NULL, `tag_code` varchar(31) NOT NULL, `tag_class` varchar(15) NOT NULL DEFAULT 'music', PRIMARY KEY (`perso_id`,`tag_code`), KEY `tag_code` (`tag_code`), KEY `tag_class` (`tag_class`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Contenu de la table `profiles_tags` -- -- -------------------------------------------------------- -- -- Structure de la table `registry` -- CREATE TABLE IF NOT EXISTS `registry` ( `registry_key` varchar(63) NOT NULL, `registry_value` longtext NOT NULL, `registry_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`registry_key`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Contenu de la table `registry` -- INSERT INTO `registry` (`registry_key`, `registry_value`, `registry_updated`) VALUES ('api.ship.session.S00001.Demios0001', '1148', '2010-07-04 15:18:04'); -- -------------------------------------------------------- -- -- Structure de la table `sessions` -- CREATE TABLE IF NOT EXISTS `sessions` ( `session_id` varchar(32) NOT NULL DEFAULT '', `Where` tinyint(4) NOT NULL DEFAULT '1', - `IP` varchar(8) NOT NULL DEFAULT '', + `IP` varchar(45) NOT NULL DEFAULT '', `user_id` smallint(5) NOT NULL DEFAULT '-1', `perso_id` smallint(6) DEFAULT NULL, `Skin` varchar(31) NOT NULL DEFAULT 'zed', `Skin_accent` varchar(31) NOT NULL DEFAULT '', `online` tinyint(4) NOT NULL DEFAULT '1', `HeureLimite` varchar(15) NOT NULL DEFAULT '', `SessionLimite` varchar(15) NOT NULL DEFAULT '', PRIMARY KEY (`session_id`), KEY `Where` (`Where`), KEY `HeureLimite` (`HeureLimite`) ) ENGINE=MEMORY DEFAULT CHARSET=latin1 COMMENT='Sessions @ Pluton'; -- -------------------------------------------------------- -- -- Structure de la table `ships` -- CREATE TABLE IF NOT EXISTS `ships` ( `ship_id` mediumint(5) unsigned zerofill NOT NULL AUTO_INCREMENT, `ship_name` varchar(63) NOT NULL, `location_global` char(9) DEFAULT NULL, `location_local` varchar(255) NOT NULL, `api_key` varchar(36) NOT NULL, `ship_description` text NOT NULL, PRIMARY KEY (`ship_id`), UNIQUE KEY `ship_name` (`ship_name`), KEY `location` (`location_global`), KEY `api_key` (`api_key`), FULLTEXT KEY `ship_name_2` (`ship_name`,`ship_description`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Doublure de structure pour la vue `ships_sessions` -- CREATE TABLE IF NOT EXISTS `ships_sessions` ( `ship_id` varchar(5) ,`session_id` varchar(165) ,`perso_id` longtext ,`session_updated` bigint(10) ); -- -------------------------------------------------------- -- -- Structure de la table `users` -- CREATE TABLE IF NOT EXISTS `users` ( `user_id` smallint(4) NOT NULL DEFAULT '0', `username` varchar(11) NOT NULL DEFAULT '', `user_password` varchar(32) NOT NULL DEFAULT '', `user_active` tinyint(1) NOT NULL DEFAULT '0', `user_actkey` varchar(11) DEFAULT NULL, `user_email` varchar(63) NOT NULL DEFAULT '', `user_regdate` int(10) NOT NULL DEFAULT '0', PRIMARY KEY (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Contenu de la table `users` -- -- Adds a default account with demo/demo as login/password -- INSERT INTO `users` (`user_id`, `username`, `user_password`, `user_active`, `user_actkey`, `user_email`, `user_regdate`) VALUES (2600, 'demo', 'fe01ce2a7fbac8fafaed7c982a04e229', 1, NULL, 'lorem@ipsum.dol', 1279161321); -- -------------------------------------------------------- -- -- Structure de la table `users_invites` -- CREATE TABLE IF NOT EXISTS `users_invites` ( `invite_code` char(6) NOT NULL, `invite_date` int(10) NOT NULL, `invite_from_user_id` smallint(5) NOT NULL, `invite_from_perso_id` smallint(5) NOT NULL, `invite_to_user_id` smallint(5) DEFAULT NULL, PRIMARY KEY (`invite_code`), KEY `invite_to_user_id` (`invite_to_user_id`), KEY `invite_from_user_id` (`invite_from_user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Contenu de la table `users_invites` -- -- -------------------------------------------------------- -- -- Structure de la table `users_openid` -- CREATE TABLE IF NOT EXISTS `users_openid` ( `openid_id` mediumint(9) NOT NULL AUTO_INCREMENT, `openid_url` varchar(255) NOT NULL, `user_id` mediumint(9) NOT NULL, PRIMARY KEY (`openid_id`), UNIQUE KEY `openid_url` (`openid_url`), KEY `user_id` (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; -- -- Contenu de la table `users_openid` -- -- -------------------------------------------------------- -- -- Structure de la vue `content` -- DROP TABLE IF EXISTS `content`; CREATE VIEW `content` AS select `cl`.`content_id` AS `content_id`,`cl`.`location_global` AS `location_global`,`cl`.`location_local` AS `location_local`,`cl`.`location_k` AS `location_k`,`cf`.`content_path` AS `content_path`,`cf`.`user_id` AS `user_id`,`cf`.`perso_id` AS `perso_id`,`cf`.`content_title` AS `content_title` from (`content_locations` `cl` join `content_files` `cf`) where (`cf`.`content_id` = `cl`.`content_id`); -- -------------------------------------------------------- -- -- Structure de la vue `geo_locations` -- DROP TABLE IF EXISTS `geo_locations`; CREATE VIEW `geo_locations` AS select concat(_utf8'B',convert(`geo_bodies`.`body_code` using utf8)) AS `location_code`,`geo_bodies`.`body_name` AS `location_name` from `geo_bodies` union select concat(_utf8'B',convert(`geo_places`.`body_code` using utf8),convert(`geo_places`.`place_code` using utf8)) AS `code`,`geo_places`.`place_name` AS `NAME` from `geo_places` union select concat(_utf8'S',convert(`ships`.`ship_id` using utf8)) AS `location_code`,`ships`.`ship_name` AS `location_name` from `ships`; -- -------------------------------------------------------- -- -- Structure de la vue `ships_sessions` -- DROP TABLE IF EXISTS `ships_sessions`; CREATE VIEW `ships_sessions` AS select substr(`registry`.`registry_key`,19,5) AS `ship_id`,substr(`registry`.`registry_key`,25) AS `session_id`,`registry`.`registry_value` AS `perso_id`,unix_timestamp(`registry`.`registry_updated`) AS `session_updated` from `registry` where (left(`registry`.`registry_key`,17) = _utf8'api.ship.session.'); -- -------------------------------------------------------- -- -- Structure de la vue `geo_coordinates` -- CREATE VIEW geo_coordinates AS (SELECT body_name as object_name, body_status as object_type, body_location as object_location FROM geo_bodies) UNION (SELECT ship_name as object_name, 'ship' as object_type, location_global as object_location FROM ships WHERE LEFT(location_global, 3) = 'xyz') ORDER BY object_name \ No newline at end of file diff --git a/do.php b/do.php index ff034a1..e440aac 100644 --- a/do.php +++ b/do.php @@ -1,471 +1,471 @@ * @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 */ //////////////////////////////////////////////////////////////////////////////// /// /// Constants /// //We define one negative number constant by standard erroneous return value. /** * Magic number which indicates the user is not logged in. */ define('USER_NOT_LOGGED', -9); /** * Magic number which indicates the user is logged in, but haven't selected its perso. */ define('PERSO_NOT_SELECTED', -7); //////////////////////////////////////////////////////////////////////////////// /// /// Initialization /// include('includes/core.php'); //Session -$IP = encode_ip($_SERVER["REMOTE_ADDR"]); +$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 //Gets current perso require_once('includes/objects/perso.php'); $CurrentUser = get_logged_user(); //Gets current user infos if ($perso_id = $CurrentUser->session['perso_id']) { $CurrentPerso = new Perso($perso_id); } //Requires user and perso if ($CurrentUser->id < 1000) { echo USER_NOT_LOGGED; exit; } if (!$CurrentPerso) { echo PERSO_NOT_SELECTED; exit; } //Loads Smarty (as it handles l10n, it will be used by lang_get) require('includes/Smarty/Smarty.class.php'); $smarty = new Smarty(); $current_dir = dirname(__FILE__); $smarty->template_dir = $current_dir . '/skins/zed'; $smarty->compile_dir = $current_dir . '/cache/compiled'; $smarty->cache_dir = $current_dir . '/cache'; $smarty->config_dir = $current_dir; //Loads language files initialize_lang(); lang_load('core.conf'); //////////////////////////////////////////////////////////////////////////////// /// /// Actions definitions /// /** * Actions class * * Each method is called by first part of your URL, other parts are arguments * e.g. /do.php/validate_quux_request/52 = Actions::validate_quux_request(52); * * You can also use $_GET, $_POST or better $_REQUEST. * * Don't print the value but return it, so we can in the future implement custom * formats like api_output(); */ class Actions { /** * Checks the arguments hash and determines whether it is valid. * * @param Array $args the arguments, the last being the hash * @return boolean true if the hash is valid ; otherwise, false. */ static private function is_hash_valid ($args) { global $Config; return array_pop($args) == md5($_SESSION['ID'] . $Config['SecretKey'] . implode('', $args)); } /** * Handles a allow/deny perso request. * * @param string $request_flag the request flag to clear * @param string $store 'perso' or 'registry' * @param string $key the perso flag or registry key * @param string $value the value to store * @param string $hash the security hash * @return boolean true if the request is valid and have been processed ; otherwise, false. */ static function perso_request ($request_flag, $store, $key, $value, $hash) { global $CurrentPerso; //Ensures we've the correct amount of arguments if (func_num_args() < 4) { return false; } //Checks hash $args = func_get_args(); if (!self::is_hash_valid($args)) { return false; } //Sets flag switch ($store) { case 'perso': $CurrentPerso->set_flag($key, $value); break; case 'registry': registry_set($key, $value); break; default: //Unknown storage location return false; } //Clears request flag if ((string)$request_flag !== "0") { $CurrentPerso->delete_flag($request_flag); } return true; } /** * Sets current perso's local location. * * We don't require a security hash. If the users want to play with it, no problem. * You generally move inside a global location as you wish. * So, if you write a story capturing a perso, use flags to handle this escape! * * @param string $location_local the local location * @return GeoLocation the current perso's GeoLocation object */ static function set_local_location ($location_local) { global $CurrentPerso; //Ensures we've the correct amount of arguments if (func_num_args() < 1) { return null; } //Moves current perso to specified location $location_local = urldecode($location_local); $CurrentPerso->move_to(null, $location_local); //Returns GeoLocation relevant instance return $CurrentPerso->location; } /** * Moves the current perso's, setting a new local location. * * We don't require a security hash. If the users want to play with it, no problem. * You generally move inside a global location as you wish. * So, if you write a story capturing a perso, use flags to handle this escape! * * @param string $move the move (coordinates or direction) * @param int $factor a number multiplying the specified move [optional] * @return GeoLocation the current perso's GeoLocation object * * e.g. to move from 2 units to east, you can use one of those instructions: * local_move('east', 2); * local_move('2,0,0'); * local_move('1,0,0', 2); * * Valid moves string are north, east, south, west, up and down. * Valid moves coordinates are x,y,z (3 integers, comma as separator) */ static function local_move ($move, $factor = 1) { global $CurrentPerso; //Ensures we've the correct amount of arguments if (func_num_args() < 1) { return null; } //Parses $move switch ($move) { case 'north': $move = [0, 1, 0]; break; case 'east': $move = [1, 0, 0]; break; case 'south': $move = [0, -1, 0]; break; case 'west': $move = [-1, 0, 0]; break; case 'up': $move = [0, 0, 1]; break; case 'down': $move = [0, 0, -1]; break; default: $move = split(',', $move, 3); foreach ($move as $coordinate) { if (!is_numeric($coordinate)) { return null; } } } //Moves current perso to specified location if ($location_local = GeoPoint3D::fromString($CurrentPerso->location->local)) { $location_local->translate($move[0] * $factor, $move[1] * $factor, $move[2] * $factor); $CurrentPerso->move_to(null, $location_local->sprintf("(%d, %d, %d)")); //Returns GeoLocation relevant instance return $CurrentPerso->location; } //Old local location weren't a GeoPoint3D return null; } /** * Moves the current perso's, setting a new local location, using polar+z coordinates. * Polar+z coordinates are polar coordinates, plus a cartesian z dimension. * * We don't require a security hash. If the users want to play with it, no problem. * You generally move inside a global location as you wish. * So, if you write a story capturing a perso, use flags to handle this escape! * * @param string $move the move (coordinates or direction) * @param int $factor a number multiplying the specified move [optional] * @return GeoLocation the current perso's GeoLocation object * * Valid moves string are cw, ccw, out, in, up and down. * r: out = +12 in = -12 * °: cw = +20° ccw = -20 * Valid moves coordinates are r,°,z (3 integers, comma as separator) * (the medium value can also be integer + °) * * e.g. to move of two units (the unit is 20°) clockwise: * polarz_local_move('cw', 2); * polarz_local_move('(0, 20°, 0)', 2); * polarz_local_move('(0, 40°, 0)'); * Or if you really want to use radians (PI/9 won't be parsed): * polarz_local_move('(0, 0.6981317007977318, 0)'; * */ static function polarz_local_move ($move, $factor = 1) { global $CurrentPerso; //Ensures we've the correct amount of arguments if (func_num_args() < 1) { return null; } //Parses $move $move = urldecode($move); switch ($move) { case 'cw': $move = [0, '20°', 0]; break; case 'ccw': $move = [0, '-20°', 0]; break; case 'in': $move = [+12, 0, 0]; break; case 'out': $move = [-12, 0, 0]; break; case 'up': $move = [0, 0, 1]; break; case 'down': $move = [0, 0, -1]; break; default: $move = split(',', $move, 3); foreach ($move as $coordinate) { if (!is_numeric($coordinate) && !preg_match("/^[0-9]+ *°$/", $coordinate)) { return null; } } } dieprint_r($move); //Moves current perso to specified location if ($location_local = GeoPoint3D::fromString($CurrentPerso->location->local)) { $location_local->translate($move[0] * $factor, $move[1] * $factor, $move[2] * $factor); $CurrentPerso->move_to(null, $location_local->sprintf("(%d, %d, %d)")); //Returns GeoLocation relevant instance return $CurrentPerso->location; } //Old local location weren't a GeoPoint3D return null; } /** * Moves the current perso's, setting a new global and local location. * * @param string $location_global The global location * @param string $location_local The local location * @return GeoLocation the current perso's GeoLocation object */ static function global_move ($location_global, $location_local = null) { //Ensures we've the correct amount of arguments if (func_num_args() < 1) { return null; } //Checks hash $args = func_get_args(); if (!self::is_hash_valid($args)) { return false; } //Moves global $CurrentPerso; $CurrentPerso->move_to($location_global, $location_local); return $CurrentPerso->location; } /** * Handles upload content form. * * @return string new content path */ static function upload_content () { global $CurrentPerso, $CurrentUser; require_once('includes/objects/content.php'); //Initializes a new content instance $content = new Content(); $content->load_from_form(); $content->user_id = $CurrentUser->id; $content->perso_id = $CurrentPerso->id; $content->location_global = $CurrentPerso->location_global; //Saves file if ($content->handle_uploaded_file($_FILES['artwork'])) { $content->save_to_database(); $content->generate_thumbnail(); return true; } return false; } /** * Gets multimedia content for the specified location * * @param string $location_global The global location (local is to specified in ?location_local parameter) * @return Array an array of Content instances */ static function get_content ($location_global) { //Ensures we've the correct amount of arguments if (func_num_args() < 1) { return null; } //Checks hash $args = func_get_args(); if (!self::is_hash_valid($args)) { return false; } //Checks local location is specified somewhere (usually in $_GET) if (!array_key_exists('location_local', $_REQUEST)) { return false; } //Gets content require_once('includes/objects/content.php'); return Content::get_local_content($location_global, $_REQUEST['location_local']); } } //////////////////////////////////////////////////////////////////////////////// /// /// Handles request /// //Parses URL $Config['SiteURL'] = get_server_url() . $_SERVER["PHP_SELF"]; $args = get_current_url_fragments(); $method = array_shift($args); if ($_REQUEST['debug']) { //Debug version //Most of E_STRICT errors are evaluated at the compile time thus such errors //are not reported ini_set('display_errors', 'stderr'); error_reporting(-1); if (method_exists('Actions', $method)) { $result = call_user_func_array(['Actions', $method], $args); echo json_encode($result); } else { echo "

Method doesn't exist: $method

"; } if (array_key_exists('redirectTo', $_REQUEST)) { //If user JS disabled, you can add ?redirectTo= followed by an URL echo "

Instead to print a callback value, redirects to $_REQUEST[redirectTo]

"; } } else { //Prod version doesn't prints warning <== silence operator if (method_exists('Actions', $method)) { $result = @call_user_func_array(['Actions', $method], $args); if (array_key_exists('redirectTo', $_REQUEST)) { //If user JS disabled, you can add ?redirectTo= followed by an URL header("location: " . $_REQUEST['redirectTo']); } else { echo json_encode($result); } } } diff --git a/includes/sessions.php b/includes/sessions.php index 81a538a..240a088 100755 --- a/includes/sessions.php +++ b/includes/sessions.php @@ -1,170 +1,160 @@ * @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 Replaces this code by the unified Keruald session class. */ -function decode_ip ($int_ip) { - $hexipbang = explode('.', chunk_split($int_ip, 2, '.')); - return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]); -} - -function encode_ip ($dotquad_ip) { - $ip_sep = explode('.', $dotquad_ip); - return sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]); -} - function session_update () { global $db, $IP, $Config; //Nettoyage de la session /* Initialisation */ $time_online = 5 * 60; // Temps après lequel l'utilisateur n'est plus considéré comme online $time_session = 2 * 60 * 60; // Durée de vie de la session $heureActuelle = time(); //Timestamp UNIX et non MySQL /* On fait le ménage */ $sql = "UPDATE " . TABLE_SESSIONS . " SET online=0 WHERE HeureLimite < $heureActuelle"; if (!$db->sql_query($sql)) { message_die(SQL_ERROR, 'Impossible de mettre à jour les sessions (utilisateurs offline)', '', __LINE__, __FILE__, $sql); } $sql = "DELETE FROM " . TABLE_SESSIONS . " WHERE SessionLimite < $heureActuelle"; if (!$db->sql_query($sql)) { message_die(SQL_ERROR, "Impossible d'effacer les sessions expirées", '', __LINE__, __FILE__, $sql); } /* Création / mise à jour de la session utilisateur */ if (!$_SESSION[ID]) { $_SESSION[ID] = md5(generate_random_string("AAAA1234")); } $sql = "SELECT * FROM " . TABLE_SESSIONS . " WHERE session_id LIKE '$_SESSION[ID]'"; if ( !($result = $db->sql_query($sql)) ) { message_die(SQL_ERROR, "Problème critique avec les sessions.", '', __LINE__, __FILE__, $sql); } if ($db->sql_numrows($result) == 0) { $sql = "INSERT INTO " . TABLE_SESSIONS . " (IP, session_id, `Where`, HeureLimite, SessionLimite) VALUES ('$IP', '$_SESSION[ID]', $Config[ResourceID], $heureActuelle + $time_online, $heureActuelle + $time_session)"; if (!$db->sql_query($sql)) { message_die(SQL_ERROR, "Impossible de créer une nouvelle session", '', __LINE__, __FILE__, $sql); } } else { $sql = "UPDATE " . TABLE_SESSIONS . " SET online=1, HeureLimite = $heureActuelle + $time_online, SessionLimite= $heureActuelle + $time_session WHERE session_id = '$_SESSION[ID]'"; if (!$db->sql_query($sql)) { message_die(SQL_ERROR, "Impossible de mettre à jour la session", '', __LINE__, __FILE__, $sql); } } } function nbc () { //Renvoi du nombre d'usagers connectés global $db, $Config; $sql = "SELECT count(*) FROM " . TABLE_SESSIONS . " WHERE online=1 AND `Where` = $Config[ResourceID]"; if ( !($result = $db->sql_query($sql)) ) { message_die(SQL_ERROR, "Impossible d'obtenir le nombre d'utilisateurs connectés sur le site web", '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); return $row[0]; } function get_info ($info) { //Renvoie une variable de la session global $db; $sql = "SELECT $info FROM " . TABLE_SESSIONS . " WHERE session_id LIKE '$_SESSION[ID]'"; if ( !($result = $db->sql_query($sql)) ) { message_die(SQL_ERROR, "Impossible d'obtenir $info", '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); return $row[$info]; } function get_logged_user () { //Renvoie toutes les informations d'un utilisateur global $db; $sql = "SELECT * FROM " . TABLE_SESSIONS . " WHERE session_id LIKE '$_SESSION[ID]'"; if ( !($result = $db->sql_query($sql)) ) { message_die(SQL_ERROR, "Impossible d'obtenir les informations de l'utilisateur", '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); require_once('includes/objects/user.php'); $user = User::get($row['user_id']); $user->session = $row; return $user; } function set_info ($info, $value) { //Définit une variable session global $db; $value = ($value === null) ? 'NULL' : "'" . $db->sql_escape($value) . "'"; $sql = "UPDATE " . TABLE_SESSIONS . " SET $info = $value WHERE session_id LIKE '$_SESSION[ID]'"; if (!$db->sql_query($sql)) { message_die(SQL_ERROR, "Impossible de définir $info", '', __LINE__, __FILE__, $sql); } } /** * Destroys $_SESSION array values, help ID */ function clean_session () { foreach ($_SESSION as $key => $value) { if ($key != 'ID') { unset($_SESSION[$key]); } } } /** * Logs in user */ function login ($user_id, $username) { global $db; $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); } //We send a cookie to print automatically the last username on the login //page during 30 days. if (username) { setcookie("LastUsername", $username, time() + 2592000); } } /** * Logs out user */ function logout () { //Anonymous user in session table global $db; $sql = "UPDATE " . TABLE_SESSIONS . " SET user_id = '-1', perso_id = NULL WHERE session_id LIKE '$_SESSION[ID]'"; if (!$db->sql_query($sql)) { message_die(SQL_ERROR, "Impossible de procéder à la déconnexion", '', __LINE__, __FILE__, $sql); } clean_session(); } diff --git a/index.php b/index.php index e22cc27..2eb8f4b 100644 --- a/index.php +++ b/index.php @@ -1,201 +1,201 @@ * @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 (formerly Pluton) library include('includes/core.php'); //Session -$IP = encode_ip($_SERVER["REMOTE_ADDR"]); +$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 information //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->setTemplateDir($current_dir . '/skins/' . THEME); $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 (=character) selector /// //Handles form if ($_POST['form'] == 'perso.create') { $perso = null; $errors = []; if (Perso::create_perso_from_form($CurrentUser, $perso, $errors)) { //Notifies and logs in $smarty->assign('NOTIFY', lang_get('NewCharacterCreated')); $CurrentPerso = $perso; set_info('perso_id', $perso->id); $CurrentPerso->set_flag("site.lastlogin", $_SERVER['REQUEST_TIME']); } else { //Prints again perso create form, so the user can fix it $smarty->assign('WAP', join("
", $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 has selected a perso $CurrentPerso = new Perso($_GET['perso_id']); if ($CurrentPerso->user_id != $CurrentUser->id) { //User have made an error in the URL 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 'builder': case 'explore': case 'page': case 'request': case 'settings': case 'ship': 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 prettier 404 page header("Status: 404 Not Found"); dieprint_r($url, 'Unknown URL'); }