Added: new webig system
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
require_once(RYAPI_PATH.'client/config.php');
|
||||
|
||||
// Og (non-ryzom.com) method
|
||||
function ryzom_authenticate_with_serverkey($cid, $name, $authserver, $authkey) {
|
||||
global $_RYZOM_API_CONFIG;
|
||||
$fn = $_RYZOM_API_CONFIG['auth_script'].'?name='.$name.'&cid='.$cid.'&authkey='.$authkey.'&authserver='.$authserver;
|
||||
|
||||
$res = file_get_contents($fn);
|
||||
return $res == '1';
|
||||
}
|
||||
|
||||
// Ig method
|
||||
function ryzom_authenticate_ingame($cid, $name, $authkey) {
|
||||
global $_RYZOM_API_CONFIG;
|
||||
$fn = $_RYZOM_API_CONFIG['auth_script'].'?name='.$name.'&cid='.$cid.'&authkey='.$authkey.'&ig=1';
|
||||
|
||||
$res = file_get_contents($fn);
|
||||
echo $res;
|
||||
return $res == '1';
|
||||
}
|
||||
|
||||
// Session method
|
||||
function ryzom_authenticate_with_session($name, $redirect) {
|
||||
global $_RYZOM_API_CONFIG;
|
||||
$fn = $_RYZOM_API_CONFIG['auth_script'].'?name='.$name;
|
||||
|
||||
$res = file_get_contents($fn);
|
||||
return $res == '1';
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Url where player_auth.php is located
|
||||
define('RYAPI_AUTH_SCRIPT', '');
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function ryzom_user_get_info($cid) {
|
||||
return Array();
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
?>
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
function ryzom_app_authenticate(&$user, $ask_login=true, $welcome_message='') {
|
||||
$name = ryzom_get_param('name');
|
||||
$authserver = ryzom_get_param('authserver');
|
||||
$authkey = ryzom_get_param('authkey');
|
||||
$lang = ryzom_get_param('lang');
|
||||
|
||||
// we have to set the $user['lang'] even for anonymous user or we cannot display the test in the right langage
|
||||
if($lang == '') {
|
||||
$l = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
|
||||
if($l=='fr'||$l=='en'||$l=='de'||$l=='ru'||$l=='es')
|
||||
$lang = $l;
|
||||
else
|
||||
$lang = 'en';
|
||||
}
|
||||
$user['lang'] = $lang;
|
||||
|
||||
if (RYZOM_IG || ryzom_get_param('ig')) {
|
||||
// Ingame
|
||||
$cid = ryzom_get_param('cid');
|
||||
if (!ryzom_authenticate_ingame($cid, $name, $authkey))
|
||||
return false;
|
||||
} else {
|
||||
// Outgame : Use session
|
||||
if (!ryzom_authenticate_with_session($name, $cid, $error_message)) {
|
||||
if ($ask_login) {
|
||||
$c = '';
|
||||
if (!$welcome_message)
|
||||
$welcome_message = '<span style="font-size:11pt; color: #AAAAFF">The application <strong style="color: #99FFFF">'._t(APP_NAME).'</strong> require authentication. Please enter your credentials</span>';
|
||||
|
||||
$c .= '<div style="text-align: center">'.$welcome_message.'</div><br />';
|
||||
|
||||
if ($user['message'])
|
||||
$c .= '<div style="text-align: center"><strong style="color: #FF5555">'._t($user['message']).'</strong></div><br />';
|
||||
$c .= ryzom_render_login_form($name, false);
|
||||
echo ryzom_app_render(_t('app_'.APP_NAME), $c);
|
||||
exit;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($lang)
|
||||
$_SESSION['lang'] = $lang;
|
||||
|
||||
// get user informations
|
||||
$user = ryzom_user_get_info($cid);
|
||||
$user['lang'] = $_SESSION['lang'];
|
||||
|
||||
$user['id'] = ryzom_get_user_id($cid, $user['char_name'], $user['creation_date']);
|
||||
unset($user['last_played_date']);
|
||||
unset($user['creation_date']);
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Url where the api is
|
||||
define('RYAPI_URL', 'http://');
|
||||
if (!defined('RYAPI_PATH'))
|
||||
define('RYAPI_PATH', dirname(__FILE__).'/');
|
||||
// used by "home" link
|
||||
if (!defined('RYAPP_URL'))
|
||||
define('RYAPP_URL', 'http://');
|
||||
|
||||
?>
|
@ -0,0 +1,422 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
define('SQL_DEF_TEXT', 0);
|
||||
define('SQL_DEF_BOOLEAN', 1);
|
||||
define('SQL_DEF_INT', 2);
|
||||
define('SQL_DEF_DATE', 3);
|
||||
|
||||
|
||||
// Wrapper for SQL database interactions
|
||||
class ServerDatabase
|
||||
{
|
||||
var $hostname = '';
|
||||
var $username = '';
|
||||
var $password = '';
|
||||
var $database = '';
|
||||
|
||||
var $_connection = Null;
|
||||
|
||||
function ServerDatabase($host='', $user='', $passwd='', $dbname='')
|
||||
{
|
||||
if (($host != '') && ($user != '') && ($dbname != ''))
|
||||
{
|
||||
$this->hostname = $host;
|
||||
$this->username = $user;
|
||||
$this->password = $passwd;
|
||||
$this->database = $dbname;
|
||||
}
|
||||
|
||||
if (($this->hostname != '') && ($this->username != '') && ($this->database != ''))
|
||||
{
|
||||
$this->_connection = mysql_connect($this->hostname, $this->username, $this->password)
|
||||
or die("ERR1"); // ace . $this->get_error());
|
||||
$this->select_db($this->database);
|
||||
}
|
||||
}
|
||||
|
||||
function close()
|
||||
{
|
||||
@mysql_close($this->_connection);
|
||||
}
|
||||
|
||||
function query($sql_statement)
|
||||
{
|
||||
$result = mysql_query($sql_statement, $this->_connection);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function select_db($dbname) {
|
||||
$this->database = $dbname;
|
||||
mysql_select_db($this->database, $this->_connection) or die("Database selection error : " . $this->get_error());
|
||||
}
|
||||
|
||||
function num_rows($result)
|
||||
{
|
||||
return @mysql_num_rows($result);
|
||||
}
|
||||
|
||||
function fetch_row($result, $result_type=MYSQL_BOTH)
|
||||
{
|
||||
return @mysql_fetch_array($result, $result_type);
|
||||
}
|
||||
|
||||
function fetch_assoc($result)
|
||||
{
|
||||
return @mysql_fetch_array($result, MYSQL_ASSOC);
|
||||
}
|
||||
|
||||
|
||||
function query_single_row($sql_statement)
|
||||
{
|
||||
$result = $this->query($sql_statement);
|
||||
return @mysql_fetch_array($result);
|
||||
}
|
||||
|
||||
function free_result($result)
|
||||
{
|
||||
@mysql_free_result($result);
|
||||
}
|
||||
|
||||
function get_error()
|
||||
{
|
||||
return mysql_errno($this->_connection) .": ". mysql_error($this->_connection);
|
||||
}
|
||||
|
||||
function last_insert_id()
|
||||
{
|
||||
return @mysql_insert_id();
|
||||
}
|
||||
|
||||
function change_to($host,$user,$pass,$dbname)
|
||||
{
|
||||
$this->close();
|
||||
$this->hostname = $host;
|
||||
$this->username = $user;
|
||||
$this->password = $pass;
|
||||
$this->database = $dbname;
|
||||
$this->ServerDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class ryDB {
|
||||
|
||||
private static $_instances = array();
|
||||
private $db;
|
||||
private $defs = array();
|
||||
private $errors = '';
|
||||
|
||||
|
||||
private function __construct($db_name) {
|
||||
global $_RYZOM_API_CONFIG;
|
||||
|
||||
$this->db = new ServerDatabase(RYAPI_WEBDB_HOST, RYAPI_WEBDB_LOGIN, RYAPI_WEBDB_PASS, $db_name);
|
||||
$this->db->query("SET NAMES utf8");
|
||||
}
|
||||
|
||||
public static function getInstance($db_name) {
|
||||
if (!array_key_exists($db_name, self::$_instances))
|
||||
self::$_instances[$db_name] = new ryDB($db_name);
|
||||
|
||||
self::$_instances[$db_name]->db->select_db($db_name);
|
||||
return self::$_instances[$db_name];
|
||||
}
|
||||
|
||||
function setDbDefs($table, $defs) {
|
||||
$this->defs[$table] = $defs;
|
||||
}
|
||||
|
||||
function getDefs($table) {
|
||||
if (!array_key_exists($table, $this->defs))
|
||||
die("Please add tables defs using setDbDefs('$table', \$defs)");
|
||||
return $this->defs[$table];
|
||||
}
|
||||
|
||||
function getErrors() {
|
||||
return $this->db->get_error();
|
||||
}
|
||||
|
||||
function now() {
|
||||
return date('Y-m-d H:i:s', time());
|
||||
}
|
||||
|
||||
function toDate($timestamp) {
|
||||
return date('Y-m-d H:i:s', $timestamp);
|
||||
}
|
||||
|
||||
function fromDate($string_date) {
|
||||
return strtotime($string_date);
|
||||
}
|
||||
|
||||
function addDbTableProp($table, $props) {
|
||||
$this->props[$table] = $props;
|
||||
}
|
||||
|
||||
/// DIRECT QUERY
|
||||
function sqlQuery($sql) {
|
||||
$result = $this->db->query($sql);
|
||||
$ret = array();
|
||||
while ($row = $this->db->fetch_row($result)) {
|
||||
$ret[] = $row;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/// QUERY ///
|
||||
function sqlSelect($table, $props, $values=array(), $extra='') {
|
||||
if ($table) {
|
||||
$sql = "SELECT\n\t";
|
||||
$params = array();
|
||||
$test = array();
|
||||
if (!$props)
|
||||
die("Bad Select on [$table] : missing props");
|
||||
|
||||
foreach($props as $name => $type)
|
||||
$params[] = '`'.addslashes($name).'`';
|
||||
|
||||
foreach($values as $name => $value) {
|
||||
if ($name[0] == '=')
|
||||
$test[] = '('.addslashes(substr($name, 1)).' LIKE '.var_export($value, true).')';
|
||||
else
|
||||
$test[] = '('.addslashes($name).' = '.var_export($value, true).')';
|
||||
}
|
||||
$sql .= implode(",\n\t", $params)."\nFROM\n\t".$table."\n";
|
||||
if ($test)
|
||||
$sql .= "WHERE\n\t".implode("\nAND\n\t", $test);
|
||||
}
|
||||
|
||||
if ($extra)
|
||||
$sql .= "\n".$extra;
|
||||
return $sql.';';
|
||||
|
||||
}
|
||||
|
||||
function querySingle($table, $values=array(), $extra='') {
|
||||
$sql = $this->sqlSelect($table, $this->getDefs($table), $values, $extra);
|
||||
$result = $this->db->query($sql);
|
||||
return $this->db->fetch_row($result);
|
||||
}
|
||||
|
||||
function querySingleAssoc($table, $values=array(), $extra='') {
|
||||
$sql = $this->sqlSelect($table, $this->getDefs($table), $values, $extra);
|
||||
$result = $this->db->query($sql);
|
||||
return $this->db->fetch_row($result, MYSQL_ASSOC);
|
||||
}
|
||||
|
||||
function query($table, $values=array(), $extra='') {
|
||||
$sql = $this->sqlSelect($table, $this->getDefs($table), $values, $extra);
|
||||
$result = $this->db->query($sql);
|
||||
$ret = array();
|
||||
while ($row = $this->db->fetch_row($result)) {
|
||||
$ret[] = $row;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function queryAssoc($table, $values=array(), $extra='') {
|
||||
$sql = $this->sqlSelect($table, $this->getDefs($table), $values, $extra);
|
||||
$result = $this->db->query($sql);
|
||||
$ret = array();
|
||||
while ($row = $this->db->fetch_row($result, MYSQL_ASSOC)) {
|
||||
$ret[] = $row;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/// INSERT ///
|
||||
function sqlInsert($table, $props, $vals) {
|
||||
$sql = 'INSERT INTO '.$table.' ';
|
||||
$params = array();
|
||||
$values = array();
|
||||
foreach($props as $name => $type) {
|
||||
if (!isset($vals[$name]))
|
||||
continue;
|
||||
$params[] = $name;
|
||||
switch ($type) {
|
||||
case SQL_DEF_BOOLEAN:
|
||||
$values[] = $vals[$name]?1:0;
|
||||
break;
|
||||
case SQL_DEF_INT:
|
||||
$values[] = $vals[$name];
|
||||
break;
|
||||
case SQL_DEF_DATE: // date
|
||||
if (is_string($vals[$name]))
|
||||
$values[] = "'".addslashes($vals[$name])."'";
|
||||
else
|
||||
$values[] = "'".$this->toDate($vals[$name])."'";
|
||||
break;
|
||||
default:
|
||||
$values[] = "'".addslashes($vals[$name])."'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sql .= "(\n\t".implode(",\n\t", $params)."\n) VALUES (\n\t".implode(",\n\t", $values)."\n);";
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function insert($table, $values) {
|
||||
$sql = $this->sqlInsert($table, $this->getDefs($table), $values);
|
||||
$this->db->query($sql);
|
||||
return $this->db->last_insert_id();
|
||||
}
|
||||
|
||||
/// DELETE ///
|
||||
function sqlDelete($table, $values=array(), $where='') {
|
||||
$sql = "DELETE FROM\n\t".$table."\n";
|
||||
$test = array();
|
||||
foreach($values as $name => $value)
|
||||
$test[] = '('.addslashes($name).' = '.var_export($value, true).')';
|
||||
|
||||
if ($test or $where)
|
||||
$sql .= "WHERE\n\t";
|
||||
if ($test)
|
||||
$sql .= implode("\nAND\n\t", $test);
|
||||
if ($where)
|
||||
$sql .= "\n".$where;
|
||||
return $sql.';';
|
||||
}
|
||||
|
||||
function delete($table, $values=array(), $where='') {
|
||||
$sql = $this->sqlDelete($table, $values, $where);
|
||||
$result = $this->db->query($sql);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/// UPDATE ///
|
||||
function sqlUpdate($table, $props, $vals, $tests, $extra) {
|
||||
$sql = 'UPDATE '.$table.' SET ';
|
||||
$params = array();
|
||||
$test = array();
|
||||
$values = array();
|
||||
foreach($props as $name => $type) {
|
||||
if (!array_key_exists($name, $vals))
|
||||
continue;
|
||||
switch ($type) {
|
||||
case SQL_DEF_BOOLEAN:
|
||||
$values[] = '`'.$name.'` = '.($vals[$name]?'1':'0');
|
||||
break;
|
||||
case SQL_DEF_DATE:
|
||||
if (is_string($vals[$name]))
|
||||
$values[] = '`'.$name.'` = \''.addslashes($vals[$name]).'\'';
|
||||
else
|
||||
$values[] = '`'.$name.'` = \''.$this->toDate($vals[$name]).'\'';
|
||||
break;
|
||||
default:
|
||||
$values[] = '`'.$name.'` = \''.addslashes($vals[$name]).'\'';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sql .= "\n\t".implode(",\n\t", $values)."\n";
|
||||
|
||||
foreach($tests as $name => $value) {
|
||||
$test[] = '('.addslashes($name).' = '.var_export($value, true).')';
|
||||
}
|
||||
if ($test)
|
||||
$sql .= "WHERE\n\t".implode("\nAND\n\t", $test);
|
||||
|
||||
$sql .= "\n".$extra;
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
function update($table, $values=array(), $test=array(), $extra='') {
|
||||
$sql = $this->sqlUpdate($table, $this->getDefs($table), $values, $test, $extra);
|
||||
$result = $this->db->query($sql);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function sqlInsertOrUpdate($table, $props, $vals) {
|
||||
$sql = $this->sqlInsert($table, $props, $vals);
|
||||
$sql = substr($sql, 0, strlen($sql)-1);
|
||||
$params = array();
|
||||
$test = array();
|
||||
$values = array();
|
||||
foreach($props as $prop) {
|
||||
if (!array_key_exists($prop[2], $vals))
|
||||
continue;
|
||||
$type = $prop[0];
|
||||
$check = $prop[1];
|
||||
$name = $prop[2];
|
||||
if ($type{0} == '#')
|
||||
$type = substr($type, 1);
|
||||
if (($type{0} == '>') or ($type == 'id'))
|
||||
continue;
|
||||
switch ($type) {
|
||||
case 'trad':
|
||||
$values[] = '`'.$name."` = '".addslashes($vals[$name])."'";
|
||||
break;
|
||||
case 'textarea':
|
||||
case 'string':
|
||||
case 'option':
|
||||
$values[] = '`'.$name."` = '".addslashes($vals[$name])."'";
|
||||
break;
|
||||
case 'id':
|
||||
case 'int':
|
||||
case 'float':
|
||||
$values[] = '`'.$name.'` = '.addslashes($vals[$name]);
|
||||
break;
|
||||
case 'bool':
|
||||
$values[] = '`'.$name.'` = '.($vals[$name]?'1':'0');
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sql .= "\nON DUPLICATE KEY UPDATE\n\t".implode(",\n\t", $values)."\n";
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function insertOrUpdate($table, $values) {
|
||||
$sql = $this->sqlInsertOrUpdate($table, $this->getDefs($table), $values);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/// Display
|
||||
function getTableHtml($name, $params, $values, $order_by='')
|
||||
{
|
||||
$ret = '<table cellpadding="0" cellspacing="0" width="100%">';
|
||||
$tr_header = '<td align="left" height="32px"> ';
|
||||
$tr_header .= implode('</td><td align="left"> ', array_keys($params)).'</td>';
|
||||
$ret .= _s('t header', $tr_header);
|
||||
$i = 0;
|
||||
if (!$values)
|
||||
return '';
|
||||
$current_section = '';
|
||||
foreach ($values as $rows) {
|
||||
if ($order_by && $rows[$order_by] != $current_section) {
|
||||
$current_section = $rows[$order_by];
|
||||
if ($current_section != '0')
|
||||
$ret .= _s('t row ', '<td>'._s('section', $current_section).'</td>'.str_repeat('<td>'._s('section', ' ').'</td>', count($params)-1));
|
||||
}
|
||||
$td = '';
|
||||
foreach ($params as $test => $param)
|
||||
$td .= '<td align="left" height="22px"> '.$rows[$param].'</td>';
|
||||
$ret .= _s('t row '.strval($i % 2), $td);
|
||||
$i++;
|
||||
}
|
||||
$ret .= '</table>';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class ryLogger {
|
||||
|
||||
public $enable = false;
|
||||
private $logs;
|
||||
private static $_instance = NULL;
|
||||
|
||||
public static function getInstance() {
|
||||
if (self::$_instance === NULL)
|
||||
self::$_instance = new ryLogger();
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
function addLog($log, $indent=NULL) {
|
||||
if ($indent !== NULL)
|
||||
$this->log_indent += $indent;
|
||||
if ($log) {
|
||||
$tabs = str_repeat(" ", $this->log_indent);
|
||||
$a = $tabs.str_replace("\n", "\n ".$tabs, $log);
|
||||
$this->logs[] = '<font color="#00FF00">'.$a.'</font>';
|
||||
}
|
||||
}
|
||||
|
||||
function addPrint($log, $color='#FFFF00') {
|
||||
$this->logs[] = '<font color="'.$color.'">'.$log.'</font>';
|
||||
}
|
||||
|
||||
function addError($log) {
|
||||
$this->logs[] = '<font color="#FF5500"> ERROR: '.$log.'</font>';
|
||||
}
|
||||
|
||||
function getLogs() {
|
||||
$ret = '';
|
||||
if ($this->logs && $this->enable)
|
||||
$ret = "<b>Debug</b>\n".implode("\n", $this->logs);
|
||||
$this->logs = array();
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function ryzom_app_render($title, $content, $bgcolor='', $javascript=array(), $homeLink=false) {
|
||||
$c = '';
|
||||
// Render header
|
||||
$title_prefix = '';
|
||||
if (ON_IPHONE) {
|
||||
$title_prefix = 'Ryzom - ';
|
||||
}
|
||||
|
||||
if (!$bgcolor)
|
||||
$bgcolor = '#000000'.(RYZOM_IG?'00':'');
|
||||
|
||||
$c .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'."\n";
|
||||
$c .= '<html>
|
||||
<head>'."\n";
|
||||
$c .= ' <title>'.$title_prefix.(translation_exists($title)?_t($title):$title).'</title>'."\n";
|
||||
$c .= ' <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8" />'."\n";
|
||||
|
||||
if (!RYZOM_IG) {
|
||||
$c .= ryzom_render_header();
|
||||
$c .= ryzom_render_header_www();
|
||||
}
|
||||
|
||||
$events = ON_IPHONE ? 'onorientationchange="updateOrientation();" ' : '';
|
||||
|
||||
$c .= ' </head>'."\n";
|
||||
|
||||
$c .= ' <body '.$events.'bgcolor="'.$bgcolor.'">'."\n";
|
||||
|
||||
// Javascript
|
||||
$js_code = '';
|
||||
foreach ($javascript as $js)
|
||||
$js_code .= '<script type="text/javascript" src="'.$js.'"></script>';
|
||||
$c .= $js_code;
|
||||
|
||||
if (RYZOM_IG)
|
||||
$c .= $content;
|
||||
else{
|
||||
$c .= ryzom_render_www(ryzom_render_window($title, $content, $homeLink));
|
||||
}
|
||||
|
||||
$c .= '</body></html>';
|
||||
return $c;
|
||||
}
|
||||
|
||||
function ryzom_render_header() {
|
||||
if (ON_IPHONE) {
|
||||
return '';
|
||||
} else {
|
||||
return ' <link type="text/css" href="'.RYAPI_URL.'data/css/ryzom_ui.css" rel="stylesheet" media="all" />';
|
||||
}
|
||||
}
|
||||
|
||||
// Call this inside the <head> part if you want to use ryzom_render_www
|
||||
function ryzom_render_header_www() {
|
||||
if (ON_IPHONE) {
|
||||
return '
|
||||
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.8;">
|
||||
<link rel="apple-touch-icon" href="data/img/ryzom_icon.png"/>
|
||||
<link type="text/css" href="data/css/ryzom_iphone.css" rel="stylesheet" media="all" />
|
||||
<script type="text/javascript">
|
||||
window.addEventListener("load", function() { setTimeout(loaded, 100) }, false);
|
||||
window.onload = function initialLoad() { updateOrientation(); }
|
||||
iPhone.DomLoad(updateOrientation);
|
||||
setInterval(updateOrientation, 500);
|
||||
|
||||
function loaded() {
|
||||
document.getElementById("main").style.visibility = "visible";
|
||||
window.scrollTo(0, 1); // hide the location bar
|
||||
}
|
||||
function updateOrientation(){
|
||||
switch (window.orientation) {
|
||||
case 0:
|
||||
case 180:
|
||||
contentType = "show_normal";
|
||||
break;
|
||||
case -90:
|
||||
case 90:
|
||||
default:
|
||||
contentType = "show_wide";
|
||||
break;
|
||||
}
|
||||
document.getElementById("main").setAttribute("class", contentType);
|
||||
}
|
||||
function sizeTextarea(t) {
|
||||
a = t.value.split(\'\n\');
|
||||
b=1;
|
||||
for (x=0;x < a.length; x++) {
|
||||
if (a[x].length >= t.cols) b+= Math.floor(a[x].length/t.cols);
|
||||
}
|
||||
b+= a.length;
|
||||
if (b > t.rows) t.rows = b;
|
||||
}
|
||||
</script>
|
||||
';
|
||||
} else {
|
||||
return '
|
||||
<style type="text/css">
|
||||
body{background-image:url('.RYAPI_URL.'data/img/bg.jpg);background-repeat:no-repeat;color:white;background-color:black;font-family:arial;font-size:12px}
|
||||
#main{width:95%;height:300px;margin-left:auto;margin-right:auto;text-align:left}
|
||||
a, a:visited{color:orange;font-size:12px}
|
||||
td{font-size:12px}
|
||||
a:hover{color:orange}
|
||||
.error{padding:.5em;background:#ff5555;color:white;font-weight:bold}
|
||||
img{border:0px}
|
||||
textarea{background-color:black;color:white;font-family:arial;font-size:12px}
|
||||
pre{overflow:auto;width:800px}
|
||||
</style>
|
||||
';
|
||||
}
|
||||
}
|
||||
|
||||
// Render a Ryzom style window
|
||||
function ryzom_render_window($title, $content, $homeLink=false) {
|
||||
return ryzom_render_window_begin($title, $homeLink) . $content . ryzom_render_window_end();
|
||||
}
|
||||
|
||||
function ryzom_render_window_begin($title, $homeLink=false) {
|
||||
|
||||
if ($homeLink === false)
|
||||
$homeLink = '<span style="float:right;margin-right:12px;"><a href="'.RYAPP_URL.'/index.php" class="ryzom-ui-text-button">'._t('home').'</a></span>';
|
||||
|
||||
return '
|
||||
<div class="ryzom-ui ryzom-ui-header">
|
||||
<div class="ryzom-ui-tl"><div class="ryzom-ui-tr">
|
||||
<div class="ryzom-ui-t">'.$title_prefix.(translation_exists($title)?_t($title):$title).$homeLink.'</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ryzom-ui-l"><div class="ryzom-ui-r"><div class="ryzom-ui-m">
|
||||
<div class="ryzom-ui-body">
|
||||
';
|
||||
}
|
||||
|
||||
function ryzom_render_window_end() {
|
||||
return '</div>
|
||||
<div style="background-color: #000000">'.ryLogger::getInstance()->getLogs().'</div></div></div></div>
|
||||
<div class="ryzom-ui-bl"><div class="ryzom-ui-br"><div class="ryzom-ui-b"></div></div></div><p class="ryzom-ui-notice">powered by <a class="ryzom-ui-notice" href="http://dev.ryzom.com/projects/ryzom-api/wiki">ryzom-api</a></p>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
|
||||
// Render a webpage using www.ryzom.com style
|
||||
function ryzom_render_www($content) {
|
||||
return ryzom_render_www_begin() . $content . ryzom_render_www_end();
|
||||
}
|
||||
|
||||
function ryzom_render_www_begin($url='') {
|
||||
$style1 = 'position: relative; padding-top: 20px; padding-right: 30px; margin-bottom: -3px';
|
||||
$style2 = 'position: absolute; bottom: 0; right: 0; ';
|
||||
if (ON_IPHONE) {
|
||||
$style1 = 'position: relative; padding-top: 30px; padding-right: 30px; ';
|
||||
$style2 = 'position: fixed; top: 0; right: 0; padding-right: 0px;';
|
||||
$marginBottom = '';
|
||||
}
|
||||
if (!$url) {
|
||||
$url_params = parse_query($_SERVER['REQUEST_URI']);
|
||||
unset($url_params['lang']);
|
||||
|
||||
$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.http_build_query($url_params);
|
||||
}
|
||||
return '
|
||||
<br />
|
||||
<div id="main">
|
||||
<div style="'.$style1.'">
|
||||
<a href="'.$url.'&lang=en"><img hspace="5" border="0" src="'.RYAPI_URL.'data/img/lang/en.png" alt="English" /></a>
|
||||
<a href="'.$url.'&lang=fr"><img hspace="5" border="0" src="'.RYAPI_URL.'data/img/lang/fr.png" alt="French" /></a>
|
||||
<a href="'.$url.'&lang=de"><img hspace="5" border="0" src="'.RYAPI_URL.'data/img/lang/de.png" alt="German" /></a>
|
||||
<a href="'.$url.'&lang=ru"><img hspace="5" border="0" src="'.RYAPI_URL.'data/img/lang/ru.png" alt="Russian" /></a>
|
||||
<div style="'.$style2.'">
|
||||
<a href="http://www.ryzom.com/"><img border="0" src="'.RYAPI_URL.'data/img/logo.gif" alt=""/></a>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
|
||||
function ryzom_render_www_end() {
|
||||
return '</div>';
|
||||
}
|
||||
|
||||
function ryzom_render_login_form($char, $aligned=true) {
|
||||
$c = '';
|
||||
if ($aligned) {
|
||||
$c .= '<form action="" method="post"><table>';
|
||||
$c .= '<tr><td>'._t('enter_char').'</td></tr>';
|
||||
$c .= '<tr><td><input style="width: 200px" type="text" name="char" value="'.$char.'"/></td></tr>';
|
||||
$c .= '<tr><td>'._t('enter_password').'</td></tr>';
|
||||
$c .= '<tr><td><input style="width: 200px" type="password" name="password" /></td></tr>';
|
||||
$c .= '<tr><td><input type="submit" value="'._t('submit').'" /></td></tr>';
|
||||
} else {
|
||||
$c .= '<form action="" method="post"><table width="100%">';
|
||||
$c .= '<tr><td align="center">'._t('login').'</td></tr>';
|
||||
$c .= '<tr><td align="center"><input style="width: 200px" type="text" name="char" value="'.$char.'"/></td></tr>';
|
||||
$c .= '<tr><td align="center">'._t('password').'</td></tr>';
|
||||
$c .= '<tr><td align="center"><input style="width: 200px" type="password" name="password" /></td></tr>';
|
||||
$c .= '<tr><td align="center"><input type="submit" value="'._t('submit').'" /></td></tr>';
|
||||
}
|
||||
$c .= '</table></form>';
|
||||
return $c;
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
?>
|
@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
include_once('logger.php');
|
||||
|
||||
// Always use this function to get param because in game, the param can be pass by _GET or by _POST
|
||||
function ryzom_get_param($var, $default='')
|
||||
{
|
||||
if (isset($_POST[$var]))
|
||||
return $_POST[$var];
|
||||
else
|
||||
if (isset($_GET[$var]))
|
||||
return $_GET[$var];
|
||||
else
|
||||
return $default;
|
||||
}
|
||||
|
||||
function parse_query($var)
|
||||
{
|
||||
$var = parse_url($var);
|
||||
$arr = array();
|
||||
if (isset($var['query'])) {
|
||||
$var = html_entity_decode($var['query']);
|
||||
$var = explode('&', $var);
|
||||
|
||||
foreach($var as $val) {
|
||||
$x = explode('=', $val);
|
||||
$arr[$x[0]] = urldecode($x[1]);
|
||||
}
|
||||
unset($val, $x, $var);
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
if (!function_exists('http_build_query')) {
|
||||
function http_build_query($data, $prefix='', $sep='', $key='') {
|
||||
$ret = array();
|
||||
foreach ((array)$data as $k => $v) {
|
||||
if (is_int($k) && $prefix != null) {
|
||||
$k = urlencode($prefix . $k);
|
||||
}
|
||||
if ((!empty($key)) || ($key === 0)) $k = $key.'['.urlencode($k).']';
|
||||
if (is_array($v) || is_object($v)) {
|
||||
array_push($ret, http_build_query($v, '', $sep, $k));
|
||||
} else {
|
||||
array_push($ret, $k.'='.urlencode($v));
|
||||
}
|
||||
}
|
||||
if (empty($sep)) $sep = ini_get('arg_separator.output');
|
||||
return implode($sep, $ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* Translation utilities
|
||||
*
|
||||
* ***/
|
||||
|
||||
function translation_exists($id) {
|
||||
global $user, $ryzom_texts;
|
||||
return isset($ryzom_texts[$id]) && isset($ryzom_texts[$id][$user['lang']]);
|
||||
}
|
||||
|
||||
// Translate the $id in the selected language
|
||||
function get_translation($id, $lang, $args=array()) {
|
||||
global $ryzom_texts, $user;
|
||||
if(!isset($ryzom_texts[$id])) return '{'.$id.'}';
|
||||
if(!isset($ryzom_texts[$id][$lang])) return '{'.$id.'['.$lang.']}';
|
||||
if($ryzom_texts[$id][$lang] == '' && isset($ryzom_texts[$id]['en'])) return @vsprintf($ryzom_texts[$id]['en'], $args);
|
||||
return @vsprintf($ryzom_texts[$id][$lang], $args);
|
||||
}
|
||||
|
||||
|
||||
// Translate the $id in the user language
|
||||
function _t($id, $args=array()) {
|
||||
global $ryzom_texts, $user;
|
||||
|
||||
$a = '';
|
||||
if ($args) {
|
||||
if (is_array($args)) {
|
||||
$a = array();
|
||||
foreach ($args as $arg)
|
||||
$a[] = strval($arg);
|
||||
$a = ' '.implode(', ', $a);
|
||||
} else
|
||||
$a = ' '.strval($args);
|
||||
}
|
||||
if(!isset($ryzom_texts[$id])) return '{'.$id.$a.'}';
|
||||
if(!isset($ryzom_texts[$id][$user['lang']])) return '{'.$id.'['.$user['lang'].']'.$a.'}';
|
||||
if($ryzom_texts[$id][$user['lang']] == '' && isset($ryzom_texts[$id]['en']) && $ryzom_texts[$id]['en'] != '') return @vsprintf($ryzom_texts[$id]['en'], $args);
|
||||
if($ryzom_texts[$id][$user['lang']] == '' && isset($ryzom_texts[$id]['fr']) && $ryzom_texts[$id]['fr'] != '') return '{'.$id.$a.'}';
|
||||
if($ryzom_texts[$id][$user['lang']] == '' && isset($ryzom_texts[$id]['de']) && $ryzom_texts[$id]['de'] != '') return '{'.$id.$a.'}';
|
||||
return @vsprintf($ryzom_texts[$id][$user['lang']], $args);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* Ryzom time
|
||||
*
|
||||
* ***/
|
||||
|
||||
|
||||
|
||||
// Get a human and translated readable time, for example "3 days ago"
|
||||
function ryzom_relative_time($timestamp) {
|
||||
global $ryzom_periods, $user;
|
||||
$difference = time() - $timestamp;
|
||||
$lengths = array("60","60","24","7","4.35","12","10");
|
||||
|
||||
if ($difference >= 0) { // this was in the past
|
||||
$ending = _t('ago');
|
||||
} else { // this was in the future
|
||||
$difference = -$difference;
|
||||
$ending = _t('to_go');
|
||||
}
|
||||
for($j = 0,$m=count($lengths); $j<$m && $difference >= $lengths[$j]; $j++)
|
||||
$difference /= $lengths[$j];
|
||||
// round hours as '1.2 hours to go'
|
||||
$difference = round($difference, ($j == 2) ? 1 : 0);
|
||||
|
||||
$form = ($difference == 1) ? 'singular' : 'plural';
|
||||
|
||||
// Handle exceptions
|
||||
// French uses singular form if difference = 0
|
||||
if ($user['lang'] == 'fr' && ($difference == 0)) {
|
||||
$form = 'singular';
|
||||
}
|
||||
// Russian has a different plural form for plurals of 2 through 4
|
||||
if ($user['lang'] == 'ru' && ($form == 'plural')) {
|
||||
if ($difference < 5) {
|
||||
$form = '2-4';
|
||||
}
|
||||
}
|
||||
|
||||
$final = $ryzom_periods[$user['lang']][$form][$j];
|
||||
$text = _t('date_format', array($difference, $final, $ending));
|
||||
return $text;
|
||||
}
|
||||
|
||||
// Get a human and translated absolute date
|
||||
function ryzom_absolute_time($timestamp) {
|
||||
global $user, $ryzom_daysofweek, $ryzom_monthnames;
|
||||
$day_of_month = date("j", $timestamp);
|
||||
$dow = date("w", $timestamp);
|
||||
$month = date("n", $timestamp);
|
||||
$day_of_week = $ryzom_daysofweek[$user['lang']][$dow];
|
||||
$month_str = $ryzom_monthnames[$user['lang']][$month-1];
|
||||
$text = _t("absolute_date_format", array($day_of_month, $day_of_week, $month_str, $month, date("m", $timestamp), date("d", $timestamp)));
|
||||
return $text;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* Debug tools
|
||||
*
|
||||
* ***/
|
||||
|
||||
function p($var, $value=NULL) {
|
||||
ob_start();
|
||||
debug_print_backtrace();
|
||||
$bt = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$bt = explode("\n",$bt);
|
||||
$bt = explode('[', $bt[1]);
|
||||
ob_start();
|
||||
echo '<font color="#AAFFFF">'.substr($bt[count($bt)-1], 0, -1)."</font>\n";
|
||||
if ($value !== NULL) {
|
||||
echo '<font color="#FFFFFF">'.$var.' : </font>';
|
||||
$var = $value;
|
||||
}
|
||||
//if (is_array($var))
|
||||
echo '<pre>';
|
||||
print_r($var);
|
||||
echo '</pre>';
|
||||
// else
|
||||
// var_dump($var);
|
||||
ryLogger::getInstance()->addPrint(ob_get_contents());
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,248 @@
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
html, body, form, fieldset, p, div, h1, h2, h3, h4, h5, h6 {
|
||||
margin:0;
|
||||
padding:0;
|
||||
-webkit-text-size-adjust: none;
|
||||
}
|
||||
|
||||
body {
|
||||
font-size: 14px;
|
||||
background: black;
|
||||
font-family: Helvetica;
|
||||
}
|
||||
|
||||
ul li {
|
||||
padding: 0px 4px 10px 2px;
|
||||
list-style: circle outside;
|
||||
}
|
||||
ol li {
|
||||
padding: 0px 4px 10px 2px;
|
||||
}
|
||||
.ryzom-ui p {
|
||||
padding-bottom:8px;
|
||||
}
|
||||
|
||||
#main {
|
||||
clear: both;
|
||||
padding-top: 0px;
|
||||
overflow:auto;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
text-align:left
|
||||
}
|
||||
.error {
|
||||
padding:.5em;
|
||||
background:#ff5555;
|
||||
color:white;
|
||||
font-weight:bold
|
||||
}
|
||||
/*-----------------------------
|
||||
ORIENTATION
|
||||
-----------------------------*/
|
||||
|
||||
.content_wide,
|
||||
.content_normal {
|
||||
display:none;
|
||||
}
|
||||
|
||||
.show_normal {
|
||||
width: 320px;
|
||||
}
|
||||
|
||||
.show_wide {
|
||||
width: 480px;
|
||||
}
|
||||
|
||||
.show_wide .content_wide,
|
||||
.show_normal .content_normal {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* ---------------------- */
|
||||
|
||||
|
||||
.ryzom-ui {
|
||||
color: white;
|
||||
}
|
||||
.ryzom-ui input, .ryzom-ui select {
|
||||
border-top: 1px solid #030403;
|
||||
border-right: 1px solid #6e7f57;
|
||||
border-bottom: 1px solid #889e6c;
|
||||
border-left: 1px solid #272d1f;
|
||||
background-color: #37402b;
|
||||
color: #ddd;
|
||||
font-size: 16px;
|
||||
margin: 2px 0 5px 0;
|
||||
}
|
||||
.ryzom-ui input[type=text] {
|
||||
width: 96%;
|
||||
}
|
||||
|
||||
.ryzom-ui textarea {
|
||||
width: 96%;
|
||||
background-color: black;
|
||||
color: white;
|
||||
font-size: 16px;
|
||||
font-family: Helvetica;
|
||||
}
|
||||
/* input[type=submit] will make IE6 to ignore whole CSS rule, so cant combine this with .ryzom-ui-button below */
|
||||
input[type=submit] {
|
||||
border-bottom: 1px solid #030403;
|
||||
border-left: 1px solid #6e7f57;
|
||||
border-top: 1px solid #889e6c;
|
||||
border-right: 1px solid #272d1f;
|
||||
background-color: #435120;
|
||||
}
|
||||
input.ryzom-ui-button, .ryzom-ui-button {
|
||||
border-bottom: 1px solid #030403;
|
||||
border-left: 1px solid #6e7f57;
|
||||
border-top: 1px solid #889e6c;
|
||||
border-right: 1px solid #272d1f;
|
||||
background-color: #435120;
|
||||
}
|
||||
|
||||
a, a:visited {color:orange}
|
||||
|
||||
a:hover {color:orange}
|
||||
|
||||
a.ryzom-ui-button, a.ryzom-ui-button:visited {
|
||||
color: white;
|
||||
padding: 0 .5em;
|
||||
text-decoration: none;
|
||||
}
|
||||
a.ryzom-ui-button:hover {
|
||||
background: #536130;
|
||||
color: #ddd;
|
||||
}
|
||||
/* window without title - just borders */
|
||||
.ryzom-ui-tl {
|
||||
}
|
||||
.ryzom-ui-tr {
|
||||
}
|
||||
.ryzom-ui-t {
|
||||
background-image: url(skin_t.gif);
|
||||
background-repeat: repeat-x;
|
||||
background-position: left top;
|
||||
height: 8px;
|
||||
margin: 0;
|
||||
}
|
||||
/* window with proper header */
|
||||
.ryzom-ui-header .ryzom-ui-tl {
|
||||
margin: 0px 0px;
|
||||
height: 32px;
|
||||
}
|
||||
.ryzom-ui-header .ryzom-ui-tr {
|
||||
height: 32px;
|
||||
}
|
||||
.ryzom-ui-header .ryzom-ui-t {
|
||||
background-image: url(skin_header_m.gif);
|
||||
background-repeat: repeat-x;
|
||||
background-position: left top;
|
||||
padding: 7px 0 0 12px;
|
||||
height: 32px;
|
||||
text-transform: uppercase;
|
||||
color: white;
|
||||
border-top: 1px solid #030403;
|
||||
}
|
||||
/* window body */
|
||||
.ryzom-ui-l {
|
||||
}
|
||||
.ryzom-ui-r {
|
||||
}
|
||||
.ryzom-ui-m {
|
||||
margin: 0 0px;
|
||||
padding: 0px;
|
||||
background-image: url(skin_blank.png);
|
||||
background-repeat: repeat;
|
||||
}
|
||||
.ryzom-ui-body {
|
||||
background-image: url(skin_blank_inner.png);
|
||||
background-repeat: repeat;
|
||||
/* leave 5px room after bottom border */
|
||||
margin: 0 8px 5px 2px;
|
||||
padding: 5px 5px 5px 5px;
|
||||
border-top: 1px solid #030403;
|
||||
border-right: 1px solid #6e7f57;
|
||||
border-bottom: 1px solid #889e6c;
|
||||
border-left: 1px solid #272d1f;
|
||||
}
|
||||
/* window bottom border */
|
||||
.ryzom-ui-bl {
|
||||
height: 8px;
|
||||
}
|
||||
.ryzom-ui-br {
|
||||
height: 8px;
|
||||
}
|
||||
.ryzom-ui-b {
|
||||
height: 8px;
|
||||
margin: 0 8px;
|
||||
}
|
||||
.ryzom-ui-notice {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
}
|
||||
a.ryzom-ui-notice, a.ryzom-ui-notice:visited {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
color: #BBB;
|
||||
padding: 0 .5em;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a.ryzom-ui-notice:hover {
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.ryzom-ui-t .ryzom-ui-text-button {
|
||||
font-size: 85%;
|
||||
}
|
||||
a.ryzom-ui-text-button, a:visited.ryzom-ui-text-button {
|
||||
color:#FFFF11;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
.ryzom-ui-text-button {
|
||||
border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
}
|
||||
.ryzom-ui-text-button {
|
||||
padding: 0;margin: 0;
|
||||
border-color: #ff8 #ff3 #ff3 #ff8;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
padding: 0px 4px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.ryzom-ui-wrap-ul {
|
||||
float: left;
|
||||
text-align: center;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.ryzom-ui-wrap-li {
|
||||
float: left;
|
||||
margin: 0 0 10px 5px;
|
||||
width: 6.1em;
|
||||
list-style: none;
|
||||
height: 70px;
|
||||
}
|
@ -0,0 +1,227 @@
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Check ryzom_api/functions_render.php for easy php function to render ryzom layout or use this following html:
|
||||
*
|
||||
<div class="ryzom-ui">
|
||||
<div class="ryzom-ui-tl"><div class="ryzom-ui-tr">
|
||||
<div class="ryzom-ui-t"><!-- title --></div>
|
||||
</div></div>
|
||||
<div class="ryzom-ui-l"><div class="ryzom-ui-r"><div class="ryzom-ui-m">
|
||||
<div class="ryzom-ui-body"><!-- content --></div>
|
||||
</div></div></div>
|
||||
<div class="ryzom-ui-bl"><div class="ryzom-ui-br"><div class="ryzom-ui-b"></div></div></div>
|
||||
</div><!-- .ryzom-ui -->
|
||||
*/
|
||||
|
||||
.ryzom-ui {
|
||||
color: white;
|
||||
}
|
||||
.ryzom-ui input, .ryzom-ui select {
|
||||
border-top: 1px solid #030403;
|
||||
border-right: 1px solid #6e7f57;
|
||||
border-bottom: 1px solid #889e6c;
|
||||
border-left: 1px solid #272d1f;
|
||||
background-color: #37402b;
|
||||
color: #ddd;
|
||||
font-size: 12px;
|
||||
margin: 2px 0 5px 0;
|
||||
}
|
||||
.ryzom-ui input[type=text] {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ryzom-ui textarea {
|
||||
width: 98%;
|
||||
}
|
||||
|
||||
/* input[type=submit] will make IE6 to ignore whole CSS rule, so cant combine this with .ryzom-ui-button below */
|
||||
input[type=submit] {
|
||||
border-bottom: 1px solid #030403;
|
||||
border-left: 1px solid #6e7f57;
|
||||
border-top: 1px solid #889e6c;
|
||||
border-right: 1px solid #272d1f;
|
||||
background-color: #435120;
|
||||
}
|
||||
input.ryzom-ui-button, .ryzom-ui-button {
|
||||
border-bottom: 1px solid #030403;
|
||||
border-left: 1px solid #6e7f57;
|
||||
border-top: 1px solid #889e6c;
|
||||
border-right: 1px solid #272d1f;
|
||||
background-color: #435120;
|
||||
}
|
||||
a.ryzom-ui-button, a.ryzom-ui-button:visited {
|
||||
color: white;
|
||||
padding: 0 .5em;
|
||||
text-decoration: none;
|
||||
}
|
||||
a.ryzom-ui-button:hover {
|
||||
background: #536130;
|
||||
color: #ddd;
|
||||
}
|
||||
/* window without title - just borders */
|
||||
.ryzom-ui-tl {
|
||||
background-image: url(skin_tl.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: left top;
|
||||
width: 100%; height: 8px;
|
||||
}
|
||||
.ryzom-ui-tr {
|
||||
background-image: url(skin_tr.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: right top;
|
||||
height: 8px;
|
||||
}
|
||||
.ryzom-ui-t {
|
||||
background-image: url(skin_t.gif);
|
||||
background-repeat: repeat-x;
|
||||
background-position: left top;
|
||||
height: 8px;
|
||||
margin: 0 8px;
|
||||
}
|
||||
/* window with proper header */
|
||||
.ryzom-ui-header .ryzom-ui-tl {
|
||||
margin: 0px 0px;
|
||||
background-image: url(skin_header_l.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: left top;
|
||||
height: 32px;
|
||||
}
|
||||
.ryzom-ui-header .ryzom-ui-tr {
|
||||
background-image: url(skin_header_r.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: right top;
|
||||
height: 32px;
|
||||
}
|
||||
.ryzom-ui-header .ryzom-ui-t {
|
||||
background-image: url(skin_header_m.gif);
|
||||
background-repeat: repeat-x;
|
||||
background-position: left top;
|
||||
margin-left: 12px;
|
||||
margin-right: 26px;
|
||||
padding-top: 9px;
|
||||
height: 32px;
|
||||
text-transform: uppercase;
|
||||
color: white;
|
||||
}
|
||||
/* window body */
|
||||
.ryzom-ui-l {
|
||||
background-image: url(skin_l.gif);
|
||||
background-position: left top;
|
||||
background-repeat: repeat-y;
|
||||
width: 100%;
|
||||
}
|
||||
.ryzom-ui-r {
|
||||
background-image: url(skin_r.gif);
|
||||
background-position: right top;
|
||||
background-repeat: repeat-y;
|
||||
width: 100%;
|
||||
}
|
||||
.ryzom-ui-m {
|
||||
margin: 0 8px;
|
||||
padding: 8px;
|
||||
background-image: url(skin_blank.png);
|
||||
background-repeat: repeat;
|
||||
}
|
||||
.ryzom-ui-body {
|
||||
background-image: url(skin_blank_inner.png);
|
||||
background-repeat: repeat;
|
||||
/* leave 5px room after bottom border */
|
||||
margin: 0px 0 5px 0;
|
||||
padding: 10px 10px 5px 10px;
|
||||
border-top: 1px solid #030403;
|
||||
border-right: 1px solid #6e7f57;
|
||||
border-bottom: 1px solid #889e6c;
|
||||
border-left: 1px solid #272d1f;
|
||||
}
|
||||
/* window bottom border */
|
||||
.ryzom-ui-bl {
|
||||
background-image: url(skin_bl.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: left top;
|
||||
height: 8px;
|
||||
}
|
||||
.ryzom-ui-br {
|
||||
background-image: url(skin_br.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: right top;
|
||||
height: 8px;
|
||||
}
|
||||
.ryzom-ui-b {
|
||||
background-image: url(skin_b.gif);
|
||||
background-repeat: repeat-x;
|
||||
background-position: left top;
|
||||
height: 8px;
|
||||
margin: 0 8px;
|
||||
}
|
||||
.ryzom-ui-notice {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
}
|
||||
a.ryzom-ui-notice, a.ryzom-ui-notice:visited {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
color: #555;
|
||||
padding: 0 .5em;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a.ryzom-ui-notice:hover {
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.ryzom-ui-t .ryzom-ui-text-button {
|
||||
font-size: 85%;
|
||||
}
|
||||
a.ryzom-ui-text-button, a:visited.ryzom-ui-text-button {
|
||||
color:#FFFF11;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
.ryzom-ui-text-button {
|
||||
border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
}
|
||||
.ryzom-ui-text-button {
|
||||
padding: 0;margin: 0;
|
||||
border-color: #ff8 #ff3 #ff3 #ff8;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
padding: 0px 4px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.ryzom-ui-wrap-ul {
|
||||
float: left;
|
||||
text-align: center;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
margin-top: -5px;
|
||||
margin-bottom: -20px;
|
||||
}
|
||||
|
||||
.ryzom-ui-wrap-li {
|
||||
float: left;
|
||||
margin: 0 5px 10px 5px;
|
||||
width: 6.1em;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
height: 70px;
|
||||
}
|
After Width: | Height: | Size: 748 B |
After Width: | Height: | Size: 129 B |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 130 B |
After Width: | Height: | Size: 434 B |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 977 B |
After Width: | Height: | Size: 477 B |
After Width: | Height: | Size: 488 B |
After Width: | Height: | Size: 315 B |
After Width: | Height: | Size: 99 B |
After Width: | Height: | Size: 127 B |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 229 B |
After Width: | Height: | Size: 396 B |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 62 B |
After Width: | Height: | Size: 6.6 KiB |
@ -0,0 +1 @@
|
||||
<?php echo "api"; ?>
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
require_once('ryzom_api.php');
|
||||
$cid = ryzom_get_param('cid');
|
||||
$name = ryzom_get_param('name');
|
||||
$authserver = ryzom_get_param('authserver');
|
||||
$authkey = ryzom_get_param('authkey');
|
||||
|
||||
if ($authserver) {
|
||||
if (ryzom_authenticate_with_serverkey($cid, $name, $authserver, $authkey))
|
||||
die('1');
|
||||
die('0');
|
||||
}
|
||||
|
||||
if (RYZOM_IG || ryzom_get_param('ig')) {
|
||||
echo 'ig';
|
||||
if (ryzom_authenticate_ingame($cid, $name, $authkey)) {
|
||||
echo 'ok';
|
||||
$user_infos = ryzom_user_get_info($cid);
|
||||
echo ryzom_get_user_id($cid, $name, $user_infos['creation_date']);
|
||||
die('1');
|
||||
}
|
||||
die('0');
|
||||
} else {
|
||||
echo ryzom_authenticate_with_session($name, $cid, $_RYZOM_API_CONFIG['base_url'].'index.php');
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
session_start();
|
||||
|
||||
// Global defines
|
||||
if (!defined('ON_IPHONE')) {
|
||||
if(isset($_SERVER['HTTP_USER_AGENT']))
|
||||
define('ON_IPHONE', strpos($_SERVER['HTTP_USER_AGENT'], 'Ryzom'));
|
||||
else
|
||||
define('ON_IPHONE', false);
|
||||
}
|
||||
if (!defined('RYZOM_IG')) {
|
||||
if (isset($_SERVER['HTTP_USER_AGENT']))
|
||||
define('RYZOM_IG', strpos($_SERVER['HTTP_USER_AGENT'], 'Ryzom'));
|
||||
else
|
||||
define('RYZOM_IG', false);
|
||||
}
|
||||
|
||||
$includes = array('auth', 'config', 'utils', 'user');
|
||||
|
||||
foreach ($includes as $include) {
|
||||
if ($_SERVER['HTTP_HOST'] == 'shard.nuneo.org' || $_SERVER['HTTP_HOST'] == 'app.ryzom.com')
|
||||
require_once("server/$include.php");
|
||||
else
|
||||
require_once("client/$include.php");
|
||||
|
||||
require_once("common/$include.php");
|
||||
}
|
||||
|
||||
require_once("common/db_lib.php");
|
||||
require_once("common/render.php");
|
||||
|
||||
?>
|
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function ryzom_authenticate_with_serverkey($cid, $name, $authserver, $authkey) {
|
||||
$rawkey = RYAPI_COOKIE_KEY.$name.$cid.$authserver;
|
||||
$authkey = md5($rawkey);
|
||||
if ($authkey != $authkey) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function ryzom_authenticate_ingame($cid, $name, $authkey) {
|
||||
return file_get_contents(RYAPI_AUTH_SCRIPT) == '1';
|
||||
}
|
||||
|
||||
// take the character name and the account password and check if it's valid
|
||||
function ryzom_authenticate_with_char_and_password($character, $password, &$cid) {
|
||||
$db = new ServerDatabase(RYAPI_NELDB_HOST, RYAPI_NELDB_LOGIN, RYAPI_NELDB_PASS, RYAPI_NELDB_RING);
|
||||
$char = mysql_real_escape_string($character, $db->_connection);
|
||||
$sql = "SELECT char_id, char_name, user_id, home_mainland_session_id FROM characters WHERE char_name = '$char'";
|
||||
$row = $db->query_single_row($sql);
|
||||
$character = $row['char_name'];
|
||||
$cid = $row['char_id'];
|
||||
$uid = $row['user_id'];
|
||||
mysql_select_db('nel', $db->_connection);
|
||||
$sql = "SELECT Password FROM user WHERE UId = $uid";
|
||||
$row = $db->query_single_row($sql);
|
||||
$ok = $row['Password'] == crypt($password, $row['Password']);
|
||||
return $ok;
|
||||
}
|
||||
|
||||
function ryzom_authenticate_with_session(&$name, &$cid, &$error_message) {
|
||||
$c = '';
|
||||
|
||||
$action = ryzom_get_param('action');
|
||||
if ($action == 'logout') {
|
||||
unset($_SESSION['name']);
|
||||
unset($_SESSION['cid']);
|
||||
}
|
||||
|
||||
if (isset($_SESSION['name']) && ($name == '' || $_SESSION['name'] == $name)) {
|
||||
$name = $_SESSION['cid'];
|
||||
$cid = $_SESSION['cid'];
|
||||
return true;
|
||||
}
|
||||
|
||||
$char = ryzom_get_param('char');
|
||||
$password = ryzom_get_param('password');
|
||||
|
||||
if ($char && $password) {
|
||||
// check credentials
|
||||
if (ryzom_authenticate_with_char_and_password($char, $password, $cid)) {
|
||||
$_SESSION['name'] = $char;
|
||||
$_SESSION['cid'] = $cid;
|
||||
return true;
|
||||
} else {
|
||||
$error_message = 'bad_auth';
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ryzom_get_user_id($cid, $name, $creation_date) {
|
||||
$name = strtolower($name);
|
||||
|
||||
$db = ryDB::getInstance('webig');
|
||||
$db->setDbDefs('players', array('id' => SQL_DEF_INT, 'cid' => SQL_DEF_INT, 'name' => SQL_DEF_TEXT, 'creation_date' => SQL_DEF_DATE, 'deleted' => SQL_DEF_BOOLEAN));
|
||||
|
||||
$charProps = $db->querySingle('players', array('cid' => intval($cid), 'deleted' => 0));
|
||||
// new char => create record
|
||||
if (!$charProps) {
|
||||
$charProps = array('name' => $name, 'cid' => $cid, 'creation_date' => $creation_date, 'deleted' => 0);
|
||||
$charProps['id'] = $db->insert('players', $charProps);
|
||||
if (!$charProps['id'])
|
||||
die('ryDb New Char Error');
|
||||
} else {
|
||||
// char renamed => update record
|
||||
if ($charProps['name'] != $name)
|
||||
if (!$db->update('players', array('name' => $name), array('id' => $charProps['id'])))
|
||||
die('ryDb Rename Char Error');
|
||||
|
||||
// char deleted and recreated => change to deleted
|
||||
if ($charProps['creation_date'] != $creation_date) {
|
||||
if (!$db->update('players', array('deleted' => 1), array('id' => $charProps['id'])))
|
||||
die('ryDb Delete char Error: '.$db->getErrors());
|
||||
$charProps = array('name' => $name, 'cid' => $cid, 'creation_date' => $creation_date, 'deleted' => 0);
|
||||
if (!$charProps['id'] = $db->insert('players', $charProps))
|
||||
die('ryDb New Char in Slot Error');
|
||||
}
|
||||
}
|
||||
return $charProps['id'];
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
define('RYAPI_WEBDB_HOST', 'localhost');
|
||||
define('RYAPI_WEBDB_LOGIN', 'localhost');
|
||||
define('RYAPI_WEBDB_PASS', 'localhost');
|
||||
|
||||
define('RYAPI_NELDB_HOST', 'localhost');
|
||||
define('RYAPI_NELDB_LOGIN', 'shard');
|
||||
define('RYAPI_NELDB_PASS', 'localhost');
|
||||
define('RYAPI_NELDB_RING', 'ring_open');
|
||||
define('RYAPI_NELDB_NEL', 'nel');
|
||||
|
||||
define('RYAPI_AUTH_SCRIPT', '');
|
||||
define('RYAPI_COOKIE_KEY', '');
|
||||
|
||||
?>
|
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function ryzom_user_get_info($cid) {
|
||||
// User information
|
||||
global $_RYZOM_API_CONFIG;
|
||||
$db = new ServerDatabase(RYAPI_NELDB_HOST, RYAPI_NELDB_LOGIN, RYAPI_NELDB_PASS, RYAPI_NELDB_RING);
|
||||
$sql = "SELECT char_name, race, civilisation, cult, guild_id, creation_date, last_played_date FROM characters WHERE char_id = $cid";
|
||||
$result = $db->query($sql) or die('Could not query on ryzom_user_get_info');
|
||||
$found = $db->num_rows($result) >= 1;
|
||||
if (!$found)
|
||||
die('Could not found on ryzom_user_get_info');
|
||||
$row = $db->fetch_assoc($result);
|
||||
$db->free_result($result);
|
||||
if ($row) {
|
||||
$row['race'] = substr($row['race'], 2);
|
||||
$row['cult'] = substr($row['cult'], 2);
|
||||
$row['civ'] = substr($row['civilisation'], 2);
|
||||
if ($row['guild_id'] != '0') {
|
||||
//$xml = @simplexml_load_file(ryzom_guild($row['guild_id'], false));
|
||||
$xml = false;
|
||||
if ($xml !== false) {
|
||||
$row['guild_icon'] = (string)$xml->icon;
|
||||
$row['guild_name'] = (string)$xml->name;
|
||||
$result = $xml->xpath("/guild/members/member[cid=$cid]");
|
||||
while(list( , $item) = each($result))
|
||||
$row['grade'] = (string)$item->grade;
|
||||
} else {
|
||||
$row['guild_name'] = 'UNKNOWN_GUILD_'.$row['guild_id']; // Unknow name (normal in yubo shard)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$uid = intval($cid / 16);
|
||||
$db = new ServerDatabase(RYAPI_NELDB_HOST, RYAPI_NELDB_LOGIN, RYAPI_NELDB_PASS, RYAPI_NELDB_NEL);
|
||||
$sql = "SELECT Privilege FROM user WHERE UId = $uid";
|
||||
$result = $db->query($sql) or die("Could not query.");
|
||||
$priv_row = $db->fetch_row($result, MYSQL_NUM);
|
||||
$priv = $priv_row[0];
|
||||
$db->free_result($result);
|
||||
$groups = array();
|
||||
|
||||
if (strpos($priv, ':DEV:') !== false) {
|
||||
$groups[] = 'DEV';
|
||||
$groups[] = 'SGM';
|
||||
$groups[] = 'GM';
|
||||
$groups[] = 'EM';
|
||||
$groups[] = 'EG';
|
||||
$groups[] = 'VG';
|
||||
$groups[] = 'G';
|
||||
}
|
||||
|
||||
if (strpos($priv, ':SGM:') !== false) {
|
||||
$groups[] = 'SGM';
|
||||
$groups[] = 'GM';
|
||||
$groups[] = 'VG';
|
||||
$groups[] = 'G';
|
||||
}
|
||||
|
||||
if (strpos($priv, ':GM:') !== false) {
|
||||
$groups[] = 'GM';
|
||||
$groups[] = 'VG';
|
||||
$groups[] = 'G';
|
||||
}
|
||||
|
||||
if (strpos($priv, ':VG:') !== false) {
|
||||
$groups[] = 'VG';
|
||||
$groups[] = 'G';
|
||||
}
|
||||
|
||||
if (strpos($priv, ':G:') !== false) {
|
||||
$groups[] = 'G';
|
||||
}
|
||||
|
||||
if (strpos($priv, ':SEM:') !== false) {
|
||||
$groups[] = 'SEM';
|
||||
$groups[] = 'EM';
|
||||
$groups[] = 'EG';
|
||||
}
|
||||
|
||||
if (strpos($priv, ':EM:') !== false) {
|
||||
$groups[] = 'EM';
|
||||
$groups[] = 'EG';
|
||||
}
|
||||
|
||||
if (strpos($priv, ':EG:') !== false) {
|
||||
$groups[] = 'EG';
|
||||
}
|
||||
|
||||
$groups[] = 'PLAYER';
|
||||
$row['groups'] = $groups;
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
function ryzom_name_to_file($name)
|
||||
{
|
||||
$r = '';
|
||||
for ($i=0; $i<strlen($name); ++$i)
|
||||
{
|
||||
if ($name[$i] == ' ')
|
||||
$r .= '_';
|
||||
else if ($name[$i] == '%' || $name[$i] <= chr(32) || $name[$i] >= chr(127))
|
||||
$r .= sprintf("%%%02x", ord($name[$i]));
|
||||
else
|
||||
$r .= $name[$i];
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// get user home directory
|
||||
// -------------------------------------
|
||||
function ryzom_get_user_dir($user)
|
||||
{
|
||||
global $_RYZOM_API_CONFIG;
|
||||
|
||||
if ($user == "")
|
||||
die("INTERNAL ERROR CODE 1");
|
||||
|
||||
$user = ryzom_name_to_file($user);
|
||||
return $_RYZOM_API_CONFIG['cookie_path'].'/'.$_RYZOM_API_CONFIG['shardid'].'/'.substr(strtolower($user), 0, 2).'/'.strtolower($user).'/';
|
||||
}
|
||||
|
||||
?>
|
After Width: | Height: | Size: 2.5 KiB |
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
define('APP_NAME', 'app_test');
|
||||
|
||||
include_once('../config.php');
|
||||
include_once('../lang.php');
|
||||
include_once('lang.php');
|
||||
|
||||
// Ask to authenticate user (using ingame or session method) and fill $user with all information
|
||||
ryzom_app_authenticate($user, true);
|
||||
|
||||
// Enable debug logs only for DEVS
|
||||
if (in_array('DEV', $user['groups']))
|
||||
ryLogger::getInstance()->enable = true;
|
||||
|
||||
// Debug log
|
||||
p($user);
|
||||
|
||||
// Update user acces on Db
|
||||
$db = ryDB::getInstance(APP_NAME);
|
||||
$db->setDbDefs('test', array('id' => SQL_DEF_INT, 'num_access' => SQL_DEF_INT));
|
||||
|
||||
$num_access = $db->querySingleAssoc('test', array('id' => $user['id']));
|
||||
if ($num_access)
|
||||
$db->update('test', array('num_access' => ++$num_access['num_access']), array('id' => $user['id']));
|
||||
else
|
||||
$db->insert('test', array('num_access' => $num_access['num_access']=1, 'id' => $user['id']));
|
||||
|
||||
// Content
|
||||
$c = _t('access', $num_access['num_access']).'<br/>';
|
||||
|
||||
echo ryzom_app_render(APP_NAME, $c);
|
||||
|
||||
?>
|
@ -0,0 +1,15 @@
|
||||
<?php // %2011-09-28T08:12:16+02:00
|
||||
$__texts = array (
|
||||
'access' =>
|
||||
array (
|
||||
'en' => 'User access this page %s times',
|
||||
'fr' => 'L\'utilisateur a accede a cette page %s fois',
|
||||
'de' => '',
|
||||
'ru' => '',
|
||||
),
|
||||
);
|
||||
if(isset($ryzom_texts))
|
||||
$ryzom_texts = array_merge ($__texts, $ryzom_texts);
|
||||
else
|
||||
$ryzom_texts = $__texts;
|
||||
?>
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/* Copyright (C) 2009 Winch Gate Property Limited
|
||||
*
|
||||
* This file is part of ryzom_api.
|
||||
* ryzom_api is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ryzom_api is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ryzom_api. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
define('RYAPP_URL', 'http://');
|
||||
define('RYAPP_PATH', dirname(__FILE__).'/');
|
||||
define('RYAPI_PATH', dirname(__FILE__).'/../api/');
|
||||
|
||||
include_once(RYAPI_PATH.'ryzom_api.php');
|
||||
|
||||
?>
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
include_once('config.php');
|
||||
|
||||
include_once('lang.php');
|
||||
|
||||
// List of apps
|
||||
$apps = array(
|
||||
'app_test',
|
||||
);
|
||||
|
||||
|
||||
$c = '';
|
||||
|
||||
// Ask to authenticate user (using ingame or session method) and fill $user with all information
|
||||
$logged = ryzom_app_authenticate($user, false);
|
||||
if ($logged) {
|
||||
$c .= '<h1>'._t('welcome', $user['char_name']).'</h1>';
|
||||
} else {
|
||||
if (!RYZOM_IG) {
|
||||
if ($user['message'])
|
||||
$c .= '<div style="text-align: center"><strong style="color: #FF5555">'._t($user['message']).'</strong></div><br />';
|
||||
$c .= ryzom_render_login_form(ryzom_get_param('name'));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($apps as $app) {
|
||||
$c .= '<a href="'.RYAPP_URL.'/'.$app.'/index.php"><img src="'.RYAPP_URL.'/'.$app.'/favicon.png" />'._t($app).'</a><br />';
|
||||
}
|
||||
|
||||
if($logged) $c .= '<br /><a href="'.RYAPP_URL.'/index.php?action=logout">'._t('logout').'</a>';
|
||||
|
||||
echo ryzom_app_render('Ryzom', $c);
|
||||
|
||||
?>
|