From 9be5bfb5d75897c7e1728b4d6e1557f0e0a09091 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 6 Sep 2014 00:35:28 +0200 Subject: [PATCH 01/93] Create shard admin user in setup --- .../private_php/setup/sql/nel_tool_00001.sql | 9 +---- .../{todo_cfg => public_php}/admin/config.php | 32 ++++++++-------- code/web/public_php/setup/header.php | 2 + code/web/public_php/setup/install.php | 37 ++++++++++++++++++- 4 files changed, 55 insertions(+), 25 deletions(-) rename code/web/{todo_cfg => public_php}/admin/config.php (71%) diff --git a/code/web/private_php/setup/sql/nel_tool_00001.sql b/code/web/private_php/setup/sql/nel_tool_00001.sql index 12ae695ad..a01a1c4a5 100644 --- a/code/web/private_php/setup/sql/nel_tool_00001.sql +++ b/code/web/private_php/setup/sql/nel_tool_00001.sql @@ -595,14 +595,7 @@ CREATE TABLE IF NOT EXISTS `neltool_users` ( UNIQUE KEY `user_login` (`user_name`), KEY `user_group_id` (`user_group_id`), KEY `user_active` (`user_active`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; - --- --- Dumping data for table `neltool_users` --- - -INSERT INTO `neltool_users` (`user_id`, `user_name`, `user_password`, `user_group_id`, `user_created`, `user_active`, `user_logged_last`, `user_logged_count`, `user_menu_style`) VALUES -(1, 'guest', '084e0343a0486ff05530df6c705c8bb4', 1, 1405357395, 1, 0, 0, 0); +) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- diff --git a/code/web/todo_cfg/admin/config.php b/code/web/public_php/admin/config.php similarity index 71% rename from code/web/todo_cfg/admin/config.php rename to code/web/public_php/admin/config.php index 530adcb43..0a43d798a 100644 --- a/code/web/todo_cfg/admin/config.php +++ b/code/web/public_php/admin/config.php @@ -1,30 +1,32 @@ 0, 'level_name' => 'Normal'), @@ -70,6 +72,6 @@ 'level_name' => 'Administrator'), ); - $restart_notification_emails = array('vl@ryzom.com'); + $restart_notification_emails = array('support@ryzomcore.org'); ?> diff --git a/code/web/public_php/setup/header.php b/code/web/public_php/setup/header.php index 1c7b4cda0..317637ef8 100644 --- a/code/web/public_php/setup/header.php +++ b/code/web/public_php/setup/header.php @@ -112,6 +112,8 @@ function update_database_structure($continue_r, $con, $file) { admin/common.php"); + $continue = false; + } + } + if ($continue) { + try { + require_once('functions_tool_administration.php'); + } catch (Exception $e) { + printalert("danger", "Failed to include NeL admin/functions_tool_administration.php"); + $continue = false; + } + } + if ($continue) { + $adminGroup = 1; + $result = tool_admin_users_add($_POST["toolsAdminUsername"], $_POST["toolsAdminPassword"], (string)$adminGroup, (string)1); + if ($result == "") { + printalert("success", "Added shard admin to NeL tools database"); + } else { + printalert("danger", "Failed to add shard admin to NeL tools database
" . htmlentities($result)); + $continue = false; + } + } + if (!chdir("../")) { + printalert("danger", "Cannot change to public PHP root directory"); + $continue = false; + } } if ($roleSupport) { From 07eff64df55c97d261d84d2e16666e9831504a7b Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 6 Sep 2014 00:38:20 +0200 Subject: [PATCH 02/93] Fix version number --- code/web/public_php/ams/templates/layout.tpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/web/public_php/ams/templates/layout.tpl b/code/web/public_php/ams/templates/layout.tpl index 6550929b0..d4735a200 100644 --- a/code/web/public_php/ams/templates/layout.tpl +++ b/code/web/public_php/ams/templates/layout.tpl @@ -29,7 +29,7 @@ - + @@ -158,7 +158,7 @@
- {if $permission > 1}

AMS 0.9.0 Powered by: Charisma

{/if} + {if $permission > 1}

AMS 0.9.1 Powered by: Charisma

{/if}
{/if} @@ -303,6 +303,6 @@ - + From 1cec88b78b4236a43250c310a25160417edffc1d Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 6 Sep 2014 01:40:37 +0200 Subject: [PATCH 03/93] Protect shard admin auth SQL queries --- code/web/public_php/admin/functions_auth.php | 10 +++++----- code/web/public_php/admin/functions_mysqli.php | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/code/web/public_php/admin/functions_auth.php b/code/web/public_php/admin/functions_auth.php index fcc53ed6a..b56a12064 100644 --- a/code/web/public_php/admin/functions_auth.php +++ b/code/web/public_php/admin/functions_auth.php @@ -8,7 +8,7 @@ { global $db; - $sql = "UPDATE ". NELDB_USER_TABLE ." SET user_logged_count=user_logged_count+1,user_logged_last=". time() ." WHERE user_id=". $user_id; + $sql = "UPDATE ". NELDB_USER_TABLE ." SET user_logged_count=user_logged_count+1,user_logged_last=". time() ." WHERE user_id=". (int)$user_id; $db->sql_query($sql); } @@ -18,7 +18,7 @@ $data = null; - $sql = "SELECT * FROM ". NELDB_USER_TABLE ." LEFT JOIN ". NELDB_GROUP_TABLE ." ON (user_group_id=group_id) WHERE user_id=". $nelid; + $sql = "SELECT * FROM ". NELDB_USER_TABLE ." LEFT JOIN ". NELDB_GROUP_TABLE ." ON (user_group_id=group_id) WHERE user_id=". (int)$nelid; if ($result = $db->sql_query($sql)) { if ($db->sql_numrows($result)) @@ -34,7 +34,7 @@ { global $db; - $sql = "SELECT user_name FROM ". NELDB_USER_TABLE ." WHERE user_id=". $group_id; + $sql = "SELECT user_name FROM ". NELDB_USER_TABLE ." WHERE user_id=". (int)$group_id; if ($result = $db->sql_query($sql)) { if ($db->sql_numrows($result)) @@ -53,7 +53,7 @@ $data = null; - $user = trim($user); + $user = $db->sql_escape_string(trim($user)); $passwd = md5(trim($passwd)); $sql = "SELECT * FROM ". NELDB_USER_TABLE ." LEFT JOIN ". NELDB_GROUP_TABLE ." ON (user_group_id=group_id) WHERE user_name='". $user ."' AND user_password='". $passwd ."' AND user_active=1 AND group_active=1"; @@ -120,4 +120,4 @@ unset($NELTOOL['SESSION_VARS'][$name]); } -?> \ No newline at end of file +?> diff --git a/code/web/public_php/admin/functions_mysqli.php b/code/web/public_php/admin/functions_mysqli.php index da455eb79..8cc2737c3 100644 --- a/code/web/public_php/admin/functions_mysqli.php +++ b/code/web/public_php/admin/functions_mysqli.php @@ -251,6 +251,10 @@ class sql_db return false; } } + function sql_escape_string($str) + { + return mysqli_real_escape_string($this->db_connect_id, $str); + } function sql_error($query_id = 0) { $result["message"] = mysqli_error($this->db_connect_id); From 144800719352bd4f94bc821b361c030409429452 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 6 Sep 2014 03:43:31 +0200 Subject: [PATCH 04/93] Make files folder safe to use --- code/web/public_php/ams/files/.htaccess | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 code/web/public_php/ams/files/.htaccess diff --git a/code/web/public_php/ams/files/.htaccess b/code/web/public_php/ams/files/.htaccess new file mode 100644 index 000000000..8c34c8164 --- /dev/null +++ b/code/web/public_php/ams/files/.htaccess @@ -0,0 +1,5 @@ +Options -Indexes + + ForceType application/octet-stream + Header set Content-Disposition attachment + From 3ee17121f9659b1534fa7eaeeacd7b0fce9e8df9 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 6 Sep 2014 03:44:58 +0200 Subject: [PATCH 05/93] Make files folder safe to use --- code/web/public_php/ams/files/.htaccess | 1 + 1 file changed, 1 insertion(+) diff --git a/code/web/public_php/ams/files/.htaccess b/code/web/public_php/ams/files/.htaccess index 8c34c8164..f3b08d726 100644 --- a/code/web/public_php/ams/files/.htaccess +++ b/code/web/public_php/ams/files/.htaccess @@ -1,4 +1,5 @@ Options -Indexes +Options -ExecCGI ForceType application/octet-stream Header set Content-Disposition attachment From afa6787100a03d9c05f7ea36bcebaac47fc9e034 Mon Sep 17 00:00:00 2001 From: botanic Date: Fri, 5 Sep 2014 18:46:13 -0700 Subject: [PATCH 06/93] Fix #189 --- code/web/private_php/ams/autoload/dblayer.php | 1 - .../web/public_php/ams/func/create_ticket.php | 44 +++++++++++++++---- code/web/public_php/ams/inc/createticket.php | 3 +- .../public_php/ams/templates/createticket.tpl | 12 ++--- 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/code/web/private_php/ams/autoload/dblayer.php b/code/web/private_php/ams/autoload/dblayer.php index 140f6bfd1..1f361008b 100644 --- a/code/web/private_php/ams/autoload/dblayer.php +++ b/code/web/private_php/ams/autoload/dblayer.php @@ -201,7 +201,6 @@ class DBLayer { $field_option_values = ltrim($field_option_values, ','); try { $sth = $this->PDO->prepare("UPDATE $tb_name SET $field_option_values WHERE $where "); - error_log("UPDATE $tb_name SET $field_option_values WHERE $where "); foreach ($data as $key => $value) { $sth->bindValue(":$key", $value); diff --git a/code/web/public_php/ams/func/create_ticket.php b/code/web/public_php/ams/func/create_ticket.php index cdc07cf8f..713d4f19f 100644 --- a/code/web/public_php/ams/func/create_ticket.php +++ b/code/web/public_php/ams/func/create_ticket.php @@ -9,8 +9,36 @@ function create_ticket(){ //if logged in global $INGAME_WEBPATH; global $WEBPATH; + $return = array(); + $error = false; if(WebUsers::isLoggedIn() && isset($_SESSION['ticket_user'])){ + + if(strlen (preg_replace('/\s\s+/', ' ', $_POST['Title']) )<2){ + $return = array_merge ( $_POST, $return); + $return['no_visible_elements'] = 'FALSE'; + $catArray = Ticket_Category::getAllCategories(); + $return['permission'] = unserialize( $_SESSION['ticket_user'] ) -> getPermission(); + $return['category'] = Gui_Elements::make_table_with_key_is_id($catArray, Array("getName"), "getTCategoryId" ); + $return['TITLE_ERROR_MESSAGE'] = "Title must not be blank!"; + $return['TITLE_ERROR'] = true; + $error = true; + } + if(strlen (preg_replace('/\s\s+/', ' ', $_POST['Content']) )<2){ + $return = array_merge ( $_POST, $return); + $return['no_visible_elements'] = 'FALSE'; + $catArray = Ticket_Category::getAllCategories(); + $return['permission'] = unserialize( $_SESSION['ticket_user'] ) -> getPermission(); + $return['category'] = Gui_Elements::make_table_with_key_is_id($catArray, Array("getName"), "getTCategoryId" ); + $return['CONTENT_ERROR_MESSAGE'] = "Content must not be blank!"; + $return['CONTENT_ERROR'] = true; + $error = true; + } + + if ($error) { + helpers :: loadTemplate( 'createticket' , $return ); + throw new SystemExit(); + } if(isset($_POST['target_id'])){ //if target_id is the same as session id or is admin @@ -31,19 +59,19 @@ function create_ticket(){ $ticket_id = Ticket::create_Ticket($title, $content, $category, $author, unserialize($_SESSION['ticket_user'])->getTUserId(),0, $_POST); //redirect to the new ticket. if (Helpers::check_if_game_client()) { - header("Cache-Control: max-age=1"); + header("Cache-Control: max-age=1"); header("Location: ".$INGAME_WEBPATH."?page=show_ticket&id=".$ticket_id); }else{ - header("Cache-Control: max-age=1"); + header("Cache-Control: max-age=1"); header("Location: ".$WEBPATH."?page=show_ticket&id=".$ticket_id); + throw new SystemExit(); } - throw new SystemExit(); - + }catch (PDOException $e) { //ERROR: LIB DB is not online! print_r($e); throw new SystemExit(); - header("Cache-Control: max-age=1"); + header("Cache-Control: max-age=1"); header("Location: index.php"); throw new SystemExit(); } @@ -58,13 +86,13 @@ function create_ticket(){ }else{ //ERROR: The form was not filled in correclty - header("Cache-Control: max-age=1"); - header("Location: index.php?page=create_ticket"); + header("Cache-Control: max-age=1"); + header("Location: index.php?page=createticket"); throw new SystemExit(); } }else{ //ERROR: user is not logged in - header("Cache-Control: max-age=1"); + header("Cache-Control: max-age=1"); header("Location: index.php"); throw new SystemExit(); } diff --git a/code/web/public_php/ams/inc/createticket.php b/code/web/public_php/ams/inc/createticket.php index 470bf3f5f..7a4dea3c2 100644 --- a/code/web/public_php/ams/inc/createticket.php +++ b/code/web/public_php/ams/inc/createticket.php @@ -44,11 +44,12 @@ function createticket(){ $result['category'] = Gui_Elements::make_table_with_key_is_id($catArray, Array("getName"), "getTCategoryId" ); global $INGAME_WEBPATH; $result['ingame_webpath'] = $INGAME_WEBPATH; + $result['TITLE_ERROR'] = $INGAME_WEBPATH; return $result; }else{ //ERROR: not logged in! - header("Cache-Control: max-age=1"); + header("Cache-Control: max-age=1"); header("Location: index.php"); throw new SystemExit(); } diff --git a/code/web/public_php/ams/templates/createticket.tpl b/code/web/public_php/ams/templates/createticket.tpl index fcf528ab8..40dee70f8 100644 --- a/code/web/public_php/ams/templates/createticket.tpl +++ b/code/web/public_php/ams/templates/createticket.tpl @@ -10,11 +10,12 @@
New ticket -
+
- + + {if isset($TITLE_ERROR) and $TITLE_ERROR eq "TRUE"}{$TITLE_ERROR_MESSAGE}{/if}
@@ -30,12 +31,13 @@
-
+
- -
+ + {if isset($CONTENT_ERROR) and $CONTENT_ERROR eq "TRUE"}{$CONTENT_ERROR_MESSAGE}{/if} +
From 702320a0ce135d4c8b47972c75565edaeaff4622 Mon Sep 17 00:00:00 2001 From: botanic Date: Fri, 5 Sep 2014 19:18:17 -0700 Subject: [PATCH 07/93] forgot $AMS_TMPDIR --- code/web/private_php/setup/config/config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/code/web/private_php/setup/config/config.php b/code/web/private_php/setup/config/config.php index a481cdf9d..4e2262f41 100644 --- a/code/web/private_php/setup/config/config.php +++ b/code/web/private_php/setup/config/config.php @@ -96,6 +96,7 @@ $AMS_LIB = $PRIVATE_PHP_PATH . '/ams'; $AMS_TRANS = $AMS_LIB . '/translations'; $AMS_CACHEDIR = $AMS_LIB . '/cache'; $AMS_PLUGINS = $AMS_LIB . '/plugins'; +$AMS_TMPDIR = $AMS_LIB . '/tmp'; // Here your inc and func resides $SITEBASE = $PUBLIC_PHP_PATH . '/ams/' ; From 72711ab92e9aa54aea3c0ce6a52ae47a9dc19136 Mon Sep 17 00:00:00 2001 From: botanic Date: Fri, 5 Sep 2014 19:26:12 -0700 Subject: [PATCH 08/93] throw error on non-writable file --- code/web/private_php/ams/autoload/sync.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/web/private_php/ams/autoload/sync.php b/code/web/private_php/ams/autoload/sync.php index 47d6cb61b..2aaf9b069 100644 --- a/code/web/private_php/ams/autoload/sync.php +++ b/code/web/private_php/ams/autoload/sync.php @@ -27,7 +27,11 @@ class Sync{ if(!file_exists($pidfile)) { $pid = getmypid(); $file = fopen($pidfile, 'w+'); - + if (!$file) + echo $pidfile.' is not writeable.'; + error_log($pidfile.' is not writeable.'); + throw new SystemExit(); + } fwrite($file, $pid); fclose($file); From d34f884d32fb3c80b5b83b1ceecd893f0ac48cbd Mon Sep 17 00:00:00 2001 From: botanic Date: Fri, 5 Sep 2014 19:38:53 -0700 Subject: [PATCH 09/93] fixed sync to be more robust --- code/web/private_php/ams/autoload/sync.php | 39 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/code/web/private_php/ams/autoload/sync.php b/code/web/private_php/ams/autoload/sync.php index 2aaf9b069..a3bf6fdb2 100644 --- a/code/web/private_php/ams/autoload/sync.php +++ b/code/web/private_php/ams/autoload/sync.php @@ -7,6 +7,11 @@ */ class Sync{ + const OS_UNKNOWN = 1; + const OS_WIN = 2; + const OS_LINUX = 3; + const OS_OSX = 4; + /** * performs the actions listed in the querycache. * All entries in the querycache will be read and performed depending on their type. @@ -24,10 +29,10 @@ class Sync{ if(isset($pid) and function_exists('pcntl_fork') ) { // We're the main process. } else { - if(!file_exists($pidfile)) { - $pid = getmypid(); + $pid = getmypid(); + if(!file_exists($pidfile) or (file_exists($pidfile) && Sync::check_pid(file_get_contents($pid)))) { $file = fopen($pidfile, 'w+'); - if (!$file) + if (!$file) { echo $pidfile.' is not writeable.'; error_log($pidfile.' is not writeable.'); throw new SystemExit(); @@ -94,4 +99,32 @@ class Sync{ } } + + public static function check_pid($pid){ + + $OS = Sync::getOS(); + + if ($OS == 2) { + $processes = explode( "\n", shell_exec( "tasklist.exe" )); + foreach( $processes as $process ) + { + if( strpos( "Image Name", $process ) === 0 + || strpos( "===", $process ) === 0 ) + continue; + $matches = false; + preg_match( "/(.*?)\s+(\d+).*$/", $process, $matches ); + $pid = $matches[ 2 ]; + } + } else { + return file_exists( "/proc/$pid" ); + } + } + static public function getOS() { + switch (true) { + case stristr(PHP_OS, 'DAR'): return self::OS_OSX; + case stristr(PHP_OS, 'WIN'): return self::OS_WIN; + case stristr(PHP_OS, 'LINUX'): return self::OS_LINUX; + default : return self::OS_UNKNOWN; + } + } } From d132e5ebb1412e2adfce817471e7fa58877f715b Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 6 Sep 2014 04:44:08 +0200 Subject: [PATCH 10/93] Add upgrade script --- code/web/public_php/setup/install.php | 2 - code/web/public_php/setup/upgrade.php | 99 +++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 code/web/public_php/setup/upgrade.php diff --git a/code/web/public_php/setup/install.php b/code/web/public_php/setup/install.php index 456018c5d..f8dfbdab2 100644 --- a/code/web/public_php/setup/install.php +++ b/code/web/public_php/setup/install.php @@ -133,8 +133,6 @@ include('header.php'); $config = str_replace("%amsSqlPassword%", addslashes($_POST["amsSqlPassword"]), $config); $config = str_replace("%amsDatabase%", addslashes($_POST["amsDatabase"]), $config); $config = str_replace("%amsLibDatabase%", addslashes($_POST["amsLibDatabase"]), $config); - $config = str_replace("%amsAdminUsername%", addslashes($_POST["amsAdminUsername"]), $config); - $config = str_replace("%amsAdminPassword%", addslashes($_POST["amsAdminPassword"]), $config); $config = str_replace("%nelSetupPassword%", addslashes($_POST["nelSetupPassword"]), $config); $config = str_replace("%domainDatabase%", addslashes($_POST["domainDatabase"]), $config); $config = str_replace("%nelDomainName%", addslashes($_POST["nelDomainName"]), $config); diff --git a/code/web/public_php/setup/upgrade.php b/code/web/public_php/setup/upgrade.php new file mode 100644 index 000000000..f8cebb9e2 --- /dev/null +++ b/code/web/public_php/setup/upgrade.php @@ -0,0 +1,99 @@ + + +
+ + + +config.php"); + $continue = false; + } else { + $cwd = getcwd(); + $config = str_replace("%privatePhpDirectory%", addslashes($PRIVATE_PHP_PATH), $config); + $config = str_replace("%publicPhpDirectory%", addslashes($PUBLIC_PHP_PATH), $config); + $config = str_replace("%nelSqlHostname%", addslashes($cfg['db']['shard']['host']), $config); + $config = str_replace("%nelSqlUsername%", addslashes($cfg['db']['shard']['user']), $config); + $config = str_replace("%nelSqlPassword%", addslashes($cfg['db']['shard']['pass']), $config); + $config = str_replace("%nelDatabase%", addslashes($cfg['db']['shard']['name']), $config); + $config = str_replace("%toolDatabase%", addslashes($cfg['db']['tool']['name']), $config); + $config = str_replace("%amsSqlHostname%", addslashes($cfg['db']['lib']['host']), $config); + $config = str_replace("%amsSqlUsername%", addslashes($cfg['db']['lib']['user']), $config); + $config = str_replace("%amsSqlPassword%", addslashes($cfg['db']['lib']['pass']), $config); + $config = str_replace("%amsDatabase%", addslashes($cfg['db']['web']['name']), $config); + $config = str_replace("%amsLibDatabase%", addslashes($cfg['db']['lib']['name']), $config); + $config = str_replace("%nelSetupPassword%", addslashes($NEL_SETUP_PASSWORD), $config); + // $config = str_replace("%domainDatabase%", addslashes($_POST["domainDatabase"]), $config); // TODO + $config = str_replace("%nelDomainName%", addslashes($NEL_DOMAIN_NAME), $config); + if (file_put_contents("config.php", $config)) { + printalert("success", "Generated config.php"); + } else { + printalert("danger", "Cannot write to config.php"); + $continue = false; + } + } + } + + require_once('database.php'); + + if (file_exists("role_support")) { + $continue = upgrade_support_databases($continue); + } + + if (file_exists("role_service")) { + $continue = upgrade_service_databases($continue); + } + + if (file_exists("role_domain")) { + $continue = upgrade_domain_databases($continue); + } + +?> + +

+ Continue +

+ + + +
+
Backup
+
+ It is strongly recommended to create a backup of your installation before proceeding with an upgrade! +
+
+ + +
+ +
+ + + + +
+ + From 186da3c0fab595151b4da64ff19b5c8ea1fb2439 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 6 Sep 2014 04:55:17 +0200 Subject: [PATCH 11/93] Saner behaviour to show Forbidden error --- code/web/public_php/ams/files/.htaccess | 1 + 1 file changed, 1 insertion(+) diff --git a/code/web/public_php/ams/files/.htaccess b/code/web/public_php/ams/files/.htaccess index f3b08d726..655df6494 100644 --- a/code/web/public_php/ams/files/.htaccess +++ b/code/web/public_php/ams/files/.htaccess @@ -1,5 +1,6 @@ Options -Indexes Options -ExecCGI +DirectoryIndex disabled ForceType application/octet-stream Header set Content-Disposition attachment From 67d5ec373e899ab52a23ceecb886c906a5375690 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 6 Sep 2014 06:40:33 +0200 Subject: [PATCH 12/93] Now really, don't execute any scripts here --- code/web/public_php/ams/files/.htaccess | 1 + 1 file changed, 1 insertion(+) diff --git a/code/web/public_php/ams/files/.htaccess b/code/web/public_php/ams/files/.htaccess index 655df6494..6e11c1a83 100644 --- a/code/web/public_php/ams/files/.htaccess +++ b/code/web/public_php/ams/files/.htaccess @@ -1,3 +1,4 @@ +SetHandler default-handler Options -Indexes Options -ExecCGI DirectoryIndex disabled From 6763d9699213c14cd553fd2d0e3e0dc5b80fd1da Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 6 Sep 2014 06:49:42 +0200 Subject: [PATCH 13/93] Add more paranoia --- code/web/public_php/ams/files/.htaccess | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/code/web/public_php/ams/files/.htaccess b/code/web/public_php/ams/files/.htaccess index 6e11c1a83..65a3a44db 100644 --- a/code/web/public_php/ams/files/.htaccess +++ b/code/web/public_php/ams/files/.htaccess @@ -1,8 +1,20 @@ +SetHandler none SetHandler default-handler -Options -Indexes Options -ExecCGI + + php_flag engine off + +RemoveHandler .cgi .php .php3 .php4 .php5 .phtml .pl .py .pyc .pyo +Options -Indexes DirectoryIndex disabled - + + SetHandler none + SetHandler default-handler + Options -ExecCGI + + php_flag engine off + + RemoveHandler .cgi .php .php3 .php4 .php5 .phtml .pl .py .pyc .pyo ForceType application/octet-stream Header set Content-Disposition attachment From 9211037a54061fc661a052bcd28ce30107560851 Mon Sep 17 00:00:00 2001 From: botanic Date: Fri, 5 Sep 2014 22:24:09 -0700 Subject: [PATCH 14/93] fix missing pcntl_fork func --- code/web/private_php/ams/autoload/mail_handler.php | 6 +++++- code/web/private_php/ams/autoload/support_group.php | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/code/web/private_php/ams/autoload/mail_handler.php b/code/web/private_php/ams/autoload/mail_handler.php index 66cb0f95d..c57b93250 100644 --- a/code/web/private_php/ams/autoload/mail_handler.php +++ b/code/web/private_php/ams/autoload/mail_handler.php @@ -16,7 +16,11 @@ class Mail_Handler{ */ private function mail_fork() { //Start a new child process and return the process id! - $pid = pcntl_fork(); + if (function_exists('pcntl_fork')) { + $pid = pcntl_fork(); + } else { + $pid = getmypid (); + } return $pid; } diff --git a/code/web/private_php/ams/autoload/support_group.php b/code/web/private_php/ams/autoload/support_group.php index ed3c5daf5..f776471ae 100644 --- a/code/web/private_php/ams/autoload/support_group.php +++ b/code/web/private_php/ams/autoload/support_group.php @@ -60,10 +60,10 @@ class Support_Group{ * @return a string that specifies if it was a success or not (SUCCESS, SIZE_ERROR, NAME_TAKEN or TAG_TAKEN ) */ public static function createSupportGroup( $name, $tag, $groupemail, $imap_mailserver, $imap_username, $imap_password) { - error_log( "Error at line " . __LINE__ . " in file " . __FILE__); + //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); if(strlen($name) <= 21 && strlen($name) >= 4 &&strlen($tag) <= 8 && strlen($tag) >= 2 ){ $notExists = self::supportGroup_EntryNotExists($name, $tag); - error_log( "Error at line " . __LINE__ . " in file " . __FILE__); + //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); if ( $notExists == "SUCCESS" ){ $sGroup = new self(); $values = array('Name' => $name, 'Tag' => $tag, 'GroupEmail' => $groupemail, 'IMAP_MailServer' => $imap_mailserver, 'IMAP_Username' => $imap_username, 'IMAP_Password' => $imap_password); @@ -80,14 +80,14 @@ class Support_Group{ $sGroup->setIMAP_Password($enc_password); $sGroup->create(); - error_log( "Error at line " . __LINE__ . " in file " . __FILE__); + //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); }else{ - error_log( "Error at line " . __LINE__ . " in file " . __FILE__); + //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); //return NAME_TAKEN or TAG_TAKEN return $notExists; } }else{ - error_log( "Error at line " . __LINE__ . " in file " . __FILE__); + //error_log( "Error at line " . __LINE__ . " in file " . __FILE__); //RETURN ERROR that indicates SIZE return "SIZE_ERROR"; } From 667fa78aab839668e2226ee949c71bc8089436a9 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 6 Sep 2014 20:56:06 +0200 Subject: [PATCH 15/93] This should fix #193 --- code/web/public_php/admin/functions_auth.php | 62 ++++++++++++-------- code/web/public_php/setup/header.php | 2 +- code/web/public_php/setup/index.php | 4 +- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/code/web/public_php/admin/functions_auth.php b/code/web/public_php/admin/functions_auth.php index b56a12064..e65b90e83 100644 --- a/code/web/public_php/admin/functions_auth.php +++ b/code/web/public_php/admin/functions_auth.php @@ -1,8 +1,8 @@ display('index_login.tpl'); } - function nt_auth_start_session() + function nt_auth_start_session() { + global $NEL_SETUP_SESSION; + if (isset($NEL_SETUP_SESSION) && ($NEL_SETUP_SESSION)) { + return; + } + session_name(NELTOOL_SESSIONID); session_cache_limiter('nocache'); session_start(); - header("Expires: Mon, 01 May 2000 06:00:00 GMT"); - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); - header("Cache-Control: no-store, no-cache, must-revalidate"); - header("Cache-Control: post-check=0, pre-check=0", false); - header("Pragma: no-cache"); + header("Expires: Mon, 01 May 2000 06:00:00 GMT"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); + header("Cache-Control: no-store, no-cache, must-revalidate"); + header("Cache-Control: post-check=0, pre-check=0", false); + header("Pragma: no-cache"); } - function nt_auth_stop_session() + function nt_auth_stop_session() + { + global $NEL_SETUP_SESSION; + if (isset($NEL_SETUP_SESSION) && ($NEL_SETUP_SESSION)) { + return; + } + + global $NELTOOL; + + foreach($NELTOOL['SESSION_VARS'] as $key => $val) + { + unset($NELTOOL['SESSION_VARS'][$key]); + } + } + + function nt_auth_set_session_var($name,$value) { global $NELTOOL; - foreach($NELTOOL['SESSION_VARS'] as $key => $val) - { - unset($NELTOOL['SESSION_VARS'][$key]); - } - } - - function nt_auth_set_session_var($name,$value) - { - global $NELTOOL; - - $NELTOOL['SESSION_VARS'][$name] = $value; + $NELTOOL['SESSION_VARS'][$name] = $value; } function nt_auth_get_session_var($name) { - global $NELTOOL; + global $NELTOOL; - if (isset($NELTOOL['SESSION_VARS'][$name])) return $NELTOOL['SESSION_VARS'][$name]; - return null; + if (isset($NELTOOL['SESSION_VARS'][$name])) return $NELTOOL['SESSION_VARS'][$name]; + return null; } - function nt_auth_unset_session_var($name) + function nt_auth_unset_session_var($name) { - global $NELTOOL; + global $NELTOOL; - unset($NELTOOL['SESSION_VARS'][$name]); + unset($NELTOOL['SESSION_VARS'][$name]); } ?> diff --git a/code/web/public_php/setup/header.php b/code/web/public_php/setup/header.php index 317637ef8..a93fd85c1 100644 --- a/code/web/public_php/setup/header.php +++ b/code/web/public_php/setup/header.php @@ -1,7 +1,7 @@ Add Domain

--> -

+ From 500aa9fbfc281af7cbd8e0ba40dbeabeea535dec Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 6 Sep 2014 20:59:21 +0200 Subject: [PATCH 16/93] Syntax styling --- code/web/public_php/admin/functions_auth.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/code/web/public_php/admin/functions_auth.php b/code/web/public_php/admin/functions_auth.php index e65b90e83..6f478bbc9 100644 --- a/code/web/public_php/admin/functions_auth.php +++ b/code/web/public_php/admin/functions_auth.php @@ -1,8 +1,8 @@ assign('tool_login_title','Login'); + $tpl->assign('tool_login_title', 'Login'); $tpl->display('index_login.tpl'); } function nt_auth_start_session() { global $NEL_SETUP_SESSION; - if (isset($NEL_SETUP_SESSION) && ($NEL_SETUP_SESSION)) { + if (isset($NEL_SETUP_SESSION) && ($NEL_SETUP_SESSION)) + { return; } @@ -87,7 +88,7 @@ session_start(); header("Expires: Mon, 01 May 2000 06:00:00 GMT"); - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); + header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); @@ -96,7 +97,8 @@ function nt_auth_stop_session() { global $NEL_SETUP_SESSION; - if (isset($NEL_SETUP_SESSION) && ($NEL_SETUP_SESSION)) { + if (isset($NEL_SETUP_SESSION) && ($NEL_SETUP_SESSION)) + { return; } @@ -108,7 +110,7 @@ } } - function nt_auth_set_session_var($name,$value) + function nt_auth_set_session_var($name, $value) { global $NELTOOL; From 82d910326377017b3f1d7a031de81b40b13cfcde Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 6 Sep 2014 21:25:07 +0200 Subject: [PATCH 17/93] This might fix #193 --- code/web/public_php/admin/common.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/web/public_php/admin/common.php b/code/web/public_php/admin/common.php index caf90a812..1ddecc2d9 100644 --- a/code/web/public_php/admin/common.php +++ b/code/web/public_php/admin/common.php @@ -8,6 +8,9 @@ require_once('config.php'); + if (isset($NEL_SETUP_SESSION) && ($NEL_SETUP_SESSION)) + define('NELTOOL_NO_USER_NEEDED', true); + require_once(NELTOOL_SYSTEMBASE .'functions_common.php'); require_once(NELTOOL_SYSTEMBASE .'functions_auth.php'); @@ -139,11 +142,11 @@ { $default_user_application_id = 0; if (isset( $nel_user['user_default_application_id']) &&($nel_user['user_default_application_id'] > 0)) { - $default_user_application_id = $nel_user['user_default_application_id']; + $default_user_application_id = $nel_user['user_default_application_id']; }elseif (isset( $nel_user['group_default_application_id']) &&($nel_user['group_default_application_id'] > 0)) { $default_user_application_id = $nel_user['group_default_application_id']; } - + if ($default_user_application_id > 0) { nt_common_add_debug("default application : user:". $nel_user['user_default_application_id'] ." group:". $nel_user['group_default_application_id']); From b4f4eddd1242824894941e9be956f4b3251d5621 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 7 Sep 2014 03:43:00 +0200 Subject: [PATCH 18/93] Add login configuration --- code/web/private_php/ams/autoload/dblayer.php | 7 +- code/web/private_php/setup/config/config.php | 91 +++++++++++-------- .../private_php/setup/config/config_user.php | 18 ++++ code/web/public_php/login/config.php | 32 +++++++ code/web/public_php/setup/install.php | 20 ++++ code/web/public_php/setup/upgrade.php | 59 +++++++++--- code/web/public_php/setup/version.php | 6 ++ code/web/todo_cfg/login/config.php | 27 ------ 8 files changed, 181 insertions(+), 79 deletions(-) create mode 100644 code/web/private_php/setup/config/config_user.php create mode 100644 code/web/public_php/login/config.php create mode 100644 code/web/public_php/setup/version.php delete mode 100644 code/web/todo_cfg/login/config.php diff --git a/code/web/private_php/ams/autoload/dblayer.php b/code/web/private_php/ams/autoload/dblayer.php index 1f361008b..da3a757a6 100644 --- a/code/web/private_php/ams/autoload/dblayer.php +++ b/code/web/private_php/ams/autoload/dblayer.php @@ -48,8 +48,11 @@ class DBLayer { * @param $db String, the name of the databases entry in the $cfg global var. * @param $dbn String, the name of the databases entry in the $cfg global var if $db referenced to an action(install etc). */ - function __construct($db, $dbn = null) - { + function __construct($db, $dbn = null) { + if ($db == "ring" && $dbn == null) { + throw new Exception("Domain database access from AMS must have database name specified"); + } + global $cfg; // $this->host = $cfg['db'][$db]['host']; // $this->dbname = $cfg['db'][$db]['name']; diff --git a/code/web/private_php/setup/config/config.php b/code/web/private_php/setup/config/config.php index 4e2262f41..699b76979 100644 --- a/code/web/private_php/setup/config/config.php +++ b/code/web/private_php/setup/config/config.php @@ -4,6 +4,10 @@ * @author Daan Janssens, mentored by Matthew Lagoe */ +// WARNING: Do not modify this manually on your web server, it will be +// overwritten by the upgrade process. Instead, add overrides to the +// config_user.php file. + // Variables for database access to the www/CMS database (only if support role) $cfg['db']['web']['host'] = '%amsSqlHostname%'; $cfg['db']['web']['port'] = '3306'; @@ -19,25 +23,25 @@ $cfg['db']['lib']['user'] = '%amsSqlUsername%'; $cfg['db']['lib']['pass'] = '%amsSqlPassword%'; // Variables for database access to the shard database -$cfg['db']['shard']['host'] = '%nelSqlHostname%'; -$cfg['db']['shard']['port'] = '3306'; -$cfg['db']['shard']['name'] = '%nelDatabase%'; -$cfg['db']['shard']['user'] = '%nelSqlUsername%'; -$cfg['db']['shard']['pass'] = '%nelSqlPassword%'; +$cfg['db']['shard']['host'] = '%nelSqlHostname%'; +$cfg['db']['shard']['port'] = '3306'; +$cfg['db']['shard']['name'] = '%nelDatabase%'; +$cfg['db']['shard']['user'] = '%nelSqlUsername%'; +$cfg['db']['shard']['pass'] = '%nelSqlPassword%'; // Variables for database access to the ring_open database (only if domain role) -// $cfg['db']['ring']['host'] = '%nelSqlHostname%'; -// $cfg['db']['ring']['port'] = '3306'; -// $cfg['db']['ring']['name'] = '%domainDatabase%'; -// $cfg['db']['ring']['user'] = '%nelSqlUsername%'; -// $cfg['db']['ring']['pass'] = '%nelSqlPassword%'; +$cfg['db']['ring']['host'] = '%nelSqlHostname%'; +$cfg['db']['ring']['port'] = '3306'; +$cfg['db']['ring']['name'] = '%domainDatabase%'; +$cfg['db']['ring']['user'] = '%nelSqlUsername%'; +$cfg['db']['ring']['pass'] = '%nelSqlPassword%'; // Variables for database access to the nel_tool database (only if service role) -$cfg['db']['tool']['host'] = '%nelSqlHostname%'; -$cfg['db']['tool']['port'] = '3306'; -$cfg['db']['tool']['name'] = '%toolDatabase%'; -$cfg['db']['tool']['user'] = '%nelSqlUsername%'; -$cfg['db']['tool']['pass'] = '%nelSqlPassword%'; +$cfg['db']['tool']['host'] = '%nelSqlHostname%'; +$cfg['db']['tool']['port'] = '3306'; +$cfg['db']['tool']['name'] = '%toolDatabase%'; +$cfg['db']['tool']['user'] = '%nelSqlUsername%'; +$cfg['db']['tool']['pass'] = '%nelSqlPassword%'; // To connect to an IMAP server running on port 143 on the local machine, // do the following: $mbox = imap_open("{localhost:143}INBOX", "user_id", "password"); @@ -50,21 +54,21 @@ $cfg['db']['tool']['pass'] = '%nelSqlPassword%'; // To connect to a remote server replace "localhost" with the name or the IP address of the server you want to connect to. //$cfg['mail']['server'] = '{localhost:110/pop3/novalidate-cert}INBOX'; -//imap connection string as explained above +// IMAP connection string as explained above $cfg['mail']['default_mailserver']= '{imap.gmail.com:993/imap/ssl}INBOX'; -//groupemail is the email that sends the email -$cfg['mail']['default_groupemail'] = 'example@gmail.com'; -//groupname will be the name displayed as sender +// The email address that sends the email +$cfg['mail']['default_groupemail'] = 'support@ryzomcore.org'; +// Name displayed as sender $cfg['mail']['default_groupname'] = 'Ryzom Core Support'; -//the username of the account -$cfg['mail']['default_username'] = 'example@gmail.com'; -//the matching password +// Username of the account +$cfg['mail']['default_username'] = 'support@ryzomcore.org'; +// Password of the account $cfg['mail']['default_password'] = 'passw0rd'; -//the host, being used when a mail is sent from a support group: support_groups_name@host -$cfg['mail']['host'] = "ryzomcore.com"; +// The host, being used when a mail is sent from a support group: support_groups_name@host +$cfg['mail']['host'] = "ryzomcore.org"; //Defines mailing related stuff -$SUPPORT_GROUP_IMAP_CRYPTKEY = "azerty"; +$SUPPORT_GROUP_IMAP_CRYPTKEY = '%cryptKeyIMAP%'; $TICKET_MAILING_SUPPORT = false; //You have to create this dir at first! @@ -76,16 +80,16 @@ $MAIL_LOG_PATH = "/home/username/mail/cron_mail.log"; $TOS_URL ="http://www.gnu.org/licenses/agpl-3.0.html"; //crypt is being used by encrypting & decrypting of the IMAP password of the supportgroups -$cfg['crypt']['key'] = 'Sup3rS3cr3tStuff'; +$cfg['crypt']['key'] = '%cryptKey%'; $cfg['crypt']['enc_method'] = 'AES-256-CBC'; $cfg['crypt']['hash_method'] = "SHA512"; //----------------------------------------------------------------------------------------- -// If true= the server will add automatically unknown user in the database -// (in nel.user= nel.permission= ring.ring_user and ring.characters -$ALLOW_UNKNOWN = true ; -// if true= the login service automaticaly create a ring user and a editor character if needed -$CREATE_RING = true ; +// If true, the server will add automatically unknown user in the database +// (in nel.user, nel.permission, ring.ring_user and ring.characters +$ALLOW_UNKNOWN = false; +// If true, the login service automaticaly create a ring user and a editor character if needed +$CREATE_RING = true; // PHP server paths $PUBLIC_PHP_PATH = "%publicPhpDirectory%"; @@ -100,29 +104,29 @@ $AMS_TMPDIR = $AMS_LIB . '/tmp'; // Here your inc and func resides $SITEBASE = $PUBLIC_PHP_PATH . '/ams/' ; -//the paths to your website url +// The paths to your website url $BASE_WEBPATH = '/ams/'; $IMAGELOC_WEBPATH = $BASE_WEBPATH . 'img'; $WEBPATH = $BASE_WEBPATH . 'index.php'; $INGAME_WEBPATH = $BASE_WEBPATH . 'index.php'; $CONFIG_PATH = $PUBLIC_PHP_PATH; -//defines the default language +// Defines the default language $DEFAULT_LANGUAGE = 'en'; -//defines if logging actions should happen or not. +// Defines if logging actions should happen or not. $TICKET_LOGGING = true; -//defines the time format display +// Defines the time format display $TIME_FORMAT = "m-d-Y H:i:s"; -//defines which ingame layout template should be used +// Defines which ingame layout template should be used $INGAME_LAYOUT = "basic"; -//forces to load the ingame templates if set to true +// Forces to load the ingame templates if set to true $FORCE_INGAME = false; -//file storage path (must be a publicly accessible url for +// File storage path (must be a publicly accessible url) $FILE_STORAGE_PATH = $PUBLIC_PHP_PATH . '/ams/files/'; $FILE_WEB_PATH = $BASE_WEBPATH . 'files/'; @@ -131,3 +135,14 @@ $NEL_SETUP_PASSWORD = '%nelSetupPassword%'; // Name of current domain (only if domain role) $NEL_DOMAIN_NAME = '%nelDomainName%'; + +// Currently configured setup version +$NEL_SETUP_VERSION_CONFIGURED = %nelSetupVersion%; + +// Get installed version +require_once('setup/version.php'); + +// Override user parameters +require_once('config_user.php'); + +/* end of file */ diff --git a/code/web/private_php/setup/config/config_user.php b/code/web/private_php/setup/config/config_user.php new file mode 100644 index 000000000..916adc7c3 --- /dev/null +++ b/code/web/private_php/setup/config/config_user.php @@ -0,0 +1,18 @@ + diff --git a/code/web/public_php/setup/install.php b/code/web/public_php/setup/install.php index f8dfbdab2..57f7938bb 100644 --- a/code/web/public_php/setup/install.php +++ b/code/web/public_php/setup/install.php @@ -136,6 +136,11 @@ include('header.php'); $config = str_replace("%nelSetupPassword%", addslashes($_POST["nelSetupPassword"]), $config); $config = str_replace("%domainDatabase%", addslashes($_POST["domainDatabase"]), $config); $config = str_replace("%nelDomainName%", addslashes($_POST["nelDomainName"]), $config); + $cryptKeyLength = 16; + $cryptKey = str_replace("=", "", base64_encode(mcrypt_create_iv(ceil(0.75 * $cryptKeyLength), MCRYPT_DEV_URANDOM))); + $cryptKeyIMAP = str_replace("=", "", base64_encode(mcrypt_create_iv(ceil(0.75 * $cryptKeyLength), MCRYPT_DEV_URANDOM))); + $config = str_replace("%cryptKey%", addslashes($cryptKey), $config); + $config = str_replace("%cryptKeyIMAP%", addslashes($cryptKeyIMAP), $config); if (file_put_contents("config.php", $config)) { printalert("success", "Generated config.php"); } else { @@ -145,6 +150,21 @@ include('header.php'); } } + if ($continue) { + $configUser = file_get_contents($_POST["privatePhpDirectory"] . "/setup/config/config_user.php"); + if (!$config) { + printalert("danger", "Cannot read config_user.php"); + $continue = false; + } else { + if (file_put_contents("config_user.php", $config)) { + printalert("success", "Copied config_user.php"); + } else { + printalert("danger", "Cannot write to config.php"); + $continue = false; + } + } + } + // Load config if ($continue) { try { diff --git a/code/web/public_php/setup/upgrade.php b/code/web/public_php/setup/upgrade.php index f8cebb9e2..9e5cf33a5 100644 --- a/code/web/public_php/setup/upgrade.php +++ b/code/web/public_php/setup/upgrade.php @@ -10,6 +10,10 @@ $pageTitle = "Upgrade"; include('header.php'); require_once('config.php'); +require_once('setup/version.php'); +if (!isset($NEL_SETUP_VERSION_CONFIGURED)) { + $NEL_SETUP_VERSION_CONFIGURED = 1; +} ?> @@ -19,6 +23,24 @@ require_once('config.php'); config.php"); } else { @@ -50,18 +79,24 @@ require_once('config.php'); } } - require_once('database.php'); - - if (file_exists("role_support")) { - $continue = upgrade_support_databases($continue); + // Create config_user.php if it doesn't exist yet + if ($continue && !file_exists("config_user.php")) { + $configUser = file_get_contents($_POST["privatePhpDirectory"] . "/setup/config/config_user.php"); + if (!$config) { + printalert("danger", "Cannot read config_user.php"); + $continue = false; + } else { + if (file_put_contents("config_user.php", $config)) { + printalert("success", "Copied config_user.php"); + } else { + printalert("danger", "Cannot write to config.php"); + $continue = false; + } + } } - if (file_exists("role_service")) { - $continue = upgrade_service_databases($continue); - } - - if (file_exists("role_domain")) { - $continue = upgrade_domain_databases($continue); + if ($continue) { + printalert("success", "Upgrade complete"); } ?> @@ -70,7 +105,7 @@ require_once('config.php'); Continue

- +
Backup
diff --git a/code/web/public_php/setup/version.php b/code/web/public_php/setup/version.php new file mode 100644 index 000000000..67ccd7243 --- /dev/null +++ b/code/web/public_php/setup/version.php @@ -0,0 +1,6 @@ + From aebcf606edd41c0d98d1e33b2c85d781d9a6b2d8 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 7 Sep 2014 03:47:55 +0200 Subject: [PATCH 19/93] Bugfix --- code/web/public_php/setup/header.php | 1 + 1 file changed, 1 insertion(+) diff --git a/code/web/public_php/setup/header.php b/code/web/public_php/setup/header.php index a93fd85c1..b937c6913 100644 --- a/code/web/public_php/setup/header.php +++ b/code/web/public_php/setup/header.php @@ -2,6 +2,7 @@ $NEL_SETUP_SESSION = true; if (file_exists( '../config.php')) { + session_start(); if ((!isset($_SESSION['nelSetupAuthenticated'])) || $_SESSION['nelSetupAuthenticated'] != 1) { if (basename($_SERVER["SCRIPT_NAME"]) != "auth.php") { header("Cache-Control: max-age=1"); From c938c18f352c7b3824f97759df0894a186d73868 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 7 Sep 2014 03:51:10 +0200 Subject: [PATCH 20/93] Bugfix --- code/web/public_php/setup/install.php | 4 ++-- code/web/public_php/setup/upgrade.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/web/public_php/setup/install.php b/code/web/public_php/setup/install.php index 57f7938bb..cc9972f8d 100644 --- a/code/web/public_php/setup/install.php +++ b/code/web/public_php/setup/install.php @@ -152,11 +152,11 @@ include('header.php'); if ($continue) { $configUser = file_get_contents($_POST["privatePhpDirectory"] . "/setup/config/config_user.php"); - if (!$config) { + if (!$configUser) { printalert("danger", "Cannot read config_user.php"); $continue = false; } else { - if (file_put_contents("config_user.php", $config)) { + if (file_put_contents("config_user.php", $configUser)) { printalert("success", "Copied config_user.php"); } else { printalert("danger", "Cannot write to config.php"); diff --git a/code/web/public_php/setup/upgrade.php b/code/web/public_php/setup/upgrade.php index 9e5cf33a5..b29c04e2c 100644 --- a/code/web/public_php/setup/upgrade.php +++ b/code/web/public_php/setup/upgrade.php @@ -81,12 +81,12 @@ if (!isset($NEL_SETUP_VERSION_CONFIGURED)) { // Create config_user.php if it doesn't exist yet if ($continue && !file_exists("config_user.php")) { - $configUser = file_get_contents($_POST["privatePhpDirectory"] . "/setup/config/config_user.php"); - if (!$config) { + $configUser = file_get_contents($PRIVATE_PHP_PATH . "/setup/config/config_user.php"); + if (!$configUser) { printalert("danger", "Cannot read config_user.php"); $continue = false; } else { - if (file_put_contents("config_user.php", $config)) { + if (file_put_contents("config_user.php", $configUser)) { printalert("success", "Copied config_user.php"); } else { printalert("danger", "Cannot write to config.php"); From 70eb2d7bee5958f6847ab0e68df2db4452018674 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 7 Sep 2014 04:16:07 +0200 Subject: [PATCH 21/93] Cleanup some English AMS translations --- code/web/private_php/ams/translations/en.ini | 80 ++++++++++---------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/code/web/private_php/ams/translations/en.ini b/code/web/private_php/ams/translations/en.ini index ca199831c..8256427a3 100644 --- a/code/web/private_php/ams/translations/en.ini +++ b/code/web/private_php/ams/translations/en.ini @@ -1,10 +1,6 @@ ; This is a sample configuration file ; Comments start with ';', as in php.ini -[install] -login_info = "Please enter your MySQL Username and Password to install the database.
This is being loaded because the is_installed file is missing.
This process will take about 30 seconds." -login_here = "here" - [ams_content] ams_title="Ryzom Account Mangement System" @@ -58,13 +54,13 @@ action = "Action" [plugins] plugin_title = "Plugin List" -plugin_info = "Here you can see the entire list of plugins . You can easily remove plugins ,activate them and add permissions" +plugin_info = "Here you can see the entire list of plugins. You can easily remove plugins, activate them, and add permissions." plugins = "Plugins" plugin_name = "Name" plugin_version = "Version" plugin_description = "Description" plugin_type = "Type" -plugin_permission = "Access
Permission" +plugin_permission = "Access
Permission" plugin_status = "Status" ip_success = "Plugin added succesfuly." plugin_actions = "Actions" @@ -101,40 +97,40 @@ t_fill = "Fill in your reply" t_send = "Send reply" invalid_sgroup = "Invalid support group!" ticket_not_existing = "That's an invalid ticket" -success_forwarded = "The ticket was forwarded successfully!" +success_forwarded = "The ticket was forwarded successfully." public_sgroup = "Public" not_assigned = "None" -success_assigned = "The ticket was successfully assigned!" -success_unassigned = "The ticket was successfully unassigned!" -ticket_not_existing = "That ticket doesn't exist!" -ticket_already_assigned = "That ticket is already assigned to someone!" +success_assigned = "The ticket was successfully assigned." +success_unassigned = "The ticket was successfully unassigned." +ticket_not_existing = "That ticket doesn't exist." +ticket_already_assigned = "That ticket is already assigned to someone." [show_user] [show_queue] not_assigned = "Open" -success_assigned = "The ticket was successfully assigned!" -success_unassigned = "The ticket was successfully unassigned!" -ticket_not_existing = "That ticket doesn't exist!" -ticket_already_assigned = "That ticket is already assigned to someone!" -ticket_not_assigned = "That ticket isn't assigned to you!" +success_assigned = "The ticket was successfully assigned." +success_unassigned = "The ticket was successfully unassigned." +ticket_not_existing = "That ticket doesn't exist." +ticket_already_assigned = "That ticket is already assigned to someone." +ticket_not_assigned = "That ticket isn't assigned to you." public_sgroup = "Public" [show_sgroup] -add_to_group_success = "The user has been added to the group!" -user_already_added = "The user is already part of the group!" -group_not_existing = "The group doesn't exist!" -user_not_existing = "The user doesn't seem to exist" -not_mod_or_admin = "You can only add Moderators or Admins!" -modify_mail_of_group_success = "The Support Group's email settings have been modified!" -email_not_valid = "The group email address is invalid!" -no_password_given = "Be aware that there was no password filled in, so the password is empty atm!" +add_to_group_success = "The user has been added to the group." +user_already_added = "The user is already part of the group." +group_not_existing = "The group doesn't exist." +user_not_existing = "The user doesn't seem to exist." +not_mod_or_admin = "You can only add Moderators or Admins." +modify_mail_of_group_success = "The Support Group's email settings have been modified." +email_not_valid = "The group email address is invalid." +no_password_given = "Be aware that there was no password filled in, so the password is currently empty." [sgroup_list] -group_success = "The group has been created!" -group_name_taken = "The groupname was already used!" -group_tag_taken = "The tag was already used!" -group_size_error = "The name has to be between 4-20 chars and the tag between 2-4!" +group_success = "The group has been created." +group_name_taken = "The groupname was already used." +group_tag_taken = "The tag was already used." +group_size_error = "The name has to be between 4-20 chars and the tag between 2-4." [createticket] @@ -157,34 +153,34 @@ group_size_error = "The name has to be between 4-20 chars and the tag between 2- 10= "added attachment" [error] -title404 = "Not
Found!" -title403 = "Forbidden!" -error_message404 = "This is not the page you are looking for.." -error_message403 = "You cannot access this page!" +title404 = "Not
Found" +title403 = "Forbidden" +error_message404 = "This is not the page you are looking for." +error_message403 = "You cannot access this page." go_home = "Go Home" [userlist] userlist_info = "welcome to the userlist" [login] -login_info = "Please login with your Email/Username and Password." -login_error_message = "The Email/username/password were not correct!" -login_register_message ="Register If you don't have an account yet, create one" -login_here = "here" -login_forgot_password_message = "In case you forgot your password, click" +login_info = "Please login with your user name (or email) and password." +login_error_message = "Create a new account" +login_register_message ="Register" +login_here = "I forgot my password" +login_forgot_password_message = "" [logout] -logout_message = "You've been logged out successfully!" +logout_message = "You've been logged out successfully." login_title = "Login" login_timer = "You will be redirected to the login page in " -login_text = "Or click here if you don't want to wait!" +login_text = "Or click here if you don't want to wait." [reset_success] -reset_success_message = "You've changed the password succesfully!" +reset_success_message = "You've changed the password succesfully." reset_success_title = "Login" reset_success_timer = "You will be redirected to the login page in " -login_text = "Or click here if you don't want to wait!" +login_text = "Or click here if you don't want to wait." [register_feedback] @@ -193,7 +189,7 @@ status_shardoffline = "It seems the shard is offline, you can use the web-accoun status_liboffline = "You can't register an account at this time" login_title = "Login" login_timer = "You will be redirected to the login page in " -login_text = "Or click here if you don't want to wait!" +login_text = "Click here if you do not want to wait." [register] title = "RYZOM CORE INGAME REGISTRATION" From 00b394603d69e1a95445dd5e08d8aa2a23013080 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 7 Sep 2014 04:21:08 +0200 Subject: [PATCH 22/93] Cleanup some English AMS translations --- code/web/private_php/ams/translations/en.ini | 34 ++++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/code/web/private_php/ams/translations/en.ini b/code/web/private_php/ams/translations/en.ini index 8256427a3..41978fe83 100644 --- a/code/web/private_php/ams/translations/en.ini +++ b/code/web/private_php/ams/translations/en.ini @@ -13,19 +13,19 @@ home_info = "Welcome to the Ryzom Core - Account Management System" [forgot_password] title = "Forgot your password?" -forgot_password_message = "Fill in your account's emailaddress to reset the password!" +forgot_password_message = "Fill in your account's email address to reset the password." email_tag = "Email Address" -email_tooltip = "The emailaddress related to the account of which you forgot the password." +email_tooltip = "The email address related to the account of which you forgot the password." email_default = "Email" -email_doesnt_exist = "That emailaddress doesn't match any user!" -email_sent = "An email with further instructions has been sent to the emailaddress!" +email_doesnt_exist = "The email address does not match any user." +email_sent = "An email with further instructions has been sent to the email address." register_message ="Register If you don't have an account yet, create one " here = "here" login_message = "You can always try to login by clicking " [reset_password] title = "Reset your password" -reset_password_message = "Fill in your new password!" +reset_password_message = "Fill in your new password." password_tag = "Desired Password" password_tooltip = "Pick a hard to guess password (it must be 5-20 characters)." @@ -43,8 +43,8 @@ cpassword_default = "Re-enter Password" syncing_title = "LibDB-Query List" syncing_info = "Here you can see the entire list of elements in the LibDB-Query table. You can easily remove elements and by pressing 'Synchronize' you can start the syncing process manually!" syncing_sync = "Synchronize" -shard_online = "The shard seems to be online, manually syncing is possible: " -shard_offline = "The shard seems to be offline, manually syncing is not possible!" +shard_online = "The shard seems to be online, manually syncing is possible." +shard_offline = "The shard seems to be offline, manually syncing is not possible." members = "Members" id = "ID" type = "Type" @@ -64,11 +64,11 @@ plugin_permission = "Access
Permission" plugin_status = "Status" ip_success = "Plugin added succesfuly." plugin_actions = "Actions" -dp_success = "Plugin deleted successfuly" +dp_success = "Plugin deleted successfully" dp_error = "Error in deleting plugin.Please try again later." -ac_success = "Plugin Activated successfuly." +ac_success = "Plugin Activated successfully." ac_error = "Plugin facing some error in activating. Please try again later." -dc_success = "Plugin de-Activated successfuly." +dc_success = "Plugin de-Activated successfully." dc_error = "Plugin facing some error in de-activating. Please try again later." up_success = "Update added successfully. Go to Updates page for installing updates." up_install_success = "Update installed successfully." @@ -95,7 +95,7 @@ title = "Title" t_reply = "Reply on ticket" t_fill = "Fill in your reply" t_send = "Send reply" -invalid_sgroup = "Invalid support group!" +invalid_sgroup = "Invalid support group." ticket_not_existing = "That's an invalid ticket" success_forwarded = "The ticket was forwarded successfully." public_sgroup = "Public" @@ -231,7 +231,7 @@ Reply Content: " email_body_new_reply_4 = " -------------------- -You can reply on this message to answer directly on the ticket!" +You can reply on this message to answer directly on the ticket." ;NEWTICKET ;========================================================================== @@ -244,7 +244,7 @@ email_body_new_ticket_3 = " ,is newly created " email_body_new_ticket_4 = " ---------- -You can reply on this message to answer directly on the ticket!" +You can reply on this message to answer directly on the ticket." ;WARNAUTHOR ;========================================================================== @@ -254,19 +254,19 @@ email_body_warn_author_2 = " by sending an email from " email_body_warn_author_3 = " ! Please use the email address matching to your account if you want to auto reply If " -email_body_warn_author_4 = " isn't one of your email addresses, please contact us by replying to this ticket!" +email_body_warn_author_4 = " isn't one of your email addresses, please contact us by replying to this ticket." ;WARNSENDER ;========================================================================== -email_subject_warn_sender = "You tried to reply to someone elses ticket!" +email_subject_warn_sender = "You tried to reply to someone elses ticket." email_body_warn_sender = "It seems you tried to reply to someone elses ticket, please use the matching email address to that account! This action is notified to the real ticket owner!" ;WARNUNKNOWNENDER ;========================================================================== -email_subject_warn_unknown_sender = "You tried to reply to someone's ticket!" -email_body_warn_unknown_sender = "It seems you tried to reply to someone's ticket, However this email address isn't linked to any account, please use the matching email address to that account! +email_subject_warn_unknown_sender = "You tried to reply to someone's ticket." +email_body_warn_unknown_sender = "It seems you tried to reply to someone's ticket, However this email address isn't linked to any account, please use the matching email address to that account. This action is notified to the real ticket owner!" ;=========================================================================== From b0c0439b391f4ccdc63a8b2ce0c58060731a6bae Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 7 Sep 2014 08:53:10 +0200 Subject: [PATCH 23/93] Change ClientApplication to DomainId in permission table --- .../game_share/generate_module_interface.xslt | 6 +- .../nel_database_mapping.cpp | 77 ++-- .../nel_database_mapping.h | 57 +-- .../nel_database_mapping.xml | 6 +- .../src/shard_unifier_service/readme.txt | 2 + .../ring_session_manager.cpp | 362 +++++++++--------- .../oldmodule/ryzommanage.module | 4 +- code/web/private_php/ams/autoload/sync.php | 32 +- code/web/private_php/ams/autoload/users.php | 6 +- code/web/private_php/setup/sql/nel_00002.sql | 5 + code/web/public_php/login/r2_login.php | 54 +-- code/web/public_php/setup/database.php | 4 + code/web/public_php/setup/install.php | 7 + code/web/public_php/setup/upgrade.php | 7 + 14 files changed, 286 insertions(+), 343 deletions(-) create mode 100644 code/ryzom/server/src/shard_unifier_service/readme.txt create mode 100644 code/web/private_php/setup/sql/nel_00002.sql diff --git a/code/ryzom/common/src/game_share/generate_module_interface.xslt b/code/ryzom/common/src/game_share/generate_module_interface.xslt index 425e699a4..ee87f6ae4 100644 --- a/code/ryzom/common/src/game_share/generate_module_interface.xslt +++ b/code/ryzom/common/src/game_share/generate_module_interface.xslt @@ -28,9 +28,7 @@ #ifndef #define #include "nel/misc/types_nl.h" -#ifdef NL_COMP_VC8 - #include <memory> -#endif +#include <memory> #include "nel/misc/hierarchical_timer.h" #include "nel/misc/string_conversion.h" #include "nel/net/message.h" @@ -45,7 +43,7 @@ #include "nel/misc/string_common.h" -#include "game_share/mysql_wrapper.h" +#include "server_share/mysql_wrapper.h" #include "game_share/synchronised_message.h" diff --git a/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.cpp b/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.cpp index 25cf56504..9e81798dc 100644 --- a/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.cpp +++ b/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.cpp @@ -1,18 +1,3 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . ///////////////////////////////////////////////////////////////// // WARNING : this is a generated file, don't change it ! @@ -99,7 +84,7 @@ namespace RSMGR { nlwarning("ERROR : someone try to delete this object, but there are still ptr on it !"); CNelUserPtr *ptr = _PtrList; - do + do { nlwarning(" Pointer created from '%s', line %u", ptr->_FileName, ptr->_LineNum); ptr = _PtrList->getNextPtr(); @@ -107,7 +92,7 @@ namespace RSMGR nlstop; } // remove object from cache map - if (_UserId != NOPE::INVALID_OBJECT_ID + if (_UserId != NOPE::INVALID_OBJECT_ID && _ObjectState != NOPE::os_removed && _ObjectState != NOPE::os_transient) { @@ -318,7 +303,7 @@ namespace RSMGR } else if (cmd == NOPE::cc_instance_count) { - return (uint32)_ObjectCache.size(); + return _ObjectCache.size(); } // default return value @@ -336,7 +321,7 @@ namespace RSMGR TReleasedObject::iterator first(_ReleasedObject.begin()), last(_ReleasedObject.end()); for (; first != last; ++first) { - nbReleased += (uint32)first->second.size(); + nbReleased += first->second.size(); } nlinfo(" There are %u object instances in cache not referenced (waiting deletion or re-use))", nbReleased); @@ -424,7 +409,7 @@ namespace RSMGR if(_ObjectState == NOPE::os_released && state == NOPE::os_removed) { // a release object gets removed (e.g. by remove by id) - + // delete the object delete this; @@ -578,7 +563,7 @@ namespace RSMGR { nlwarning("ERROR : someone try to delete this object, but there are still ptr on it !"); CNelPermissionPtr *ptr = _PtrList; - do + do { nlwarning(" Pointer created from '%s', line %u", ptr->_FileName, ptr->_LineNum); ptr = _PtrList->getNextPtr(); @@ -586,16 +571,16 @@ namespace RSMGR nlstop; } // remove object from cache map - if (_Prim != NOPE::INVALID_OBJECT_ID + if (_PermissionId != NOPE::INVALID_OBJECT_ID && _ObjectState != NOPE::os_removed && _ObjectState != NOPE::os_transient) { - nldebug("NOPE: clearing CNelPermission @%p from cache with id %u", this, static_cast(_Prim)); - nlverify(_ObjectCache.erase(_Prim) == 1); + nldebug("NOPE: clearing CNelPermission @%p from cache with id %u", this, static_cast(_PermissionId)); + nlverify(_ObjectCache.erase(_PermissionId) == 1); } else if (_ObjectState != NOPE::os_transient) { - nlassert(_ObjectCache.find(_Prim) == _ObjectCache.end()); + nlassert(_ObjectCache.find(_PermissionId) == _ObjectCache.end()); } if (_ObjectState == NOPE::os_released) { @@ -626,18 +611,18 @@ namespace RSMGR { nlassert(getPersistentState() == NOPE::os_transient); - nlassert(_Prim != 0); + nlassert(_PermissionId != 0); std::string qs; qs = "INSERT INTO permission ("; - qs += "prim, UId, ClientApplication, ShardId, AccessPrivilege"; + qs += "PermissionId, UId, DomainId, ShardId, AccessPrivilege"; qs += ") VALUES ("; - qs += "'"+MSW::escapeString(NLMISC::toString(_Prim), connection)+"'"; + qs += "'"+MSW::escapeString(NLMISC::toString(_PermissionId), connection)+"'"; qs += ", "; qs += "'"+MSW::escapeString(NLMISC::toString(_UserId), connection)+"'"; qs += ", "; - qs += "'"+MSW::escapeString(NLMISC::toString(_DomainName), connection)+"'"; + qs += "'"+MSW::escapeString(NLMISC::toString(_DomainId), connection)+"'"; qs += ", "; qs += "'"+MSW::escapeString(NLMISC::toString(_ShardId), connection)+"'"; qs += ", "; @@ -670,17 +655,17 @@ namespace RSMGR std::string qs; qs = "UPDATE permission SET "; - qs += "prim = '"+MSW::escapeString(NLMISC::toString(_Prim), connection)+"'"; + qs += "PermissionId = '"+MSW::escapeString(NLMISC::toString(_PermissionId), connection)+"'"; qs += ", "; qs += "UId = '"+MSW::escapeString(NLMISC::toString(_UserId), connection)+"'"; qs += ", "; - qs += "ClientApplication = '"+MSW::escapeString(NLMISC::toString(_DomainName), connection)+"'"; + qs += "DomainId = '"+MSW::escapeString(NLMISC::toString(_DomainId), connection)+"'"; qs += ", "; qs += "ShardId = '"+MSW::escapeString(NLMISC::toString(_ShardId), connection)+"'"; qs += ", "; qs += "AccessPrivilege = '"+MSW::escapeString(NLMISC::toString(_AccessPriv), connection)+"'"; - qs += " WHERE prim = '"+NLMISC::toString(_Prim)+"'"; + qs += " WHERE PermissionId = '"+NLMISC::toString(_PermissionId)+"'"; if (connection.query(qs)) @@ -702,7 +687,7 @@ namespace RSMGR std::string qs; qs = "DELETE FROM permission "; - qs += " WHERE prim = '"+NLMISC::toString(_Prim)+"'"; + qs += " WHERE PermissionId = '"+NLMISC::toString(_PermissionId)+"'"; if (connection.query(qs)) @@ -736,7 +721,7 @@ namespace RSMGR std::string qs; qs = "DELETE FROM permission "; - qs += " WHERE prim = '"+NLMISC::toString(id)+"'"; + qs += " WHERE PermissionId = '"+NLMISC::toString(id)+"'"; if (connection.query(qs)) @@ -796,7 +781,7 @@ namespace RSMGR } else if (cmd == NOPE::cc_instance_count) { - return (uint32)_ObjectCache.size(); + return _ObjectCache.size(); } // default return value @@ -814,7 +799,7 @@ namespace RSMGR TReleasedObject::iterator first(_ReleasedObject.begin()), last(_ReleasedObject.end()); for (; first != last; ++first) { - nbReleased += (uint32)first->second.size(); + nbReleased += first->second.size(); } nlinfo(" There are %u object instances in cache not referenced (waiting deletion or re-use))", nbReleased); @@ -902,7 +887,7 @@ namespace RSMGR if(_ObjectState == NOPE::os_released && state == NOPE::os_removed) { // a release object gets removed (e.g. by remove by id) - + // delete the object delete this; @@ -912,12 +897,12 @@ namespace RSMGR if (_ObjectState == NOPE::os_transient && state != NOPE::os_transient) { - nldebug("NOPE: inserting CNelPermission @%p in cache with id %u", this, static_cast(_Prim)); - nlverify(_ObjectCache.insert(std::make_pair(_Prim, this)).second); + nldebug("NOPE: inserting CNelPermission @%p in cache with id %u", this, static_cast(_PermissionId)); + nlverify(_ObjectCache.insert(std::make_pair(_PermissionId, this)).second); } if (_ObjectState != NOPE::os_transient) - nlassert(_ObjectCache.find(_Prim) != _ObjectCache.end()); + nlassert(_ObjectCache.find(_PermissionId) != _ObjectCache.end()); _ObjectState = state; @@ -928,8 +913,8 @@ namespace RSMGR } else if (state == NOPE::os_removed) { - nldebug("NOPE: erasing CNelPermission @%p in cache with id %u", this, static_cast(_Prim)); - nlverify(_ObjectCache.erase(_Prim) == 1); + nldebug("NOPE: erasing CNelPermission @%p in cache with id %u", this, static_cast(_PermissionId)); + nlverify(_ObjectCache.erase(_PermissionId) == 1); } } @@ -945,11 +930,11 @@ namespace RSMGR std::string qs; qs = "SELECT "; - qs += "prim, UId, ClientApplication, ShardId, AccessPrivilege"; + qs += "PermissionId, UId, DomainId, ShardId, AccessPrivilege"; qs += " FROM permission"; - qs += " WHERE prim = '"+NLMISC::toString(id)+"'"; + qs += " WHERE PermissionId = '"+NLMISC::toString(id)+"'"; CNelPermissionPtr ret; if (!connection.query(qs)) { @@ -965,9 +950,9 @@ namespace RSMGR // ok, we have an object result->fetchRow(); - result->getField(0, ret->_Prim); + result->getField(0, ret->_PermissionId); result->getField(1, ret->_UserId); - result->getField(2, ret->_DomainName); + result->getField(2, ret->_DomainId); result->getField(3, ret->_ShardId); result->getField(4, ret->_AccessPriv); diff --git a/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.h b/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.h index 7ddd3de74..50ef8e823 100644 --- a/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.h +++ b/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.h @@ -1,18 +1,3 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . ///////////////////////////////////////////////////////////////// // WARNING : this is a generated file, don't change it ! @@ -107,7 +92,7 @@ namespace RSMGR _PrevPtr(NULL) { _Ptr = objectPtr; - + linkPtr(); } @@ -247,7 +232,7 @@ namespace RSMGR _PrevPtr(NULL) { _Ptr = objectPtr; - + linkPtr(); } @@ -556,7 +541,7 @@ namespace RSMGR time_t _ReleaseDate; /// The linked list of pointer on this object - CNelUserPtr *_PtrList; + CNelUserPtr *_PtrList; // Try to load the specified object from the memory cache, return NULL if the object is not in the cache static CNelUser *loadFromCache(uint32 objectId, bool unrelease); @@ -583,7 +568,7 @@ namespace RSMGR } public: - + /** Return the object identifier (witch is unique) * You can only call this method on a persistent instance. * (because transient instance can have invalid id) @@ -632,11 +617,11 @@ namespace RSMGR { protected: // - uint32 _Prim; + uint32 _PermissionId; // uint32 _UserId; // - std::string _DomainName; + uint32 _DomainId; // uint32 _ShardId; // @@ -662,25 +647,21 @@ namespace RSMGR } // - const std::string &getDomainName() const + uint32 getDomainId() const { - return _DomainName; + return _DomainId; } - - - void setDomainName(const std::string &value) + void setDomainId(uint32 value) { - if (_DomainName != value) + if (_DomainId != value) { if (getPersistentState() != NOPE::os_transient) setPersistentState(NOPE::os_dirty); + _DomainId = value; - _DomainName = value; - - } } @@ -729,9 +710,9 @@ namespace RSMGR bool operator == (const CNelPermission &other) const { - return _Prim == other._Prim + return _PermissionId == other._PermissionId && _UserId == other._UserId - && _DomainName == other._DomainName + && _DomainId == other._DomainId && _ShardId == other._ShardId && _AccessPriv == other._AccessPriv; } @@ -742,7 +723,7 @@ namespace RSMGR CNelPermission() : _PtrList(NULL), _ObjectState(NOPE::os_transient), - _Prim(NOPE::INVALID_OBJECT_ID) + _PermissionId(NOPE::INVALID_OBJECT_ID) { // register the cache for this class (if not already done) @@ -825,7 +806,7 @@ namespace RSMGR time_t _ReleaseDate; /// The linked list of pointer on this object - CNelPermissionPtr *_PtrList; + CNelPermissionPtr *_PtrList; // Try to load the specified object from the memory cache, return NULL if the object is not in the cache static CNelPermission *loadFromCache(uint32 objectId, bool unrelease); @@ -852,7 +833,7 @@ namespace RSMGR } public: - + /** Return the object identifier (witch is unique) * You can only call this method on a persistent instance. * (because transient instance can have invalid id) @@ -860,7 +841,7 @@ namespace RSMGR uint32 getObjectId() const { - return _Prim; + return _PermissionId; } /** Set the object unique ID. @@ -874,8 +855,8 @@ namespace RSMGR // can only be set when in transient state nlassert(getPersistentState() == NOPE::os_transient); // can only be set once - nlassert(_Prim == NOPE::INVALID_OBJECT_ID); - _Prim = objectId; + nlassert(_PermissionId == NOPE::INVALID_OBJECT_ID); + _PermissionId = objectId; } /** Return the current persistent state of the object.*/ diff --git a/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.xml b/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.xml index 02642eb11..cd85c2fd5 100644 --- a/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.xml +++ b/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.xml @@ -17,16 +17,16 @@ - + - + - + diff --git a/code/ryzom/server/src/shard_unifier_service/readme.txt b/code/ryzom/server/src/shard_unifier_service/readme.txt new file mode 100644 index 000000000..6d45d7556 --- /dev/null +++ b/code/ryzom/server/src/shard_unifier_service/readme.txt @@ -0,0 +1,2 @@ +xsltproc -o nel_database_mapping.cpp --stringparam output cpp --stringparam filename nel_database_mapping ../../../common/src/game_share/generate_module_interface.xslt nel_database_mapping.xml +xsltproc -o nel_database_mapping.h --stringparam output header --stringparam filename nel_database_mapping ../../../common/src/game_share/generate_module_interface.xslt nel_database_mapping.xml diff --git a/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp b/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp index 8d6c2a91f..a2dc72b1c 100644 --- a/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp +++ b/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp @@ -58,7 +58,7 @@ CVariable PrivilegeForSessionAccess("su", "PrivilegeForSessionAccess", " namespace RSMGR { - class CRingSessionManager : + class CRingSessionManager : public CEmptyModuleServiceBehav > >, public CRingSessionManagerSkel, public CRingSessionManagerWebItf, @@ -74,10 +74,10 @@ namespace RSMGR // mysql nel database connection MSW::CConnection _NelDb; - + struct TSessionServerInfo { - /// Shard id + /// Shard id TShardId ShardId; /// Total number of player in the sessions hosted by this server uint32 NbTotalPlayingChars; @@ -97,7 +97,7 @@ namespace RSMGR TSessionServers _SessionServers; typedef map TSessionServersIdx; - // index of sessionId to session server + // index of sessionId to session server TSessionServersIdx _SessionIndex; struct TWelcomeServiceInfo @@ -147,7 +147,7 @@ namespace RSMGR }; typedef map TTemporaryShardAssocs; - /** A table of session owner and the ring shard on witch they are + /** A table of session owner and the ring shard on witch they are * currently stuck. This allow the RSM to assign edit and anim session * of a character to the same DSS to use the DSS session ID masquerading * that allow reuse of the same session for editing and animating without @@ -184,7 +184,7 @@ namespace RSMGR struct TPendingJoinSession { /// The user ID - uint32 UserId; + uint32 UserId; /// the session id TSessionId SessionId; /// The web connection @@ -206,7 +206,7 @@ namespace RSMGR /// Pointer to character sync speaker ICharacterSync *_CharSync; public: - CRingSessionManager() + CRingSessionManager() : _DontUsePerm(false), _CharSync(NULL) { @@ -284,7 +284,7 @@ namespace RSMGR nlwarning("Missing 'web' param in module init string"); return false; } - + const TParsedCommandLine *portParam = web->getParam("port"); if (portParam == NULL) { @@ -399,7 +399,7 @@ namespace RSMGR { nldebug("RSM : receive module down for session server '%s'", proxy->getModuleName().c_str()); - // lock any sessions that belong to this module (because we don't now if + // lock any sessions that belong to this module (because we don't now if // the session server if just unreachable or really dead) TSessionServerInfo &ssi = it->second; { @@ -433,7 +433,7 @@ namespace RSMGR else ++it; } - + } { @@ -457,7 +457,7 @@ namespace RSMGR } } } - + } // remove session info @@ -625,11 +625,11 @@ namespace RSMGR // query << " WHERE shard.domain_id = domain.domain_id"; // query << " AND domain_name = '" << DomainName << "'"; // query << " AND ShardId = " << shardId; -// +// // BOMB_IF(!_NelDb.query(query), "registerWS : Failed to request into the NeL database", return CNelShardPtr()); // auto_ptr result = auto_ptr(_NelDb.storeResult()); // BOMB_IF(result.get() == NULL, "registerWS : Failed to retrieve request result", return CNelShardPtr()); -// +// // if (result->getNumRows() == 0) // { // return CNelShardPtr(); @@ -639,7 +639,7 @@ namespace RSMGR // // load the data // uint32 prim; // result->getField(0, prim); -// +// // return CNelShard::load(_NelDb, prim, __FILE__, __LINE__); // } @@ -648,8 +648,8 @@ namespace RSMGR userAccessPriv.clear(); CSString query; query << "SELECT AccessPrivilege FROM permission"; - query << " WHERE UId = " << userId << " AND permission.ClientApplication = '"<getModuleName().c_str()); if (_SessionServers.find(sender) != _SessionServers.end()) @@ -696,13 +696,13 @@ namespace RSMGR for (uint i=0; i(rsi.getSessionId()), + nlwarning("registerDSS : can't load the session %u hosted by '%s, closing it", + static_cast(rsi.getSessionId()), sender->getModuleName().c_str()); CRingSessionManagerClientProxy smc(sender); @@ -718,7 +718,7 @@ namespace RSMGR if (session->getState() != TSessionState::ss_open && session->getState() != TSessionState::ss_locked) { nlwarning("registerDSS : The session %u open hosted by '%s' is '%s', asking DSS to close it", - static_cast(rsi.getSessionId()), + static_cast(rsi.getSessionId()), sender->getModuleName().c_str(), session->getState().toString().c_str()); @@ -790,7 +790,7 @@ restartLoop: _TemporaryLockedSession.erase(sessionId); sessionToClose.pop_front(); } - + } _SessionServers[sender] = ssi; @@ -829,7 +829,7 @@ restartLoop: invokeResult(from, (it3->CharId) >> 4, 5, "Session server failure"); return; } - + TSessionServerInfo &ssi = it->second; TSessionServerInfo::THostedSessions::iterator it2(ssi.HostedSessions.find(sessionInfo.getSessionId())); @@ -875,7 +875,7 @@ restartLoop: _PendingSessions.erase(it3); } - + // that all } @@ -898,7 +898,7 @@ restartLoop: sender->getModuleName().c_str()); return; } - + TSessionServerInfo &ssi = it->second; TSessionServerInfo::THostedSessions::iterator it2(ssi.HostedSessions.find(sessionId)); @@ -1049,7 +1049,7 @@ restartLoop: sessionLog->setScenarioPointScored(0); sessionLog->setTimeTaken(0); sessionLog->setGuildName(""); - + sessionLog->create(_RingDb); } @@ -1095,12 +1095,12 @@ restartLoop: // provides a bunch of data about the session life. // The DSS report the end of an animation session and // provides a bunch of data about the session life. - virtual void scenarioEnded(NLNET::IModuleProxy *sender, - TSessionId sessionId, - const R2::TRunningScenarioInfo &scenarioInfo, - uint32 rrpScored, - uint32 scenarioPointScored, - uint32 timeTaken, + virtual void scenarioEnded(NLNET::IModuleProxy *sender, + TSessionId sessionId, + const R2::TRunningScenarioInfo &scenarioInfo, + uint32 rrpScored, + uint32 scenarioPointScored, + uint32 timeTaken, const std::vector < uint32 > &participants) { H_AUTO(SessionManager_scenarioEnded); @@ -1171,7 +1171,7 @@ restartLoop: // build the participants string for (uint i=0; isetObjectId(shardId); - // new WS are always inserted in restricted mode + // new WS are always inserted in restricted mode wsInfo.ShardInfo->setWSOnline(false); wsInfo.ShardInfo->setRequiredState(TAccessLevel::ds_restricted); wsInfo.ShardInfo->setMOTD("Shard up, access restricted"); @@ -1286,7 +1286,7 @@ restartLoop: if (isOnline && wsInfo.ShardInfo->getRequiredState() != TAccessLevel::ds_close) { - // the WS is online, check the previous known state of the + // the WS is online, check the previous known state of the // WS and put it in restricted if it was previously close. if (!wsInfo.ShardInfo->getWSOnline()) { @@ -1322,8 +1322,8 @@ restartLoop: { TWelcomeServiceInfo &wsi = itw->second; - if (isOnline - && wsi.ShardInfo->getRequiredState() != TAccessLevel::ds_close + if (isOnline + && wsi.ShardInfo->getRequiredState() != TAccessLevel::ds_close && !wsi.ShardInfo->getWSOnline()) { // unclose this shard @@ -1388,7 +1388,7 @@ restartLoop: // retrieve the session participant character->loadSessionParticipants(_RingDb, __FILE__, __LINE__); TSessionPartStatus status; - + // vector::iterator first(character->getSessionParticipants().begin()), last(character->getSessionParticipants().end()); // for (; first != last; ++first) uint i; @@ -1479,7 +1479,7 @@ restartLoop: joinSessionResult(pjs.From, pjs.UserId, pjs.SessionId, 8, string("Welcome refused entry in shard with error : '")+errorMsg+"'", TSessionPartStatus::invalid_val); } -endOfWelcomeUserResult: +endOfWelcomeUserResult: if (ok) { // update the 'ring_user' table to signal which session we're entering and with which character @@ -1494,7 +1494,7 @@ endOfWelcomeUserResult: return; } } - + nlwarning("welcomeUserResult : received a result for unexpected userId %u from WS '%s'", userId, sender->getModuleName().c_str()); @@ -1559,37 +1559,37 @@ endOfWelcomeUserResult: } } - virtual void on_setSessionStartParams(NLNET::TSockId from, + virtual void on_setSessionStartParams(NLNET::TSockId from, uint32 charId, TSessionId sessionId, const std::string &initialIslandLocation, const std::string &initialEntryPointLocation, const std::string &initialSeason) { CSessionPtr session = CSession::load(_RingDb, sessionId.asInt(), __FILE__, __LINE__); if (session == NULL) { return; } if (session->getSessionType() == TSessionType::st_mainland) { return;} - + TSessionServersIdx::iterator it(_SessionIndex.find(sessionId)); if (it == _SessionIndex.end()) { return; } CRingSessionManagerClientProxy ss(it->second); ss.setSessionStartParams(this, charId, sessionId, initialIslandLocation, initialEntryPointLocation, initialSeason); - + } - virtual void on_scheduleSession(NLNET::TSockId from, - uint32 charId, - const TSessionType &sessionType, - const std::string &sessionTitle, - const std::string &sessionDesc, - const TSessionLevel &sessionLevel, -// const TAccessType &accessType, - const TRuleType &ruleType, - const TEstimatedDuration &estimatedDuration, - uint32 subscriptionSlot, + virtual void on_scheduleSession(NLNET::TSockId from, + uint32 charId, + const TSessionType &sessionType, + const std::string &sessionTitle, + const std::string &sessionDesc, + const TSessionLevel &sessionLevel, +// const TAccessType &accessType, + const TRuleType &ruleType, + const TEstimatedDuration &estimatedDuration, + uint32 subscriptionSlot, const TAnimMode &animMode, - const TRaceFilter &raceFilter, - const TReligionFilter &religionFilter, - const TGuildFilter &guildFilter, + const TRaceFilter &raceFilter, + const TReligionFilter &religionFilter, + const TGuildFilter &guildFilter, const TShardFilter &shardFilter, const TLevelFilter &levelFilter, const std::string &language, @@ -1636,7 +1636,7 @@ endOfWelcomeUserResult: CCharacterPtr character = CCharacter::load(_RingDb, charId, __FILE__, __LINE__); if (character == NULL) { - // failed !, invalid character + // failed !, invalid character scheduleSessionResult(from, charId, TSessionId(0), 3, "Invalid character"); return; } @@ -1646,13 +1646,13 @@ endOfWelcomeUserResult: { CNelUserPtr nelUser = CNelUser::load(_NelDb, userId, __FILE__, __LINE__); BOMB_IF(nelUser == NULL, "Failed to load nel user "<getExtendedPrivilege().find(":TRIAL:") != string::npos) { // this account is free trial, no anim session allowed - scheduleSessionResult(from, charId, TSessionId(0), 9, "Forbidden for free trial"); + scheduleSessionResult(from, charId, TSessionId(0), 9, "Forbidden for free trial"); return; } */ @@ -1704,7 +1704,7 @@ endOfWelcomeUserResult: // store the session session->create(_RingDb); - + // ok, return the result to web scheduleSessionResult(from, charId, TSessionId(session->getObjectId()), 0, ""); } @@ -1730,7 +1730,7 @@ endOfWelcomeUserResult: } // ok, return the result to web - sessionInfoResult(from, charId, TSessionId(session->getObjectId()), + sessionInfoResult(from, charId, TSessionId(session->getObjectId()), session->getRaceFilter(), session->getReligionFilter(), session->getGuildFilter(), session->getShardFilter(), session->getLevelFilter(), session->getSubscriptionClosed(), (session->getAccessType()==TAccessType::at_public), session->getLang(), session->getOrientation(), session->getDescription()); @@ -1743,21 +1743,21 @@ endOfWelcomeUserResult: // 3 : char don't own the session // 4 : session is closed, no update allowed // 5 : invalid parameter - virtual void on_updateSessionInfo(NLNET::TSockId from, - uint32 charId, - TSessionId sessionId, - const std::string &sessionTitle, - uint32 plannedDate, - const std::string &sessionDesc, - const TSessionLevel &sessionLevel, -// const TAccessType &accessType, - const TEstimatedDuration &estimatedDuration, - uint32 subscriptionSlot, - const TRaceFilter &raceFilter, - const TReligionFilter &religionFilter, - const TGuildFilter &guildFilter, - const TShardFilter &shardFilter, - const TLevelFilter &levelFilter, + virtual void on_updateSessionInfo(NLNET::TSockId from, + uint32 charId, + TSessionId sessionId, + const std::string &sessionTitle, + uint32 plannedDate, + const std::string &sessionDesc, + const TSessionLevel &sessionLevel, +// const TAccessType &accessType, + const TEstimatedDuration &estimatedDuration, + uint32 subscriptionSlot, + const TRaceFilter &raceFilter, + const TReligionFilter &religionFilter, + const TGuildFilter &guildFilter, + const TShardFilter &shardFilter, + const TLevelFilter &levelFilter, bool subscriptionClosed, bool autoInvite, const std::string &language, @@ -1833,7 +1833,7 @@ endOfWelcomeUserResult: invokeResult(from, charId>>4, 0, ""); } - + // Cancel a planned session // Return 'invokeResult' : 0 : ok, session canceled // 1 : unknown char @@ -1867,14 +1867,14 @@ endOfWelcomeUserResult: return; } - if (session->getState() != TSessionState::ss_planned + if (session->getState() != TSessionState::ss_planned && session->getState() != TSessionState::ss_locked) { // not planned invokeResult(from, charId>>4, 4, "Session not in planned state"); return; } - + // remove the session from database session->remove(_RingDb); @@ -1928,7 +1928,7 @@ endOfWelcomeUserResult: // look for the best server TSessionServers::iterator best(_SessionServers.end()); - + // check if the user has a open edit session, if so, lauch the session on the same shard if (session->getSessionType() == TSessionType::st_anim) @@ -1944,7 +1944,7 @@ endOfWelcomeUserResult: TSessionServersIdx::iterator it(_SessionIndex.find(s->getObjectId())); if (it != _SessionIndex.end()) best = _SessionServers.find(it->second); - + break; } } @@ -2134,7 +2134,7 @@ endOfWelcomeUserResult: if (session->getState() != TSessionState::ss_closed && session->getState() != TSessionState::ss_planned) - { + { // ask the session server to close this session TSessionServersIdx::iterator it(_SessionIndex.find(sessionId)); if (it != _SessionIndex.end()) @@ -2142,7 +2142,7 @@ endOfWelcomeUserResult: TModuleProxyPtr proxy = it->second; CRingSessionManagerClientProxy ss(proxy); - + ss.closeSession(this, sessionId); // ok, we have closed the session @@ -2162,7 +2162,7 @@ endOfWelcomeUserResult: // use the first server in the list TModuleProxyPtr proxy = _SessionServers.begin()->first; CRingSessionManagerClientProxy ss(proxy); - + ss.stopHibernation(this, TSessionId(sessionId), charId); } @@ -2171,7 +2171,7 @@ endOfWelcomeUserResult: } // Close a running session - // Return 'invokeResult' : 0 : ok, + // Return 'invokeResult' : 0 : ok, // 1 : not ok //:TODO: change the name to Cloase or hibernate previous sessions virtual void on_hibernateEditSession(NLNET::TSockId from, uint32 charId) @@ -2186,12 +2186,12 @@ endOfWelcomeUserResult: CCharacterPtr character = CCharacter::load(_RingDb, charId, __FILE__, __LINE__); if (character == NULL) { - invokeResult(from, charId>>4, 1, "Character not found"); + invokeResult(from, charId>>4, 1, "Character not found"); return; } // Hiberning edit sessions { - + CSString query; query << "SELECT session_id FROM sessions"; query << " WHERE owner = "<getNumRows() != 0) { - + if (result->getNumRows() > 1) { @@ -2214,13 +2214,13 @@ endOfWelcomeUserResult: uint32 sessionNum; result->getField(0, sessionNum); TSessionId sessionId(sessionNum); - + CSessionPtr session = CSession::load(_RingDb, sessionId.asInt(), __FILE__, __LINE__); if (session != NULL) { if (session->getState() != TSessionState::ss_closed && session->getState() != TSessionState::ss_planned) - { + { // ask the session server to close this session TSessionServersIdx::iterator it(_SessionIndex.find(sessionId)); if (it != _SessionIndex.end()) @@ -2228,7 +2228,7 @@ endOfWelcomeUserResult: TModuleProxyPtr proxy = it->second; CRingSessionManagerClientProxy ss(proxy); - + ss.hibernateSession(this, sessionId); } } @@ -2238,7 +2238,7 @@ endOfWelcomeUserResult: // Close anim sessions { - + CSString query; query << "SELECT session_id FROM sessions"; query << " WHERE owner = "<getNumRows()); } - + unsigned int firstSession = 0; unsigned int lastSession = result->getNumRows(); for (;firstSession != lastSession; ++firstSession) - { + { result->fetchRow(); - // get the session id - + // get the session id + uint32 sessionNum; result->getField(0, sessionNum); TSessionId sessionId(sessionNum); - + CSessionPtr session = CSession::load(_RingDb, sessionId.asInt(), __FILE__, __LINE__); if (session != NULL) { - - if ( session->getState() != TSessionState::ss_closed && session->getState() != TSessionState::ss_planned) - { + + if ( session->getState() != TSessionState::ss_closed && session->getState() != TSessionState::ss_planned) + { // ask the session server to close this session TSessionServersIdx::iterator it(_SessionIndex.find(sessionId)); if (it == _SessionIndex.end()) @@ -2335,8 +2335,8 @@ endOfWelcomeUserResult: uint i; for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; - if (ku->getTargetCharacter() == friendCharId + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + if (ku->getTargetCharacter() == friendCharId && (ku->getRelation() == TKnownUserRelation::rt_friend || ku->getRelation() == TKnownUserRelation::rt_banned)) break; } @@ -2411,7 +2411,7 @@ endOfWelcomeUserResult: uint i; for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; if (ku->getTargetCharacter() == friendCharId && ku->getRelation() == TKnownUserRelation::rt_friend) break; } @@ -2468,7 +2468,7 @@ endOfWelcomeUserResult: uint i; for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; if (ku->getTargetCharacter() == bannedCharId && ku->getRelation() == TKnownUserRelation::rt_banned) break; } @@ -2487,14 +2487,14 @@ endOfWelcomeUserResult: } else { - // the character is already banned + // the character is already banned } vector removeList; // remove any friend or DM friend record for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; if (ku->getTargetCharacter() == bannedCharId && ku->getRelation() != TKnownUserRelation::rt_banned) removeList.push_back(ku); } @@ -2545,7 +2545,7 @@ endOfWelcomeUserResult: uint i; for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; if (ku->getTargetCharacter() == bannedCharId && ku->getRelation() == TKnownUserRelation::rt_banned) break; } @@ -2562,7 +2562,7 @@ endOfWelcomeUserResult: // invokeResult(from, userId, 3, "character not flagged as banned"); // return; // } - + // ok, remove the know user record ku->remove(_RingDb); @@ -2606,8 +2606,8 @@ endOfWelcomeUserResult: uint i; for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; - if (ku->getTargetCharacter() == friendDMCharId + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + if (ku->getTargetCharacter() == friendDMCharId && (ku->getRelation() == TKnownUserRelation::rt_friend_dm || ku->getRelation() == TKnownUserRelation::rt_banned)) break; } @@ -2681,7 +2681,7 @@ endOfWelcomeUserResult: uint i; for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; if (ku->getTargetCharacter() == friendDMCharId && ku->getRelation() == TKnownUserRelation::rt_friend_dm) break; } @@ -2698,7 +2698,7 @@ endOfWelcomeUserResult: // invokeResult(from, userId, 3, "character not flagged as friend"); // return; // } - + // ok, remove the know user record ku->remove(_RingDb); @@ -2715,9 +2715,9 @@ endOfWelcomeUserResult: // 5 : invalid param virtual void on_setKnownCharacterComments(NLNET::TSockId from, uint32 userId, uint32 charId, const std::string &relation, const std::string &comments) { - nldebug("RSM : setKnownCharacterComments set comment '%s' on char %u knowns as '%s' of user %u", + nldebug("RSM : setKnownCharacterComments set comment '%s' on char %u knowns as '%s' of user %u", comments.c_str(), - charId, + charId, relation.c_str(), userId); @@ -2739,7 +2739,7 @@ endOfWelcomeUserResult: bool foundARelation = false; for (uint i=0; igetKnownUsers().size(); ++i) { - CKnownUserPtr &ku = ru->getKnownUsersByIndex(i); + CKnownUserPtr &ku = ru->getKnownUsersByIndex(i); if (ku->getTargetCharacter() == charId && ku->getRelation() == rel) { // we found the relation, update the comment @@ -2772,7 +2772,7 @@ endOfWelcomeUserResult: // A user invite a character to help or play in his session // charRole is from enum TSessionPartStatus // invokeReturn : 0 : ok, character invited - // 1 : char not found + // 1 : char not found // 2 : session not found // 3 : invited char not found // 4 : char not own the session @@ -2842,17 +2842,17 @@ endOfWelcomeUserResult: invokeResult(from, ownerCharId>>4, 13, "scenario not started, can't validate invitation now"); return; } - + CScenarioPtr scenario = CScenario::load(_RingDb, sessionLog->getScenarioId(), __FILE__, __LINE__); BOMB_IF(invitedNelUser == NULL, "Failed to load scenario for id "<getScenarioId()<<" for session "<>4, 8, "Can not load scenario associated with session log"); return); - - if (invitedNelUser->getExtendedPrivilege().find(":TRIAL:") != string::npos + + if (invitedNelUser->getExtendedPrivilege().find(":TRIAL:") != string::npos && !scenario->getAllowFreeTrial()) { // free trial are not allowed in this scenario invokeResult(from, ownerCharId>>4, 14, "free trial character are not allowed in user scenario"); return; - + } // check that the character is not already participating @@ -2877,18 +2877,18 @@ endOfWelcomeUserResult: invokeResult(from, ownerCharId>>4, 4, "Animator can't invite other animator (only session owner can)"); return; } - else if (session->getOwnerId() != ownerCharId) + else if (session->getOwnerId() != ownerCharId) { // the character that request the invitation is not the session owner, // check that he is animator in the session/ BOMB_IF(!ownerChar->loadSessionParticipants(_RingDb, __FILE__, __LINE__), "Failed to load participation for host character "<>4, 8, "Failed to load participation for host character"); return); - + uint i=0; for (; igetSessionParticipants().size(); ++i) { CSessionParticipantPtr sp = ownerChar->getSessionParticipantsByIndex(i); - + if (sp->getSessionId() == sessionId.asInt()) { // we found it @@ -2899,12 +2899,12 @@ endOfWelcomeUserResult: invokeResult(from, ownerCharId>>4, 11, "Invitation requester char is not animator in the session"); return; } - + // ok, stop the loop break; } } - + if (i == ownerChar->getSessionParticipants().size()) { // no participation found ! @@ -3059,7 +3059,7 @@ endOfWelcomeUserResult: { const CKnownUserPtr &ku = ru->getKnownUsersByIndex(i); - if (ku->getRelation() == TKnownUserRelation::rt_banned + if (ku->getRelation() == TKnownUserRelation::rt_banned && ku->getTargetUser() == character->getUserId()) { // this character is banned ! @@ -3170,7 +3170,7 @@ endOfWelcomeUserResult: { BOMB_IF (!loadUserAccessPrivileges(userId, userAccessPriv), "RSM:on_joinSession : failed to load privileges for user "<getOwnerId() != charId + if (session->getOwnerId() != charId && nelUser->getExtendedPrivilege().find(":TRIAL:") != string::npos) { // check that the scenario launched allow free trials players @@ -3277,7 +3277,7 @@ endOfWelcomeUserResult: sessionPart->setCharId(charId); sessionPart->setSessionId(session->getObjectId()); sessionPart->setStatus(TSessionPartStatus::sps_play_invited); - + // store the participation sessionPart->create(_RingDb); } @@ -3344,7 +3344,7 @@ endOfWelcomeUserResult: // warn the session server that an editor come in enterAs = WS::TUserRole::ur_editor; ss.addCharacterInSession(this, sessionId, charId, enterAs, charac->getRingAccess(), charac->getNewcomer()); - + // update the participant status sessionPart->setStatus(TSessionPartStatus::sps_editing); @@ -3352,8 +3352,8 @@ endOfWelcomeUserResult: else if ( sessionPart->getStatus() == TSessionPartStatus::sps_anim_invited || sessionPart->getStatus() == TSessionPartStatus::sps_animating) { - // warn the session server that an animator come in - enterAs = WS::TUserRole::ur_animator; + // warn the session server that an animator come in + enterAs = WS::TUserRole::ur_animator; ss.addCharacterInSession(this, sessionId, charId, enterAs, charac->getRingAccess(), charac->getNewcomer()); // update the participant status sessionPart->setStatus(TSessionPartStatus::sps_animating); @@ -3406,7 +3406,7 @@ endOfWelcomeUserResult: if (wspSwitch == NULL) { // can't find a welcome service for this shard - + // try to read a shard status in the database CShardPtr shard = CShard::load(_RingDb, sessionId.asInt(), __FILE__, __LINE__); if (shard != NULL) @@ -3455,13 +3455,13 @@ endOfWelcomeUserResult: _PendingJoins.push_back(pjs); // reserve an entry place on the welcome service of the shard and wait for the response - wsp.welcomeUser(this, - charId, - nelUser->getLoginName(), - cookie, - nelUser->getPrivilege(), - nelUser->getExtendedPrivilege(), - enterAs, + wsp.welcomeUser(this, + charId, + nelUser->getLoginName(), + cookie, + nelUser->getPrivilege(), + nelUser->getExtendedPrivilege(), + enterAs, instanceId); // the rest of the code is done in 'welcomeUserResult' returned by the WS. @@ -3566,7 +3566,7 @@ endOfWelcomeUserResult: uint32 sessionNum; result->getField(0, sessionNum); TSessionId sessionId(sessionNum); - + // 2 : check that the character is invited in his session BOMB_IF(!character->loadSessionParticipants(_RingDb, __FILE__, __LINE__), "on_joinEditSession : failed to load session participants for char "<>4, TSessionId(0), 3, "Error loading partipation", TSessionPartStatus::invalid_val); return); uint i; @@ -3612,7 +3612,7 @@ endOfWelcomeUserResult: // ok, now call the normal join session _joinSessionCommon(from, charId, sessionId, clientApplication, true); } - + // Request to have the list of accessible shards with their attributes. virtual void on_getShards(NLNET::TSockId from, uint32 charId) { @@ -3645,7 +3645,7 @@ endOfWelcomeUserResult: } } } - + } getShardsResult(from, charId>>4, result); } @@ -3673,11 +3673,11 @@ endOfWelcomeUserResult: if (!hasSessionAccessPrivilege(userId)) { STOP("RSM : on_kickCharacter : char "<>4, 5, "Owner char don't own the session"); + invokeResult(from, ownerCharId>>4, 5, "Owner char don't own the session"); return; } } - + // load the participants BOMB_IF(!session->loadSessionParticipants(_RingDb, __FILE__, __LINE__), "RSM : on_kickCharacter : failed to load session participants for session "<>4, 4, "Failed to load session participants"); return); @@ -3733,7 +3733,7 @@ endOfWelcomeUserResult: if (!hasSessionAccessPrivilege(userId)) { STOP("RSM : on_unkickCharacter : char "<>4, 5, "Owner char don't own the session"); + invokeResult(from, ownerCharId>>4, 5, "Owner char don't own the session"); return; } } @@ -3775,7 +3775,7 @@ endOfWelcomeUserResult: // 5 : char don't own the session virtual void on_inviteGuild(NLNET::TSockId from, uint32 charId, TSessionId sessionId, uint32 guildId) { - nldebug("RSM : onInviteGuild char %u invite guild %u in session %u", + nldebug("RSM : onInviteGuild char %u invite guild %u in session %u", charId, guildId, sessionId.asInt()); @@ -3830,10 +3830,10 @@ endOfWelcomeUserResult: invite->setGuildId(guildId); invite->setSessionId(sessionId.asInt()); - + // store the new invite invite->create(_RingDb); - + // result ok invokeResult(from, charId>>4, 0, ""); } @@ -3847,7 +3847,7 @@ endOfWelcomeUserResult: // 5 : char don't own the session virtual void on_removeInvitedGuild(NLNET::TSockId from, uint32 charId, TSessionId sessionId, uint32 guildId) { - nldebug("RSM : removeInvitedGuild char %u revoke invitattion for guild %u in session %u", + nldebug("RSM : removeInvitedGuild char %u revoke invitattion for guild %u in session %u", charId, guildId, sessionId.asInt()); @@ -3919,13 +3919,13 @@ endOfWelcomeUserResult: // 2 : user not owner of session // 3 : user not found // 4 : session not found -// virtual void on_setScenarioInfo(NLNET::TSockId from, -// uint32 userId, -// TSessionId sessionId, -// const std::string &title, -// const std::string &journal, -// const std::string &credits, -// uint32 numPlayer, +// virtual void on_setScenarioInfo(NLNET::TSockId from, +// uint32 userId, +// TSessionId sessionId, +// const std::string &title, +// const std::string &journal, +// const std::string &credits, +// uint32 numPlayer, // const std::string &playType) virtual void on_setScenarioInfo(NLNET::TSockId from, uint32 charId, TSessionId sessionId, const std::string &title, uint32 numPlayer, const std::string &playType) { @@ -3955,7 +3955,7 @@ endOfWelcomeUserResult: // invokeResult(from, charId>>4, 2, "Character don't own the session"); // return; // } -// +// // // load the scenario desc // CScenarioDescPtr scenario = CScenarioDesc::load(_RingDb, sessionId.asInt(), __FILE__, __LINE__); // if (scenario == NULL) @@ -3968,7 +3968,7 @@ endOfWelcomeUserResult: // scenario->setTitle(title); // //oups, data do not matchs // nlstop; -// +// invokeResult(from, charId>>4, 100, "Deprecatted"); }; @@ -3982,10 +3982,10 @@ endOfWelcomeUserResult: // 5 : user participation not found // 6 : character not found // 7 : invalid params - virtual void on_addJournalEntry(NLNET::TSockId from, - uint32 charId, - TSessionId sessionId, - const std::string &entryType, + virtual void on_addJournalEntry(NLNET::TSockId from, + uint32 charId, + TSessionId sessionId, + const std::string &entryType, const std::string &text) { nldebug("RSM : addJournalEntry char %u add an entry in journal of session %u", charId, sessionId.asInt()); @@ -4075,11 +4075,11 @@ endOfWelcomeUserResult: // 6 : session not found // 7 : scenario not found // 8 : internal error - virtual void on_setPlayerRating(NLNET::TSockId from, uint32 charId, TSessionId sessionId, - uint32 rateFun, - uint32 rateDifficulty, - uint32 rateAccessibility, - uint32 rateOriginality, + virtual void on_setPlayerRating(NLNET::TSockId from, uint32 charId, TSessionId sessionId, + uint32 rateFun, + uint32 rateDifficulty, + uint32 rateAccessibility, + uint32 rateOriginality, uint32 rateDirection) { nldebug("Web set player rating from char %u to session %u as %u,%u,%u,%u, %u", @@ -4106,14 +4106,14 @@ endOfWelcomeUserResult: if (sp->getKicked() == true) { - invokeResult(from, charId>>4, 5, "Char is banned from the session"); + invokeResult(from, charId>>4, 5, "Char is banned from the session"); return; } break; } } - BOMB_IF(i == character->getSessionParticipants().size(), + BOMB_IF(i == character->getSessionParticipants().size(), "No participation found for char "<>4, 3, "No participation found in session"); return); // retrieve the scenario data @@ -4216,7 +4216,7 @@ endOfWelcomeUserResult: } - + NLMISC_COMMAND_HANDLER_TABLE_EXTEND_BEGIN(CRingSessionManager, CModuleBase) NLMISC_COMMAND_HANDLER_ADD(CRingSessionManager, dump, "dump the session manager internal state", "no param"); NLMISC_COMMAND_HANDLER_ADD(CRingSessionManager, forceSessionCleanup, "force a database synchronisation with current running session", "no param"); @@ -4245,7 +4245,7 @@ endOfWelcomeUserResult: log.displayNL("failed to load session %u", sessionId); return true; } - + // load the participants if (!session->loadSessionParticipants(_RingDb, __FILE__, __LINE__)) { @@ -4355,19 +4355,19 @@ endOfWelcomeUserResult: if (args.size() > 2) { shard->setMOTD(args[2]); - log.displayNL("Shard %u set required state to '%s' with message '%s'", + log.displayNL("Shard %u set required state to '%s' with message '%s'", shardId, al.toString().c_str(), args[2].c_str()); } else { - log.displayNL("Shard %u set required state to '%s'", + log.displayNL("Shard %u set required state to '%s'", shardId, al.toString().c_str()); shard->setMOTD(""); } - + // update WSState if possible @@ -4376,7 +4376,7 @@ endOfWelcomeUserResult: return true; } - + NLMISC_CLASS_COMMAND_DECL(forceSessionCleanup) { if (!_RingDb.query(string("SELECT session_id FROM sessions WHERE state = ")+toString(uint32(TSessionState::ss_open)))) @@ -4437,8 +4437,8 @@ endOfWelcomeUserResult: log.displayNL(" + Welcome service '%s' for shard %u", wsInfo.WSModuleProxy->getModuleName().c_str(), shardId); if (wsInfo.FixedSessionId.asInt() != 0) log.displayNL(" Mainland sessionId: %u", wsInfo.FixedSessionId.asInt()); - log.displayNL(" Access State = '%s', online = %s, message = '%s'", - wsInfo.ShardInfo->getRequiredState().toString().c_str(), + log.displayNL(" Access State = '%s', online = %s, message = '%s'", + wsInfo.ShardInfo->getRequiredState().toString().c_str(), wsInfo.ShardInfo->getWSOnline() ? "true" : "false", wsInfo.ShardInfo->getMOTD().c_str()); log.displayNL(" %u online players", wsInfo.NbOnlinePlayers); @@ -4455,7 +4455,7 @@ endOfWelcomeUserResult: { IModuleProxy *server = first->first; TSessionServerInfo &ssi = first->second; - + log.displayNL(" + Session server '%s' :", server->getModuleName().c_str()); log.displayNL(" Shard ID = %u", ssi.ShardId); log.displayNL(" Total player = %u", ssi.NbTotalPlayingChars); @@ -4479,9 +4479,9 @@ endOfWelcomeUserResult: return true; } - - }; + + }; NLNET_REGISTER_MODULE_FACTORY(CRingSessionManager, RingSessionManagerClassName); diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.module b/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.module index e5e184556..f09b06a37 100644 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.module +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.module @@ -659,12 +659,12 @@ function createPermissions($values) { $sth = $dbh->prepare("SELECT UId FROM user WHERE Login='" . $values[0] . "';"); $sth->execute(); $result = $sth->fetchAll(); - foreach ($result as $UId) { + /*foreach ($result as $UId) { $statement = $dbh->prepare("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES ('" . $UId['UId'] . "', 'r2', 'OPEN');"); $statement->execute($values); $statement = $dbh->prepare("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES ('" . $UId['UId'] . "', 'ryzom_open', 'OPEN');"); $statement->execute($values); - } + }*///FIXME: GARBAGE } catch (PDOException $e) { watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); diff --git a/code/web/private_php/ams/autoload/sync.php b/code/web/private_php/ams/autoload/sync.php index a3bf6fdb2..f989e3e59 100644 --- a/code/web/private_php/ams/autoload/sync.php +++ b/code/web/private_php/ams/autoload/sync.php @@ -6,12 +6,12 @@ * @author Daan Janssens, mentored by Matthew Lagoe */ class Sync{ - + const OS_UNKNOWN = 1; const OS_WIN = 2; const OS_LINUX = 3; const OS_OSX = 4; - + /** * performs the actions listed in the querycache. * All entries in the querycache will be read and performed depending on their type. @@ -19,13 +19,13 @@ class Sync{ * These changes are: createPermissions, createUser, change_pass, change_mail */ static public function syncdata ($display = false) { - + if (function_exists('pcntl_fork')) { $pid = pcntl_fork(); } global $AMS_TMPDIR; $pidfile = $AMS_TMPDIR.'/ams_cron_pid'; - + if(isset($pid) and function_exists('pcntl_fork') ) { // We're the main process. } else { @@ -43,9 +43,9 @@ class Sync{ try { $dbl = new DBLayer("lib"); $statement = $dbl->executeWithoutParams("SELECT * FROM ams_querycache"); - $rows = $statement->fetchAll(); + $rows = $statement->fetchAll(); foreach ($rows as $record) { - + $db = new DBLayer($record['db']); switch($record['type']) { case 'createPermissions': @@ -54,32 +54,32 @@ class Sync{ //make connection with and put into shard db & delete from the lib $sth=$db->selectWithParameter("UId", "user", $values, "Login= :username" ); $result = $sth->fetchAll(); - foreach ($result as $UId) { + /*foreach ($result as $UId) { $ins_values = array('UId' => $UId['UId']); $ins_values['ClientApplication'] = "r2"; $ins_values['AccessPrivilege'] = "OPEN"; $db->insert("permission", $ins_values); $ins_values['ClientApplication'] = 'ryzom_open'; $db->insert("permission",$ins_values); - } + }*/ // FIXME: GARBAGE break; case 'change_pass': $decode = json_decode($record['query']); $values = array('Password' => $decode[1]); //make connection with and put into shard db & delete from the lib - $db->update("user", $values, "Login = '$decode[0]'"); + $db->update("user", $values, "Login = '$decode[0]'"); break; case 'change_mail': $decode = json_decode($record['query']); $values = array('Email' => $decode[1]); //make connection with and put into shard db & delete from the lib - $db->update("user", $values, "Login = '$decode[0]'"); + $db->update("user", $values, "Login = '$decode[0]'"); break; - case 'createUser': + case 'createUser': $decode = json_decode($record['query']); $values = array('Login' => $decode[0], 'Password' => $decode[1], 'Email' => $decode[2] ); //make connection with and put into shard db & delete from the lib - $db->insert("user", $values); + $db->insert("user", $values); break; } $dbl->delete("ams_querycache", array('SID' => $record['SID']), "SID=:SID"); @@ -99,11 +99,11 @@ class Sync{ } } - + public static function check_pid($pid){ - + $OS = Sync::getOS(); - + if ($OS == 2) { $processes = explode( "\n", shell_exec( "tasklist.exe" )); foreach( $processes as $process ) @@ -117,7 +117,7 @@ class Sync{ } } else { return file_exists( "/proc/$pid" ); - } + } } static public function getOS() { switch (true) { diff --git a/code/web/private_php/ams/autoload/users.php b/code/web/private_php/ams/autoload/users.php index 1754a4f05..cde30cf63 100644 --- a/code/web/private_php/ams/autoload/users.php +++ b/code/web/private_php/ams/autoload/users.php @@ -25,7 +25,7 @@ class Users{ $cpass = ""; $email = ""; } - + if ( helpers :: check_if_game_client() or isset($FORCE_INGAME) ) { if ( isset( $_POST["TaC"] )) { $tac="success"; @@ -336,12 +336,12 @@ class Users{ $dbs = new DBLayer("shard"); $sth = $dbs->selectWithParameter("UId", "user", $values, "Login= :username"); $result = $sth->fetchAll(); - foreach ($result as $UId) { + /*foreach ($result as $UId) { $ins_values = array('UId' => $UId['UId'], 'clientApplication' => 'r2', 'AccessPrivilege' => 'OPEN'); $dbs->insert("permission", $ins_values); $ins_values['clientApplication'] = 'ryzom_open'; $dbs->insert("permission", $ins_values); - } + }*/ // FIXME: GARBAGE } catch (PDOException $e) { //oh noooz, the shard is offline! Put it in query queue at ams_lib db! diff --git a/code/web/private_php/setup/sql/nel_00002.sql b/code/web/private_php/setup/sql/nel_00002.sql new file mode 100644 index 000000000..74a59d980 --- /dev/null +++ b/code/web/private_php/setup/sql/nel_00002.sql @@ -0,0 +1,5 @@ +ALTER TABLE `permission` CHANGE `ClientApplication` `ClientApplication` CHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ; +ALTER TABLE `permission` DROP `prim` ; +ALTER TABLE `permission` ADD `PermissionId` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST ; +ALTER TABLE `permission` ADD `DomainId` INT NOT NULL DEFAULT '-1' AFTER `UId` ; +ALTER TABLE `permission` DROP `ClientApplication` ; diff --git a/code/web/public_php/login/r2_login.php b/code/web/public_php/login/r2_login.php index 8e97aafae..a1bccc13a 100644 --- a/code/web/public_php/login/r2_login.php +++ b/code/web/public_php/login/r2_login.php @@ -176,7 +176,6 @@ // if we need to create missing ring info if ($AutoCreateRingInfo) { - ////////////// Temporary code alpha 0 only ///////////////////////////////////// // check if the ring user exist, and create it if not $ringDb = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword) or die(errorMsgBlock(3004, 'Ring', $DBHost, $RingDBUserName)); mysqli_select_db ($ringDb, $domainInfo['ring_db_name']) or die(errorMsgBlock(3005, 'Ring', $domainInfo['ring_db_name'], $DBHost, $RingDBUserName)); @@ -190,17 +189,6 @@ $query = "INSERT INTO ring_users SET user_id = '$id', user_name = '$login', user_type='ut_pioneer'"; $result = mysqli_query ($ringDb, $query) or die(errorMsgBlock(3006, $query, 'Ring', $domainInfo['ring_db_name'], $DBHost, $RingDBUserName, mysqli_error($ringDb))); } - -// // check that there is a character record (deprecated) -// $query = "SELECT user_id FROM characters where user_id = '".$id."'"; -// $result = mysqli_query ($ringDb, $query) or die("Query ".$query." failed"); -// if (mysqli_num_rows($result) == 0) -// { -// // no characters record, build a default one -// $charId = ($id * 16); -// $query = "INSERT INTO characters SET char_id='".$charId."', char_name='".$_GET["login"]."_default', user_id = '".$id."'"; -// $result = mysqli_query ($ringDb, $query) or die("Query ".$query." failed"); -// } } // // check domain status @@ -324,7 +312,7 @@ $extended = $row["ExtendedPrivilege"]; // add the default permission - $query = "INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES ('$id', 'r2', '$accessPriv')"; + $query = "INSERT INTO permission (UId, DomainId, AccessPrivilege) VALUES ('$id', '$domainId', '$accessPriv')"; $result = mysqli_query ($link, $query) or die (errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link))); $res = false; @@ -338,40 +326,6 @@ else { $reason = errorMsg(2001, $login, 'checkUserValidity'); - // Check if this is not an unconfirmed account - /* - $query = "SELECT GamePassword, Email, Language FROM signup_data WHERE login='$login'"; - $result = mysqli_query($link, $query) or die (errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link))); - - if (mysqli_num_rows($result) == 0) - { - $reason = errorMsg(2001, $login, 'checkUserValidity'); - $res = false; - } - else - { - // Check password to avoid revealing email address to third-party - $passwordMatchedRow = false; - while ($row = mysqli_fetch_assoc($result)) - { - $salt = substr($row['GamePassword'],0,2); - if (($cp && $row['GamePassword'] == $password) || (!$cp && $row['GamePassword'] == crypt($password, $salt))) - { - $passwordMatchedRow = $row; - break; - } - } - if ($passwordMatchedRow !== false) - { - if ($lang == 'unknown') - setMsgLanguage($passwordMatchedRow['Language']); - $reason = errorMsg(2002, $passwordMatchedRow['Email']); - } - else - $reason = errorMsg(2004, 'db signup_data'); - $res = false; - } - */ } } else @@ -385,14 +339,14 @@ // check if the user can use this application $clientApplication = mysqli_real_escape_string($link, $clientApplication); - $query = "SELECT * FROM permission WHERE UId='".$row["UId"]."' AND ClientApplication='$clientApplication'"; + $query = "SELECT * FROM permission WHERE UId='".$row["UId"]."' AND DomainId='$domainId'"; $result = mysqli_query ($link, $query) or die (errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link))); if (mysqli_num_rows ($result) == 0) { if ($AcceptUnknownUser) { // add default permission - $query = "INSERT INTO permission (UId, ClientApplication, ShardId, AccessPrivilege) VALUES ('".$row["UId"]."', '$clientApplication', -1, '$domainStatus')"; + $query = "INSERT INTO permission (UId, DomainId, ShardId, AccessPrivilege) VALUES ('".$row["UId"]."', '$domainId', -1, '$domainStatus')"; $result = mysqli_query ($link, $query) or die (errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link))); $reason = errorMsg(3010); @@ -416,7 +370,7 @@ if ($AcceptUnknownUser) { // set an additionnal privilege for this player - $query = "UPDATE permission set AccessPrivilege='".$permission['AccessPrivilege'].",$accessPriv' WHERE prim=".$permission['prim']; + $query = "UPDATE permission set AccessPrivilege='".$permission['AccessPrivilege'].",$accessPriv' WHERE PermissionId=".$permission['PermissionId']; $result = mysqli_query ($link, $query) or die (errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link))); $reason = errorMsg(3012, $accessPriv); diff --git a/code/web/public_php/setup/database.php b/code/web/public_php/setup/database.php index 564e74039..37e5ce50b 100644 --- a/code/web/public_php/setup/database.php +++ b/code/web/public_php/setup/database.php @@ -57,6 +57,10 @@ function upgrade_service_databases($continue_r) { $continue = update_database_structure($continue, $con, "nel_00001.sql"); $continue = set_db_version($continue, "shard", 1); } + if ($continue && get_db_version("shard") < 2) { + $continue = update_database_structure($continue, $con, "nel_00002.sql"); + $continue = set_db_version($continue, "shard", 2); + } disconnect_database($con, "shard"); $con = null; diff --git a/code/web/public_php/setup/install.php b/code/web/public_php/setup/install.php index cc9972f8d..7eb3a7925 100644 --- a/code/web/public_php/setup/install.php +++ b/code/web/public_php/setup/install.php @@ -34,6 +34,13 @@ include('header.php'); $continue = false; } + if ($continue) { + if (!extension_loaded('mcrypt')) { + printalert("danger", "The mcrypt extension is missing. Please check your PHP configuration"); + $continue = false; + } + } + // Validate basics if ($continue) { if (file_exists($_POST["privatePhpDirectory"])) { diff --git a/code/web/public_php/setup/upgrade.php b/code/web/public_php/setup/upgrade.php index b29c04e2c..cc157a997 100644 --- a/code/web/public_php/setup/upgrade.php +++ b/code/web/public_php/setup/upgrade.php @@ -28,6 +28,13 @@ if (!isset($NEL_SETUP_VERSION_CONFIGURED)) { require_once('database.php'); + if ($continue) { + if (!extension_loaded('mcrypt')) { + printalert("danger", "The mcrypt extension is missing. Please check your PHP configuration"); + $continue = false; + } + } + if (file_exists("role_support")) { $continue = upgrade_support_databases($continue); } From 57564a8ab0562555ef76e2281d1397c5d644bd4f Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 7 Sep 2014 09:10:23 +0200 Subject: [PATCH 24/93] Cleanup shard table --- code/web/private_php/setup/sql/nel_00003.sql | 6 ++++++ code/web/public_php/setup/database.php | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 code/web/private_php/setup/sql/nel_00003.sql diff --git a/code/web/private_php/setup/sql/nel_00003.sql b/code/web/private_php/setup/sql/nel_00003.sql new file mode 100644 index 000000000..c3ec6c033 --- /dev/null +++ b/code/web/private_php/setup/sql/nel_00003.sql @@ -0,0 +1,6 @@ +ALTER TABLE `shard` DROP `prim` ; +ALTER TABLE `shard` ADD PRIMARY KEY ( `ShardId` ) ; +ALTER TABLE `shard` DROP `PatchURL` ; +ALTER TABLE `shard` DROP `DynPatchURL` ; +ALTER TABLE `shard` DROP `ClientApplication` ; + diff --git a/code/web/public_php/setup/database.php b/code/web/public_php/setup/database.php index 37e5ce50b..16ab10dcd 100644 --- a/code/web/public_php/setup/database.php +++ b/code/web/public_php/setup/database.php @@ -61,6 +61,10 @@ function upgrade_service_databases($continue_r) { $continue = update_database_structure($continue, $con, "nel_00002.sql"); $continue = set_db_version($continue, "shard", 2); } + if ($continue && get_db_version("shard") < 3) { + $continue = update_database_structure($continue, $con, "nel_00003.sql"); + $continue = set_db_version($continue, "shard", 3); + } disconnect_database($con, "shard"); $con = null; From 6a47cda484bb32eef6ec8f5ee721936958643580 Mon Sep 17 00:00:00 2001 From: botanic Date: Sun, 7 Sep 2014 03:17:20 -0700 Subject: [PATCH 25/93] added initial domain_management plugin, also fixed potental conflicting hook names --- .../private_php/ams/autoload/plugincache.php | 9 +- .../API_key_management/API_key_management.php | 1 + .../ams/plugins/Achievements/Achievements.php | 1 + .../ams/plugins/Domain_Management/.info | 8 + .../Domain_Management/Domain_Management.php | 201 ++++++++++++++++++ .../Domain_Management/templates/index.tpl | 54 +++++ .../public_php/ams/templates/layout_admin.tpl | 3 +- 7 files changed, 274 insertions(+), 3 deletions(-) create mode 100644 code/web/private_php/ams/plugins/Domain_Management/.info create mode 100644 code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php create mode 100644 code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl diff --git a/code/web/private_php/ams/autoload/plugincache.php b/code/web/private_php/ams/autoload/plugincache.php index 29a2172cb..20bbb0b25 100644 --- a/code/web/private_php/ams/autoload/plugincache.php +++ b/code/web/private_php/ams/autoload/plugincache.php @@ -261,8 +261,13 @@ class Plugincache { $arr = get_defined_functions(); foreach ($arr['user'] as $key => $value) { - if (stristr( $value, $plugin_name) == true) { - $content['hook_info'][$plugin_name] = call_user_func($value); + switch (strtolower($value)) { + case strtolower($plugin_name).'_hook_display': + case strtolower($plugin_name).'_hook_call_rest': + case strtolower($plugin_name).'_hook_get_db': + case strtolower($plugin_name).'_hook_return_global': + $content['hook_info'][$plugin_name] = call_user_func($value); + break; } } // path for the template diff --git a/code/web/private_php/ams/plugins/API_key_management/API_key_management.php b/code/web/private_php/ams/plugins/API_key_management/API_key_management.php index 8f2e6158b..09c895624 100644 --- a/code/web/private_php/ams/plugins/API_key_management/API_key_management.php +++ b/code/web/private_php/ams/plugins/API_key_management/API_key_management.php @@ -27,6 +27,7 @@ function api_key_management_hook_display() global $return_set; // to display plugin name in menu bar $return_set['menu_display'] = 'API Key Management'; + $return_set['icon'] = 'icon-download-alt'; } /** diff --git a/code/web/private_php/ams/plugins/Achievements/Achievements.php b/code/web/private_php/ams/plugins/Achievements/Achievements.php index 79c117893..47f39b9d8 100644 --- a/code/web/private_php/ams/plugins/Achievements/Achievements.php +++ b/code/web/private_php/ams/plugins/Achievements/Achievements.php @@ -31,6 +31,7 @@ function achievements_hook_display() global $return_set; // to display plugin name in menu bar $return_set['menu_display'] = 'Achievements'; + $return_set['icon'] = 'icon-certificate'; } /** diff --git a/code/web/private_php/ams/plugins/Domain_Management/.info b/code/web/private_php/ams/plugins/Domain_Management/.info new file mode 100644 index 000000000..502846e4f --- /dev/null +++ b/code/web/private_php/ams/plugins/Domain_Management/.info @@ -0,0 +1,8 @@ +PluginName = Domain_Management +Description = Plug-in for Domain Management. +Version = 1.0.0 +TemplatePath = ../../../private_php/ams/plugins/Domain_Management/templates/index.tpl +Type = Manual + + + diff --git a/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php b/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php new file mode 100644 index 000000000..4c8f44f54 --- /dev/null +++ b/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php @@ -0,0 +1,201 @@ + select( 'ams_api_keys', $data , 'User = :User AND UserCharacter = :UserCharacter' ); + $row = $sth -> fetchAll(); + return $row; + } + +/** + * Local Hook to get database content + * which is called by the global hook + * by passing a parameter + * + * This hook returns the id of the character + * whose achivements we have to get + * + * @param $data array with respective information + * @return $row extracted db content wrt $data + */ +function domain_management_get_char_id( $data ) + { + // returns the character id with respect to the character name in the ring_tool->characters + $db = new DBLayer( 'ring' ); + $sth = $db -> selectWithParameter( 'char_id', 'characters' , array( 'char_name' => $data ), 'char_name=:char_name' ); + $row = $sth -> fetch(); + return $row['char_id']; + } + +/** + * Local Hook to get database content + * which is called by the global hook + * by passing a parameter + * + * Hook to get the player stats of the character + * + * @param $data array with respective information + * @return $row extracted db content wrt $data + */ +function domain_management_get_player_stat( $data ) + { + // returns the character id with respect to the character name in the ring_tool->characters + $db = new DBLayer( 'webig' ); + $sth = $db -> select( 'players' , array( 'name' => $data ), 'name=:name' ); + $row = $sth -> fetch(); + return $row; + } + +/** + * Local Hook to set variables which contains + * the content to use during the plugin functionality. + */ +function domain_management_variable_set() + { + global $return_set; + global $var_set; + if ( isset( $_POST['Character'] ) && !empty( $_POST['Character'] ) ) + { + $var_set['character'] = $_POST['Character']; + + // get char id from ring_open table + if ( $var_set['character'] != 'All Characters' ) + { + $var_set['char_id'] = domain_management_get_char_id( $var_set['character'] ); + + } + + // get db content for variable set + $row = domain_management_get_db_content( array( 'User' => $_SESSION['user'], 'UserCharacter' => $var_set['character'] ) ); + + // access key automatically taken from the database wrt user and character + @$var_set['app_key'] = $row['AccessToken']; + + // here you can set the host where this plugin is set + $var_set['host'] = 'localhost'; + + // here we get the stats of the character + $ref_set = domain_management_get_player_stat( $var_set['character'] ); + + // here we have set items that are required to get the achivements + // these are player stats from webig->players table + @$var_set['items'] = json_encode( array( 'dev_shard' => $ref_set['dev_shard'] , 'name' => $ref_set['name'] , 'cid' => $ref_set['cid'] , 'lang' => 'en' , 'translater_mode' => '', 'last_played_date' => $ref_set['last_login'] ) ); + + // url where we have to make request for domain_management + // it sends get parameter search(what to search) and format(in which format data exchange takes place) + $var_set['url'] = 'http://localhost6/?search=domain_management&&format=json'; + } + else + { + $return_set['no_char'] = "Please Generate key for a character before requesting for domain_management"; + } + } + +/** + * Global Hook to interact with the REST api + * Pass the variables in the REST object to + * make request + * + * variables REST object expects + * url --> on which request is to be made + * appkey --> app key for authentication + * host --> host from which request have been sent + * + * @return $return_set global array returns the template data + */ +function domain_management_hook_call_rest() + { + // defined the variables + global $var_set; + global $return_set; + + if ( isset( $_POST['get_data'] ) ) + { + domain_management_variable_set(); + // here we make the REST connection + $rest_api = new Rest_Api(); + $ach_data = $rest_api -> request( $var_set['url'], $var_set['app_key'], $var_set['host'], $var_set['items'] ); + // here we store the response we get from the server + $return_set['char_domain_management'] = $ach_data ; + } + } + +/** + * Global Hook to return global variables which contains + * the content to use in the smarty templates extracted from + * the database + * + * @return $return_set global array returns the template data + */ +function domain_management_hook_get_db() + { + global $return_set; + + if ( isset( $_SESSION['user'] ) ) + { + $db = new DBLayer( 'lib' ); + + // getting content for selecting characters + $sth = $db -> selectWithParameter( 'UserCharacter', 'ams_api_keys', array( 'User' => $_SESSION['user'] ) , 'User = :User' ); + $row = $sth -> fetch(); + $return_set['Character'] = $row; + } + } + +/** + * Global Hook to return global variables which contains + * the content to use in the smarty templates + * + * @return $return_set global array returns the template data + */ +function domain_management_hook_return_global() + { + global $return_set; + return $return_set; + } diff --git a/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl b/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl new file mode 100644 index 000000000..eb0c770da --- /dev/null +++ b/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl @@ -0,0 +1,54 @@ +{block name=content} + +{if isset($smarty.get.plugin_action) and $smarty.get.plugin_action eq 'get_domain_management'} +
+
+
+
+

Domain_Management

+
+
+ {if isset($hook_info.Domain_Management.no_char)}

{$hook_info.Domain_Management.no_char}

{/if} +
+ {$hook_info.Domain_Management.char_domain_management} +
+
+
+
+
+{else} +
+
+
+
+

Select your Character

+
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+
+
+
+{/if} +{/block} diff --git a/code/web/public_php/ams/templates/layout_admin.tpl b/code/web/public_php/ams/templates/layout_admin.tpl index 54307b5bc..12ff65c40 100644 --- a/code/web/public_php/ams/templates/layout_admin.tpl +++ b/code/web/public_php/ams/templates/layout_admin.tpl @@ -4,11 +4,12 @@
  • Dashboard
  • Profile
  • Settings
  • - {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}
  • {$element.menu_display}
  • {/foreach}{/if} + {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}{if isset($element.menu_display)}
  • {$element.menu_display}
  • {/if}{/foreach}{/if}
  • Users
  • Queues
  • Support Groups
  • + {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}{if isset($element.admin_menu_display)}
  • {$element.admin_menu_display}
  • {/if}{/foreach}{/if}
  • Plugins
  • Syncing
  • From 3601eae39bd558bb89219a7f58516c1f10f1e0d7 Mon Sep 17 00:00:00 2001 From: botanic Date: Sun, 7 Sep 2014 05:39:48 -0700 Subject: [PATCH 26/93] Initial Domain Management Plugin --- .../ams/plugins/Achievements/Achievements.php | 30 +-- .../plugins/Achievements/templates/index.tpl | 1 - .../Domain_Management/Domain_Management.php | 68 ++--- .../Domain_Management/templates/index.tpl | 251 ++++++++++++++---- .../public_php/ams/templates/layout_admin.tpl | 4 +- .../public_php/ams/templates/layout_mod.tpl | 2 +- .../public_php/ams/templates/layout_user.tpl | 2 +- 7 files changed, 258 insertions(+), 100 deletions(-) diff --git a/code/web/private_php/ams/plugins/Achievements/Achievements.php b/code/web/private_php/ams/plugins/Achievements/Achievements.php index 47f39b9d8..13404598b 100644 --- a/code/web/private_php/ams/plugins/Achievements/Achievements.php +++ b/code/web/private_php/ams/plugins/Achievements/Achievements.php @@ -17,7 +17,7 @@ // Global variable to store the data which is // returned to the templates -$return_set = array(); +$achievements_return_set = array(); // Local variable to store data during // functionalities of the hooks @@ -28,10 +28,10 @@ $var_set = array(); */ function achievements_hook_display() { - global $return_set; + global $achievements_return_set; // to display plugin name in menu bar - $return_set['menu_display'] = 'Achievements'; - $return_set['icon'] = 'icon-certificate'; + $achievements_return_set['menu_display'] = 'Achievements'; + $achievements_return_set['icon'] = 'icon-certificate'; } /** @@ -98,7 +98,7 @@ function hook_get_player_stat( $data ) */ function hook_variable_set() { - global $return_set; + global $achievements_return_set; global $var_set; if ( isset( $_POST['Character'] ) && !empty( $_POST['Character'] ) ) { @@ -133,7 +133,7 @@ function hook_variable_set() } else { - $return_set['no_char'] = "Please Generate key for a character before requesting for achievements"; + $achievements_return_set['no_char'] = "Please Generate key for a character before requesting for achievements"; } } @@ -147,13 +147,13 @@ function hook_variable_set() * appkey --> app key for authentication * host --> host from which request have been sent * - * @return $return_set global array returns the template data + * @return $achievements_return_set global array returns the template data */ function achievements_hook_call_rest() { // defined the variables global $var_set; - global $return_set; + global $achievements_return_set; if ( isset( $_POST['get_data'] ) ) { @@ -162,7 +162,7 @@ function achievements_hook_call_rest() $rest_api = new Rest_Api(); $ach_data = $rest_api -> request( $var_set['url'], $var_set['app_key'], $var_set['host'], $var_set['items'] ); // here we store the response we get from the server - $return_set['char_achievements'] = $ach_data ; + $achievements_return_set['char_achievements'] = $ach_data ; } } @@ -171,11 +171,11 @@ function achievements_hook_call_rest() * the content to use in the smarty templates extracted from * the database * - * @return $return_set global array returns the template data + * @return $achievements_return_set global array returns the template data */ function achievements_hook_get_db() { - global $return_set; + global $achievements_return_set; if ( isset( $_SESSION['user'] ) ) { @@ -184,7 +184,7 @@ function achievements_hook_get_db() // getting content for selecting characters $sth = $db -> selectWithParameter( 'UserCharacter', 'ams_api_keys', array( 'User' => $_SESSION['user'] ) , 'User = :User' ); $row = $sth -> fetch(); - $return_set['Character'] = $row; + $achievements_return_set['Character'] = $row; } } @@ -192,10 +192,10 @@ function achievements_hook_get_db() * Global Hook to return global variables which contains * the content to use in the smarty templates * - * @return $return_set global array returns the template data + * @return $achievements_return_set global array returns the template data */ function achievements_hook_return_global() { - global $return_set; - return $return_set; + global $achievements_return_set; + return $achievements_return_set; } diff --git a/code/web/private_php/ams/plugins/Achievements/templates/index.tpl b/code/web/private_php/ams/plugins/Achievements/templates/index.tpl index b88b5730a..be0306fe1 100644 --- a/code/web/private_php/ams/plugins/Achievements/templates/index.tpl +++ b/code/web/private_php/ams/plugins/Achievements/templates/index.tpl @@ -1,5 +1,4 @@ {block name=content} - {if isset($smarty.get.plugin_action) and $smarty.get.plugin_action eq 'get_achievements'}
    diff --git a/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php b/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php index 4c8f44f54..359c9289e 100644 --- a/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php +++ b/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php @@ -17,7 +17,7 @@ // Global variable to store the data which is // returned to the templates -$return_set = array(); +$domain_management_return_set = array(); // Local variable to store data during // functionalities of the hooks @@ -28,10 +28,10 @@ $var_set = array(); */ function domain_management_hook_display() { - global $return_set; + global $domain_management_return_set; // to display plugin name in menu bar - $return_set['admin_menu_display'] = 'Domain Management'; - $return_set['icon'] = 'icon-edit'; + $domain_management_return_set['admin_menu_display'] = 'Domain Management'; + $domain_management_return_set['icon'] = 'icon-edit'; } /** @@ -98,7 +98,7 @@ function domain_management_get_player_stat( $data ) */ function domain_management_variable_set() { - global $return_set; + global $domain_management_return_set; global $var_set; if ( isset( $_POST['Character'] ) && !empty( $_POST['Character'] ) ) { @@ -133,7 +133,7 @@ function domain_management_variable_set() } else { - $return_set['no_char'] = "Please Generate key for a character before requesting for domain_management"; + $domain_management_return_set['no_char'] = "Please Generate key for a character before requesting for domain_management"; } } @@ -147,23 +147,16 @@ function domain_management_variable_set() * appkey --> app key for authentication * host --> host from which request have been sent * - * @return $return_set global array returns the template data + * @return $domain_management_return_set global array returns the template data */ function domain_management_hook_call_rest() { - // defined the variables - global $var_set; - global $return_set; + + global $domain_management_return_set; + global $WEBPATH; - if ( isset( $_POST['get_data'] ) ) - { - domain_management_variable_set(); - // here we make the REST connection - $rest_api = new Rest_Api(); - $ach_data = $rest_api -> request( $var_set['url'], $var_set['app_key'], $var_set['host'], $var_set['items'] ); - // here we store the response we get from the server - $return_set['char_domain_management'] = $ach_data ; - } + $domain_management_return_set['path'] = $WEBPATH; + } /** @@ -171,31 +164,42 @@ function domain_management_hook_call_rest() * the content to use in the smarty templates extracted from * the database * - * @return $return_set global array returns the template data + * @return $domain_management_return_set global array returns the template data */ function domain_management_hook_get_db() { - global $return_set; + global $domain_management_return_set; - if ( isset( $_SESSION['user'] ) ) - { - $db = new DBLayer( 'lib' ); + $db = new DBLayer( 'shard' ); - // getting content for selecting characters - $sth = $db -> selectWithParameter( 'UserCharacter', 'ams_api_keys', array( 'User' => $_SESSION['user'] ) , 'User = :User' ); - $row = $sth -> fetch(); - $return_set['Character'] = $row; - } + //get all domains + $statement = $db->executeWithoutParams("SELECT * FROM domain"); + $rows = $statement->fetchAll(); + $domain_management_return_set['domains'] = $rows; + + if (isset($_GET['edit_domain'])){ + //get permissions + $statement = $db->executeWithoutParams("SELECT * FROM `permission` WHERE `ClientApplication` = '".$rows[$_GET['edit_domain']-1]['domain_name']."'"); + $rows = $statement->fetchAll(); + $domain_management_return_set['permissions'] = $rows; + + //get all users + $pagination = new Pagination(WebUsers::getAllUsersQuery(),"web",10,"WebUsers"); + $domain_management_return_set['userlist'] = Gui_Elements::make_table($pagination->getElements() , Array("getUId","getUsername","getEmail"), Array("id","username","email")); + + } + + return $rows; } /** * Global Hook to return global variables which contains * the content to use in the smarty templates * - * @return $return_set global array returns the template data + * @return $domain_management_return_set global array returns the template data */ function domain_management_hook_return_global() { - global $return_set; - return $return_set; + global $domain_management_return_set; + return $domain_management_return_set; } diff --git a/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl b/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl index eb0c770da..d49edc89e 100644 --- a/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl +++ b/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl @@ -1,54 +1,209 @@ {block name=content} -{if isset($smarty.get.plugin_action) and $smarty.get.plugin_action eq 'get_domain_management'} -
    -
    -
    -
    -

    Domain_Management

    -
    -
    - {if isset($hook_info.Domain_Management.no_char)}

    {$hook_info.Domain_Management.no_char}

    {/if} -
    - {$hook_info.Domain_Management.char_domain_management} +{if isset($smarty.get.edit_domain)} +
    +
    +
    +
    +

    {$hook_info['Domain_Management']['domains'][$smarty.get.edit_domain-1]['domain_name']}

    +
    +
    +
    + Users with permissions in domain + + + + + + + + + + + {foreach from=$hook_info['Domain_Management']['userlist'] item=element} + + + + + + + {/foreach} + +
    User IDUsernamePermissions
    {$element.id}{$element.username}{$hook_info['Domain_Management']['permissions'][{$element.id}-1]['AccessPrivilege']} + +
    +
    +
    +
    +
    + +
    +
    +
    +

    Modify Domain Settings

    +
    +
    +
    + +
    + + Domain Settings of '{$hook_info['Domain_Management']['domains'][$smarty.get.edit_domain-1]['domain_name']}' + +
    + +
    +
    +
    -
    -
    -
    +
    +
    + +
    + +
    +
    + +
    +
    +
    + +
    + +
    + +
    +
    + +
    + +
    +
    + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    + +
    + +
    + +
    +
    + + {if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "SUCCESS"} +
    + {$modify_mail_of_group_success} +
    + {/if} + + +
    +
    +
    +
    +
    {else} -
    -
    -
    -
    -

    Select your Character

    -
    -
    -
    -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    -
    -
    -
    -
    -
    -{/if} + + + + + + + + + + + + {foreach from=$hook_info['Domain_Management']['domains'] item=array} + + + + + + + + {/foreach} + +
    Domain IDDomain NameStatusPatch VersionDescription
    {$array['domain_id']}{$array['domain_name']}{$array['status']}{$array['patch_version']}{$array['description']|truncate}
    +{/if} {/block} diff --git a/code/web/public_php/ams/templates/layout_admin.tpl b/code/web/public_php/ams/templates/layout_admin.tpl index 12ff65c40..be6bd0765 100644 --- a/code/web/public_php/ams/templates/layout_admin.tpl +++ b/code/web/public_php/ams/templates/layout_admin.tpl @@ -4,12 +4,12 @@
  • Dashboard
  • Profile
  • Settings
  • - {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}{if isset($element.menu_display)}
  • {$element.menu_display}
  • {/if}{/foreach}{/if} + {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}{if isset($element['menu_display'])}
  • {$element['menu_display']}
  • {/if}{/foreach}{/if}
  • Users
  • Queues
  • Support Groups
  • - {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}{if isset($element.admin_menu_display)}
  • {$element.admin_menu_display}
  • {/if}{/foreach}{/if} + {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}{if isset($element.admin_menu_display)}
  • {$element.admin_menu_display}
  • {/if}{/foreach}{/if}
  • Plugins
  • Syncing
  • diff --git a/code/web/public_php/ams/templates/layout_mod.tpl b/code/web/public_php/ams/templates/layout_mod.tpl index e4fbdcc69..63b992d3f 100644 --- a/code/web/public_php/ams/templates/layout_mod.tpl +++ b/code/web/public_php/ams/templates/layout_mod.tpl @@ -4,7 +4,7 @@
  • Dashboard
  • Profile
  • Settings
  • - {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}
  • {$element.menu_display}
  • {/foreach}{/if} + {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}{if isset($element.menu_display)}
  • {$element.menu_display}
  • {/if]{/foreach}{/if}
  • Users
  • Queues
  • diff --git a/code/web/public_php/ams/templates/layout_user.tpl b/code/web/public_php/ams/templates/layout_user.tpl index e70b7c164..800058bfa 100644 --- a/code/web/public_php/ams/templates/layout_user.tpl +++ b/code/web/public_php/ams/templates/layout_user.tpl @@ -3,7 +3,7 @@
  • Profile
  • Settings
  • - {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}
  • {$element.menu_display}
  • {/foreach}{/if} + {if isset($hook_info)} {foreach from=$hook_info key=arrkey item=element}
  • {$element.menu_display}
  • {/foreach}{/if}
  • Create New Ticket
  • Logout
  • From 6e0c7ef5caff7e0167f9b7b8210558c8820fe5d5 Mon Sep 17 00:00:00 2001 From: botanic Date: Sun, 7 Sep 2014 05:40:02 -0700 Subject: [PATCH 27/93] setup modifications --- .../setup/sql/nel_ams_lib_00003.sql | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 code/web/private_php/setup/sql/nel_ams_lib_00003.sql diff --git a/code/web/private_php/setup/sql/nel_ams_lib_00003.sql b/code/web/private_php/setup/sql/nel_ams_lib_00003.sql new file mode 100644 index 000000000..e82a013ed --- /dev/null +++ b/code/web/private_php/setup/sql/nel_ams_lib_00003.sql @@ -0,0 +1,28 @@ +-- phpMyAdmin SQL Dump +-- version 4.2.8 +-- http://www.phpmyadmin.net +-- +-- Host: localhost +-- Generation Time: Sep 04, 2014 at 09:28 PM +-- Server version: 5.6.17 +-- PHP Version: 5.5.12 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Dumping data for table `plugins` +-- + +INSERT INTO `plugins` (`Id`, `FileName`, `Name`, `Type`, `Owner`, `Permission`, `Status`, `Weight`, `Info`) VALUES +(3, 'Domain_Management', 'Domain_Management', 'Manual', '', 'admin', 1, 0, '{"PluginName":"Domain Management","Description":"Plug-in for Domain Management.","Version":"1.0.0","TemplatePath":"..\\/..\\/..\\/private_php\\/ams\\/plugins\\/Domain_Management\\/templates\\/index.tpl","Type":"Manual","":null}'); + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; From d3606149e88197929adea69c7fb5e852ed7131e7 Mon Sep 17 00:00:00 2001 From: botanic Date: Sun, 7 Sep 2014 05:41:35 -0700 Subject: [PATCH 28/93] upgrade nel lib version --- code/web/public_php/setup/version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/web/public_php/setup/version.php b/code/web/public_php/setup/version.php index 67ccd7243..20047997d 100644 --- a/code/web/public_php/setup/version.php +++ b/code/web/public_php/setup/version.php @@ -1,6 +1,6 @@ Date: Sun, 7 Sep 2014 13:01:42 +0000 Subject: [PATCH 29/93] Function split() is deprecated --HG-- branch : Geels/join_shardphp-edited-online-with-bitbuck-1410094877054 --- code/web/public_php/ring/join_shard.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/web/public_php/ring/join_shard.php b/code/web/public_php/ring/join_shard.php index a14c6c40a..abc6aee7b 100644 --- a/code/web/public_php/ring/join_shard.php +++ b/code/web/public_php/ring/join_shard.php @@ -53,10 +53,10 @@ class JoinShardCb extends CRingSessionManagerWeb global $getShardListCallback; $onlineShardsBySessionId = array(); - $resultArray = split(';', $resultStr); + $resultArray = explode(';', $resultStr); foreach ($resultArray as $shardInfo) { - $shardAttr = split(',', $shardInfo); + $shardAttr = explode(',', $shardInfo); if (isset($shardAttr[1])) $onlineShardsBySessionId[$shardAttr[0]] = $shardAttr[1]; } @@ -120,7 +120,7 @@ function joinShardFromIdPost( $destSessionId ) function joinShardFromId( $userId, $domainId, $destSessionId ) { $domainInfo = getDomainInfo($domainId); - $addr = split(":", $domainInfo["session_manager_address"]); + $addr = explode(":", $domainInfo["session_manager_address"]); $RSMHost = $addr[0]; $RSMPort = $addr[1]; @@ -148,7 +148,7 @@ function joinShardFromId( $userId, $domainId, $destSessionId ) function getShardList($userId, $domainId) { $domainInfo = getDomainInfo($domainId); - $addr = split(":", $domainInfo["session_manager_address"]); + $addr = explode(":", $domainInfo["session_manager_address"]); $RSMHost = $addr[0]; $RSMPort = $addr[1]; @@ -223,7 +223,7 @@ function displayAllShards(&$onlineShardsBySessionId) function joinMainland($userId, $domainId) { $domainInfo = getDomainInfo($domainId); - $addr = split(":", $domainInfo["session_manager_address"]); + $addr = explode(":", $domainInfo["session_manager_address"]); $RSMHost = $addr[0]; $RSMPort = $addr[1]; From fc43595faf46b9234860f331df5635eeea072643 Mon Sep 17 00:00:00 2001 From: Dylan Geels Date: Sun, 7 Sep 2014 13:06:24 +0000 Subject: [PATCH 31/93] Function split() is deprecated --- code/web/public_php/login/r2_login.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/web/public_php/login/r2_login.php b/code/web/public_php/login/r2_login.php index a1bccc13a..ee4b68819 100644 --- a/code/web/public_php/login/r2_login.php +++ b/code/web/public_php/login/r2_login.php @@ -223,7 +223,7 @@ $RingWebHost = $domainInfo['web_host']; $RingWebHostPHP = $domainInfo['web_host_php']; - $LSaddr = split(":", $domainInfo['login_address']); + $LSaddr = explode(":", $domainInfo['login_address']); // ask for a session cookie to the login service $login = new LoginCb; From 6a3d59f6f5c8ebad5c14117f0b5bed60d23ecd53 Mon Sep 17 00:00:00 2001 From: Dylan Geels Date: Sun, 7 Sep 2014 13:18:32 +0000 Subject: [PATCH 32/93] The setup was showing a error from it. --- code/web/private_php/setup/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/web/private_php/setup/config/config.php b/code/web/private_php/setup/config/config.php index 699b76979..0db6727a2 100644 --- a/code/web/private_php/setup/config/config.php +++ b/code/web/private_php/setup/config/config.php @@ -137,7 +137,7 @@ $NEL_SETUP_PASSWORD = '%nelSetupPassword%'; $NEL_DOMAIN_NAME = '%nelDomainName%'; // Currently configured setup version -$NEL_SETUP_VERSION_CONFIGURED = %nelSetupVersion%; +$NEL_SETUP_VERSION_CONFIGURED = '%nelSetupVersion%'; // Get installed version require_once('setup/version.php'); From d7c1249b6b54df65d4b9f6ff45ee567b2cb62433 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 00:06:13 +0200 Subject: [PATCH 33/93] Setup adjust --- code/web/private_php/setup/config/config.php | 2 +- code/web/public_php/ams/index.php | 9 ++- code/web/public_php/setup/database.php | 64 +++++++++++--------- code/web/public_php/setup/version.php | 2 +- 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/code/web/private_php/setup/config/config.php b/code/web/private_php/setup/config/config.php index 0db6727a2..d0cb88faf 100644 --- a/code/web/private_php/setup/config/config.php +++ b/code/web/private_php/setup/config/config.php @@ -137,7 +137,7 @@ $NEL_SETUP_PASSWORD = '%nelSetupPassword%'; $NEL_DOMAIN_NAME = '%nelDomainName%'; // Currently configured setup version -$NEL_SETUP_VERSION_CONFIGURED = '%nelSetupVersion%'; +$NEL_SETUP_VERSION_CONFIGURED = (int)'%nelSetupVersion%'; // Get installed version require_once('setup/version.php'); diff --git a/code/web/public_php/ams/index.php b/code/web/public_php/ams/index.php index de2e93235..43ef1aeb9 100644 --- a/code/web/public_php/ams/index.php +++ b/code/web/public_php/ams/index.php @@ -20,11 +20,18 @@ try { if (!file_exists('../role_support')) { header("Cache-Control: max-age=1"); - header('Location: ../setup', true, 303); + header('Location: ../setup?reason=no_role_support&from=ams', true, 303); throw new SystemExit(); } require( '../config.php' ); + +if ($NEL_SETUP_VERSION_CONFIGURED < $NEL_SETUP_VERSION) { + header("Cache-Control: max-age=1"); + header('Location: ../setup?reason=upgrade&from=ams', true, 303); + throw new SystemExit(); +} + require_once( $AMS_LIB . '/libinclude.php' ); session_start(); diff --git a/code/web/public_php/setup/database.php b/code/web/public_php/setup/database.php index 16ab10dcd..645e42b19 100644 --- a/code/web/public_php/setup/database.php +++ b/code/web/public_php/setup/database.php @@ -1,5 +1,17 @@ Date: Mon, 8 Sep 2014 00:09:12 +0200 Subject: [PATCH 34/93] Typo --- code/web/public_php/setup/database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/web/public_php/setup/database.php b/code/web/public_php/setup/database.php index 645e42b19..c97d5a30d 100644 --- a/code/web/public_php/setup/database.php +++ b/code/web/public_php/setup/database.php @@ -5,7 +5,7 @@ $db_nel = 3; $db_nel_tool = 1; // Support -$db_nel_ams = 1 +$db_nel_ams = 1; $db_nel_ams_lib = 3; // Domain From ed0f753fa9086efe54cb701b32a1dcc1a71d2910 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 00:11:48 +0200 Subject: [PATCH 35/93] Fix --- code/web/public_php/setup/database.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/web/public_php/setup/database.php b/code/web/public_php/setup/database.php index c97d5a30d..75a3f0713 100644 --- a/code/web/public_php/setup/database.php +++ b/code/web/public_php/setup/database.php @@ -65,6 +65,7 @@ function upgrade_service_databases($continue_r) { $con = null; $con = connect_database($continue, "shard"); $continue = ($con != null); + global $db_nel; for ($i = 1; $i <= $db_nel; $i++) { if ($continue && get_db_version("shard") < $i) { $continue = update_database_structure($continue, $con, "nel_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql"); @@ -76,6 +77,7 @@ function upgrade_service_databases($continue_r) { $con = null; $con = connect_database($continue, "tool"); $continue = ($con != null); + global $db_nel_tool; for ($i = 1; $i <= $db_nel_tool; $i++) { if ($continue && get_db_version("tool") < $i) { $continue = update_database_structure($continue, $con, "nel_tool_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql"); @@ -93,6 +95,7 @@ function upgrade_support_databases($continue_r) { $con = null; $con = connect_database($continue, "web"); $continue = ($con != null); + global $db_nel_ams; for ($i = 1; $i <= $db_nel_ams; $i++) { if ($continue && get_db_version("web") < $i) { $continue = update_database_structure($continue, $con, "nel_ams_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql"); @@ -104,6 +107,7 @@ function upgrade_support_databases($continue_r) { $con = null; $con = connect_database($continue, "lib"); $continue = ($con != null); + global $db_nel_ams_lib; for ($i = 1; $i <= $db_nel_ams_lib; $i++) { if ($continue && get_db_version("lib") < $i) { $continue = update_database_structure($continue, $con, "nel_ams_lib_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql"); @@ -121,6 +125,7 @@ function upgrade_domain_databases($continue_r) { $con = null; $con = connect_database($continue, "ring"); $continue = ($con != null); + global $db_ring_domain; for ($i = 1; $i <= $db_ring_domain; $i++) { if ($continue && get_db_version("ring") < $i) { $continue = update_database_structure($continue, $con, "ring_domain_" . str_pad($i, 5, "0", STR_PAD_LEFT) . ".sql"); From fed7dc17ac795188accd20eaa796fad74bc79326 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 00:16:36 +0200 Subject: [PATCH 36/93] Bugfix --- code/web/public_php/setup/header.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/web/public_php/setup/header.php b/code/web/public_php/setup/header.php index b937c6913..97c9cc16c 100644 --- a/code/web/public_php/setup/header.php +++ b/code/web/public_php/setup/header.php @@ -83,8 +83,9 @@ function create_use_database($continue_r, $con, $database) { } function update_database_structure($continue_r, $con, $file) { $continue = $continue_r; + global $privatePhpDirectory; if ($continue) { - $sql = file_get_contents($_POST["privatePhpDirectory"] . "/setup/sql/" . $file); + $sql = file_get_contents($privatePhpDirectory . "/setup/sql/" . $file); if (!$sql) { printalert("danger", "Cannot read " . $file . ""); $continue = false; From 795b5a9aa04e8336f8039bf4fd3ddaf3228af3ea Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 00:21:30 +0200 Subject: [PATCH 37/93] Don't write version if upgrade failed --- code/web/public_php/setup/database.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/web/public_php/setup/database.php b/code/web/public_php/setup/database.php index 75a3f0713..9a987b813 100644 --- a/code/web/public_php/setup/database.php +++ b/code/web/public_php/setup/database.php @@ -15,10 +15,12 @@ $db_ring_domain = 1; function set_db_version($continue_r, $name, $version) { $continue = $continue_r; - if (file_put_contents("db_version_" . $name, (string)$version)) { - } else { - printalert("danger", "Failed to set database version"); - $continue = false; + if ($continue) { + if (file_put_contents("db_version_" . $name, (string)$version)) { + } else { + printalert("danger", "Failed to set database version"); + $continue = false; + } } return $continue; From 5ec2db090dedaf07ff9575cbac64fc808f8b91ca Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 00:23:07 +0200 Subject: [PATCH 38/93] Bugfix --- code/web/public_php/setup/header.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/web/public_php/setup/header.php b/code/web/public_php/setup/header.php index 97c9cc16c..bc3924f4a 100644 --- a/code/web/public_php/setup/header.php +++ b/code/web/public_php/setup/header.php @@ -83,9 +83,9 @@ function create_use_database($continue_r, $con, $database) { } function update_database_structure($continue_r, $con, $file) { $continue = $continue_r; - global $privatePhpDirectory; + global $PRIVATE_PHP_PATH; if ($continue) { - $sql = file_get_contents($privatePhpDirectory . "/setup/sql/" . $file); + $sql = file_get_contents($PRIVATE_PHP_PATH . "/setup/sql/" . $file); if (!$sql) { printalert("danger", "Cannot read " . $file . ""); $continue = false; From 8a875b3bab471849f636306698e3a4b563b75279 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 00:26:54 +0200 Subject: [PATCH 39/93] Don't put fixed row id's in insert queries for upgrades --- .../setup/sql/nel_ams_lib_00003.sql | 29 ++----------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/code/web/private_php/setup/sql/nel_ams_lib_00003.sql b/code/web/private_php/setup/sql/nel_ams_lib_00003.sql index e82a013ed..55ce7fc79 100644 --- a/code/web/private_php/setup/sql/nel_ams_lib_00003.sql +++ b/code/web/private_php/setup/sql/nel_ams_lib_00003.sql @@ -1,28 +1,3 @@ --- phpMyAdmin SQL Dump --- version 4.2.8 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generation Time: Sep 04, 2014 at 09:28 PM --- Server version: 5.6.17 --- PHP Version: 5.5.12 +INSERT INTO `plugins` (`FileName`, `Name`, `Type`, `Owner`, `Permission`, `Status`, `Weight`, `Info`) VALUES +('Domain_Management', 'Domain_Management', 'Manual', '', 'admin', 1, 0, '{"PluginName":"Domain Management","Description":"Plug-in for Domain Management.","Version":"1.0.0","TemplatePath":"..\\/..\\/..\\/private_php\\/ams\\/plugins\\/Domain_Management\\/templates\\/index.tpl","Type":"Manual","":null}'); -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - --- --- Dumping data for table `plugins` --- - -INSERT INTO `plugins` (`Id`, `FileName`, `Name`, `Type`, `Owner`, `Permission`, `Status`, `Weight`, `Info`) VALUES -(3, 'Domain_Management', 'Domain_Management', 'Manual', '', 'admin', 1, 0, '{"PluginName":"Domain Management","Description":"Plug-in for Domain Management.","Version":"1.0.0","TemplatePath":"..\\/..\\/..\\/private_php\\/ams\\/plugins\\/Domain_Management\\/templates\\/index.tpl","Type":"Manual","":null}'); - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; From 58d2c8be86158681d937a7fd2b9991d62702c1c7 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 00:42:07 +0200 Subject: [PATCH 40/93] Adjust plugin description --- code/web/private_php/setup/sql/nel_ams_lib_00004.sql | 3 +++ code/web/public_php/setup/database.php | 2 +- code/web/public_php/setup/version.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 code/web/private_php/setup/sql/nel_ams_lib_00004.sql diff --git a/code/web/private_php/setup/sql/nel_ams_lib_00004.sql b/code/web/private_php/setup/sql/nel_ams_lib_00004.sql new file mode 100644 index 000000000..33dac0523 --- /dev/null +++ b/code/web/private_php/setup/sql/nel_ams_lib_00004.sql @@ -0,0 +1,3 @@ +ALTER TABLE `plugins` ADD UNIQUE(`Name`); +UPDATE `plugins` SET `Info` = '{"PluginName":"Achievements","Description":"Returns the achievements of a user with respect to the character","Version":"1.0.0","TemplatePath":"..\\/..\\/..\\/private_php\\/ams\\/plugins\\/Achievements\\/templates\\/index.tpl","Type":"Manual","":null}' WHERE `Name` = 'Achievements'; + diff --git a/code/web/public_php/setup/database.php b/code/web/public_php/setup/database.php index 9a987b813..1510a50ae 100644 --- a/code/web/public_php/setup/database.php +++ b/code/web/public_php/setup/database.php @@ -6,7 +6,7 @@ $db_nel_tool = 1; // Support $db_nel_ams = 1; -$db_nel_ams_lib = 3; +$db_nel_ams_lib = 4; // Domain $db_ring_domain = 1; diff --git a/code/web/public_php/setup/version.php b/code/web/public_php/setup/version.php index 7d22336f3..36b2fb2d9 100644 --- a/code/web/public_php/setup/version.php +++ b/code/web/public_php/setup/version.php @@ -1,6 +1,6 @@ Date: Mon, 8 Sep 2014 01:27:46 +0200 Subject: [PATCH 41/93] Translation fix --- code/web/private_php/ams/translations/en.ini | 8 ++++---- code/web/public_php/ams/templates/login.tpl | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/code/web/private_php/ams/translations/en.ini b/code/web/private_php/ams/translations/en.ini index 41978fe83..5f57f7ff8 100644 --- a/code/web/private_php/ams/translations/en.ini +++ b/code/web/private_php/ams/translations/en.ini @@ -164,10 +164,10 @@ userlist_info = "welcome to the userlist" [login] login_info = "Please login with your user name (or email) and password." -login_error_message = "Create a new account" -login_register_message ="Register" -login_here = "I forgot my password" -login_forgot_password_message = "" +login_error_message = "Login or password were invalid" +login_register_message ="Create a new account" +login_here = "" +login_forgot_password_message = "I forgot my password" [logout] logout_message = "You've been logged out successfully." diff --git a/code/web/public_php/ams/templates/login.tpl b/code/web/public_php/ams/templates/login.tpl index b10701582..eb1f3e5fd 100644 --- a/code/web/public_php/ams/templates/login.tpl +++ b/code/web/public_php/ams/templates/login.tpl @@ -3,7 +3,7 @@
    @@ -28,14 +28,14 @@
    - +

    - + {if isset($login_error) and $login_error eq "TRUE"}
    @@ -43,7 +43,7 @@
    {/if}
    - {$login_register_message} {$login_here}.
    {$login_forgot_password_message} {$login_here} + {$login_register_message}.
    {$login_forgot_password_message}
    From c902392de3d2626e478488d17f41fa3515f84489 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 01:35:47 +0200 Subject: [PATCH 42/93] Enable ring database installation and upgrade in the setup script... --- code/web/public_php/setup/install.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/code/web/public_php/setup/install.php b/code/web/public_php/setup/install.php index 7eb3a7925..0453accea 100644 --- a/code/web/public_php/setup/install.php +++ b/code/web/public_php/setup/install.php @@ -361,7 +361,7 @@ include('header.php');
    @@ -497,6 +497,18 @@ include('header.php');

    Domain (Multiple domains require separate installations, as they may run different versions)

    +
    +
    Database Only
    +
    +

    The setup script is intended only for installation and upgrade of the domain specific database.

    +

    This will only configure the database for a single domain. It will not register the domain in the domain configuration.

    +

    The domain must be manually configured in the databases according to the procedure for configuring your server park with patchman, as it depends on several values defined within the patchman configuration.

    + + +

    It is required to use separate virtual hosts for multiple domains, in order to allow domain-specific script to run at different versions.

    +

    It is recommended, when planning to use multiple domains, to use a separate virtual host for each web service role.

    +
    +
    From af1b9ed4952a2bf4729516b6d1efb60cc42fc338 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 01:41:33 +0200 Subject: [PATCH 43/93] Make this extra clear --- code/web/public_php/setup/install.php | 1 + 1 file changed, 1 insertion(+) diff --git a/code/web/public_php/setup/install.php b/code/web/public_php/setup/install.php index 0453accea..6ffd0e20c 100644 --- a/code/web/public_php/setup/install.php +++ b/code/web/public_php/setup/install.php @@ -507,6 +507,7 @@ include('header.php');

    It is required to use separate virtual hosts for multiple domains, in order to allow domain-specific script to run at different versions.

    It is recommended, when planning to use multiple domains, to use a separate virtual host for each web service role.

    +

    There can be multiple instances of the domain role, there can only be one support and one service role setup.

    From bde283e8cb3511875a9ec757a6ba32779ddc0612 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 05:28:09 +0200 Subject: [PATCH 44/93] Fix SU RSM UAP SQL query --- .../server/src/shard_unifier_service/ring_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp b/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp index a2dc72b1c..2ed06065b 100644 --- a/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp +++ b/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp @@ -648,7 +648,7 @@ namespace RSMGR userAccessPriv.clear(); CSString query; query << "SELECT AccessPrivilege FROM permission"; - query << " WHERE UId = " << userId << " AND DomainId = " << DomainId; + query << " WHERE UId = " << userId << " AND DomainId = (SELECT domain_id FROM domain WHERE domain_name = '" << DomainName << "')"; if (!_NelDb.query(query)) { From 7448ec51a74459f05b714ca9ba7080a69cb275aa Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 05:34:14 +0200 Subject: [PATCH 45/93] Remove dead declarations in DSS --- .../dynamic_scenario_service/dynamic_scenario_service.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/code/ryzom/server/src/dynamic_scenario_service/dynamic_scenario_service.h b/code/ryzom/server/src/dynamic_scenario_service/dynamic_scenario_service.h index 8d1685796..8e5efb487 100644 --- a/code/ryzom/server/src/dynamic_scenario_service/dynamic_scenario_service.h +++ b/code/ryzom/server/src/dynamic_scenario_service/dynamic_scenario_service.h @@ -54,14 +54,6 @@ public: // Release the service void release (); - void addTestClient(const std::string & clientId); - - void removeTestClient(const std::string & clientId); - - void listTestClient() const; - - void runTestClientLuaScript(const std::string & clientId, const std::string & cmd); - static R2::CDynamicScenarioService & instance() { return (CDynamicScenarioService&)*IService::getInstance(); } From 6031e8666d26b99ef8d2ff0291660dfe39c3baea Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 07:10:28 +0200 Subject: [PATCH 46/93] Enable PHP APC cache for AMS smarty --- code/web/private_php/ams/autoload/helpers.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/web/private_php/ams/autoload/helpers.php b/code/web/private_php/ams/autoload/helpers.php index 6c80813c2..ba329830b 100644 --- a/code/web/private_php/ams/autoload/helpers.php +++ b/code/web/private_php/ams/autoload/helpers.php @@ -23,6 +23,8 @@ class Helpers { global $AMS_TRANS; global $INGAME_LAYOUT; global $AMS_CACHEDIR; + global $AMS_PLUGINS; + // define('SMARTY_SPL_AUTOLOAD',1); require_once $AMS_LIB . '/smarty/libs/Smarty.class.php'; spl_autoload_register( '__autoload' ); @@ -37,8 +39,12 @@ class Helpers { $smarty -> caching = false; $smarty -> cache_lifetime = 300; + $smarty->setPluginsDir($AMS_PLUGINS); + if (function_exists('apc_cache_info')) { // production + $smarty->caching = true; + $smarty->setCachingType("apc"); $smarty->compile_check = false; } From 034c5d798293afbc0c1086c57685fa9119e0b24a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 07:16:07 +0200 Subject: [PATCH 47/93] Better use this --- code/web/private_php/ams/autoload/helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/web/private_php/ams/autoload/helpers.php b/code/web/private_php/ams/autoload/helpers.php index ba329830b..a66511820 100644 --- a/code/web/private_php/ams/autoload/helpers.php +++ b/code/web/private_php/ams/autoload/helpers.php @@ -39,7 +39,7 @@ class Helpers { $smarty -> caching = false; $smarty -> cache_lifetime = 300; - $smarty->setPluginsDir($AMS_PLUGINS); + $smarty->addPluginsDir($AMS_PLUGINS); if (function_exists('apc_cache_info')) { // production From 876afdf018b4ebd36fc577d14cfab89705e6fb44 Mon Sep 17 00:00:00 2001 From: botanic Date: Sun, 7 Sep 2014 22:26:34 -0700 Subject: [PATCH 48/93] Domain management plugin updates --- .../ams/plugins/Domain_Management/Domain_Management.php | 2 +- .../ams/plugins/Domain_Management/templates/index.tpl | 8 ++++---- .../libs/sysplugins/smarty_internal_templatebase.php | 2 ++ code/web/public_php/setup/version.php | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php b/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php index 359c9289e..2491cb0d4 100644 --- a/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php +++ b/code/web/private_php/ams/plugins/Domain_Management/Domain_Management.php @@ -179,7 +179,7 @@ function domain_management_hook_get_db() if (isset($_GET['edit_domain'])){ //get permissions - $statement = $db->executeWithoutParams("SELECT * FROM `permission` WHERE `ClientApplication` = '".$rows[$_GET['edit_domain']-1]['domain_name']."'"); + $statement = $db->executeWithoutParams("SELECT * FROM `permission` WHERE `DomainId` = '".$rows[$_GET['edit_domain']-1]['domain_name']."'"); $rows = $statement->fetchAll(); $domain_management_return_set['permissions'] = $rows; diff --git a/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl b/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl index d49edc89e..489364097 100644 --- a/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl +++ b/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl @@ -196,11 +196,11 @@ {foreach from=$hook_info['Domain_Management']['domains'] item=array} - {$array['domain_id']} + {$array['domain_id']} {$array['domain_name']} - {$array['status']} - {$array['patch_version']} - {$array['description']|truncate} + {$array['status']} + {$array['patch_version']} + {$array['description']|truncate} {/foreach} diff --git a/code/web/private_php/ams/smarty/libs/sysplugins/smarty_internal_templatebase.php b/code/web/private_php/ams/smarty/libs/sysplugins/smarty_internal_templatebase.php index abd48b799..22a59d52d 100644 --- a/code/web/private_php/ams/smarty/libs/sysplugins/smarty_internal_templatebase.php +++ b/code/web/private_php/ams/smarty/libs/sysplugins/smarty_internal_templatebase.php @@ -283,7 +283,9 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { if (isset($_template->_capture_stack[0][0])) { $_template->capture_error(); } + error_log("test1"); array_shift($_template->_capture_stack); + error_log("test2"); $_output = ob_get_clean(); } catch (Exception $e) { ob_get_clean(); diff --git a/code/web/public_php/setup/version.php b/code/web/public_php/setup/version.php index 20047997d..67ccd7243 100644 --- a/code/web/public_php/setup/version.php +++ b/code/web/public_php/setup/version.php @@ -1,6 +1,6 @@ Date: Mon, 8 Sep 2014 08:04:09 +0200 Subject: [PATCH 49/93] Remove dead code --- code/ryzom/common/src/game_share/entity_types.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/ryzom/common/src/game_share/entity_types.h b/code/ryzom/common/src/game_share/entity_types.h index 6298ff64f..aad2d94e9 100644 --- a/code/ryzom/common/src/game_share/entity_types.h +++ b/code/ryzom/common/src/game_share/entity_types.h @@ -81,7 +81,8 @@ const uint32 NB_FAKE_DISC_PROPERTIES_UPDATED_PER_CYCLE=2; typedef uint16 TProperty; typedef uint8 TPropIndex; -const uint32 NB_PROPERTIES = 256; //number of TProperty elements (if you change this, change the ids of special properties in the Front-end Service!) +// KAE: Commented because not used +//const uint32 NB_PROPERTIES = 256; //number of TProperty elements (if you change this, change the ids of special properties in the Front-end Service!) /// Main type for positions/distances. Unit: millimeter From ab06a6ce08cc24102820bcf233171875d2e27379 Mon Sep 17 00:00:00 2001 From: botanic Date: Sun, 7 Sep 2014 23:57:31 -0700 Subject: [PATCH 50/93] remove testing errorlog --- .../ams/smarty/libs/sysplugins/smarty_internal_templatebase.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/web/private_php/ams/smarty/libs/sysplugins/smarty_internal_templatebase.php b/code/web/private_php/ams/smarty/libs/sysplugins/smarty_internal_templatebase.php index 22a59d52d..abd48b799 100644 --- a/code/web/private_php/ams/smarty/libs/sysplugins/smarty_internal_templatebase.php +++ b/code/web/private_php/ams/smarty/libs/sysplugins/smarty_internal_templatebase.php @@ -283,9 +283,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { if (isset($_template->_capture_stack[0][0])) { $_template->capture_error(); } - error_log("test1"); array_shift($_template->_capture_stack); - error_log("test2"); $_output = ob_get_clean(); } catch (Exception $e) { ob_get_clean(); From e0a1d27dc8f26081823af367af16685b473e8845 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 09:09:42 +0200 Subject: [PATCH 51/93] Bugfix in distance prioritizer --- code/ryzom/server/src/frontend_service/distance_prioritizer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/server/src/frontend_service/distance_prioritizer.h b/code/ryzom/server/src/frontend_service/distance_prioritizer.h index b7a69a1d6..ad59bc12e 100644 --- a/code/ryzom/server/src/frontend_service/distance_prioritizer.h +++ b/code/ryzom/server/src/frontend_service/distance_prioritizer.h @@ -227,7 +227,7 @@ public: { outbox.serialBitAndLog( BranchHasPayload ); if ( a() ) a()->fillDiscreetProperties( outbox ); - if ( a() ) b()->fillDiscreetProperties( outbox ); + if ( b() ) b()->fillDiscreetProperties( outbox ); } } else From 3baf60ad1d4f0b4ab32c304c89eed1770be0bb79 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 09:37:14 +0200 Subject: [PATCH 52/93] Remove dead code in game item manager --- .../game_item_manager/game_item_manager.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/ryzom/server/src/entities_game_service/game_item_manager/game_item_manager.cpp b/code/ryzom/server/src/entities_game_service/game_item_manager/game_item_manager.cpp index 830c45d7c..16258192c 100644 --- a/code/ryzom/server/src/entities_game_service/game_item_manager/game_item_manager.cpp +++ b/code/ryzom/server/src/entities_game_service/game_item_manager/game_item_manager.cpp @@ -845,9 +845,9 @@ void CGameItemManager::buildNpcSpecificItems() //----------------------------------------------- // createItem : //----------------------------------------------- -NLMISC_COMMAND(createItem,"create a new item","") +NLMISC_COMMAND(createItem,"create a new item","") { - if( args.size() < 3 ) + if( args.size() < 2 ) { return false; } @@ -859,9 +859,9 @@ NLMISC_COMMAND(createItem,"create a new item","") uint16 quality; NLMISC::fromString(args[1], quality); - uint32 ownerIdTmp; - NLMISC::fromString(args[2], ownerIdTmp); - CEntityId ownerId(RYZOMID::object,ownerIdTmp); + //uint32 ownerIdTmp; + //NLMISC::fromString(args[2], ownerIdTmp); + //CEntityId ownerId(RYZOMID::object,ownerIdTmp); // CGameItemPtr item = GameItemManager.createItem( sheetId, quality, ownerId, -1, true,true ); CGameItemPtr item = GameItemManager.createItem( sheetId, quality, true, true ); From d651eff10b3b1fa4e1c6a51e229687fe52d6e8e5 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 09:48:28 +0200 Subject: [PATCH 53/93] Cleanup some RYZOMID code --- .../common/src/game_share/ryzom_entity_id.h | 17 +++++++++++------ .../player_manager/character.cpp | 8 +------- .../frontend_service/distance_prioritizer.cpp | 2 +- .../server/src/gpm_service/world_entity.cpp | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/code/ryzom/common/src/game_share/ryzom_entity_id.h b/code/ryzom/common/src/game_share/ryzom_entity_id.h index 9fc2682ef..0e96486c7 100644 --- a/code/ryzom/common/src/game_share/ryzom_entity_id.h +++ b/code/ryzom/common/src/game_share/ryzom_entity_id.h @@ -30,12 +30,17 @@ namespace RYZOMID { // warning: respect separation with creature /object, it's used in front-end vision prioritizer // creature part (include player) - player = 0, - npc, //1 - creature, //2 - mount, //3 - pack_animal, //4 - flora, //5 + creature_begin = 0, + player = creature_begin, + bot_ai_begin, + npc = bot_begin, //1 + creature, //2 + mount, //3 + pack_animal, //4 + flora, //5 + bot_ai_end = flora, + creature_end = bot_end, + // objects part object, // 6 building, // 7 diff --git a/code/ryzom/server/src/entities_game_service/player_manager/character.cpp b/code/ryzom/server/src/entities_game_service/player_manager/character.cpp index 5518042ed..33d1777b9 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/character.cpp +++ b/code/ryzom/server/src/entities_game_service/player_manager/character.cpp @@ -16324,13 +16324,7 @@ void CCharacter::sendEmote( const NLMISC::CEntityId& id, MBEHAV::EBehaviour beha } CEntityId targetId = getTarget(); - if ( targetId.getType() != RYZOMID::npc && - targetId.getType() != RYZOMID::player && - targetId.getType() != RYZOMID::creature && - targetId.getType() != RYZOMID::mount && - targetId.getType() != RYZOMID::pack_animal && - targetId.getType() != RYZOMID::flora - ) + if (targetId.getType() > creature_end) targetId = CEntityId::Unknown; TDataSetRow targetRow = TheDataset.getDataSetRow( targetId ); diff --git a/code/ryzom/server/src/frontend_service/distance_prioritizer.cpp b/code/ryzom/server/src/frontend_service/distance_prioritizer.cpp index 305adb992..04bf990cd 100644 --- a/code/ryzom/server/src/frontend_service/distance_prioritizer.cpp +++ b/code/ryzom/server/src/frontend_service/distance_prioritizer.cpp @@ -915,7 +915,7 @@ inline void CDistancePrioritizer::serialSlotHeader( CClientHost& client, CEntit timestampDelta = 15; timestampDelta |= 0x10; // 'timestampIsThere bit': first bit is bit 5 (high to low order) } - else if ( seenEntityId.getType() >= RYZOMID::object ) + else if ( seenEntityId.getType() > RYZOMID::creature_end ) { // For non-players/non-bots types (e.g. bags), set the timestamp delta if entity is being spawned to the client //if ( _VisualPropertyTreeRoot->B->B->getSHEETnode()->BranchHasPayload ) // assumes this is done after arbitrateDiscreetProperties() // CHANGED BEN diff --git a/code/ryzom/server/src/gpm_service/world_entity.cpp b/code/ryzom/server/src/gpm_service/world_entity.cpp index d9976a1c4..6debb6284 100644 --- a/code/ryzom/server/src/gpm_service/world_entity.cpp +++ b/code/ryzom/server/src/gpm_service/world_entity.cpp @@ -161,7 +161,7 @@ void CWorldEntity::init( const CEntityId& id, const TDataSetRow &index ) { _Type = Trigger; } - else if ( (id.getType() >= RYZOMID::npc ) || ( id.getType() <= RYZOMID::flora) ) + else if ((id.getType() >= RYZOMID::bot_ai_begin) && (id.getType() <= RYZOMID::bot_ai_end)) { _Type = AI; } From 3e476a9376b945f6324d75bb496471f617e5f3ff Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 8 Sep 2014 10:42:38 +0200 Subject: [PATCH 54/93] Install fix --- code/web/public_php/setup/install.php | 1 + 1 file changed, 1 insertion(+) diff --git a/code/web/public_php/setup/install.php b/code/web/public_php/setup/install.php index 6ffd0e20c..037910834 100644 --- a/code/web/public_php/setup/install.php +++ b/code/web/public_php/setup/install.php @@ -143,6 +143,7 @@ include('header.php'); $config = str_replace("%nelSetupPassword%", addslashes($_POST["nelSetupPassword"]), $config); $config = str_replace("%domainDatabase%", addslashes($_POST["domainDatabase"]), $config); $config = str_replace("%nelDomainName%", addslashes($_POST["nelDomainName"]), $config); + $config = str_replace("%nelSetupVersion%", addslashes($NEL_SETUP_VERSION), $config); $cryptKeyLength = 16; $cryptKey = str_replace("=", "", base64_encode(mcrypt_create_iv(ceil(0.75 * $cryptKeyLength), MCRYPT_DEV_URANDOM))); $cryptKeyIMAP = str_replace("=", "", base64_encode(mcrypt_create_iv(ceil(0.75 * $cryptKeyLength), MCRYPT_DEV_URANDOM))); From 52885f20e0dd668c54994c9d060e7bfdaf714c2c Mon Sep 17 00:00:00 2001 From: botanic Date: Mon, 8 Sep 2014 02:05:49 -0700 Subject: [PATCH 55/93] Fix for stupid loop --- .hgignore | 3 +++ .../ams/plugins/Domain_Management/templates/index.tpl | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.hgignore b/.hgignore index 60b5b19be..16e7f1eef 100644 --- a/.hgignore +++ b/.hgignore @@ -257,3 +257,6 @@ code/web/public_php/db_version_tool code/web/public_php/db_version_web code/web/public_php/role_service code/web/public_php/role_support +code/web/public_php/role_domain +code/web/public_php/db_version_ring +code/web/public_php/config_user.php diff --git a/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl b/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl index 489364097..0f7e208ac 100644 --- a/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl +++ b/code/web/private_php/ams/plugins/Domain_Management/templates/index.tpl @@ -194,7 +194,8 @@ - {foreach from=$hook_info['Domain_Management']['domains'] item=array} + {if isset($hook_info['Domain_Management']['domains'][0])} + {foreach from=$hook_info['Domain_Management']['domains'] item=array} {$array['domain_id']} {$array['domain_name']} @@ -202,7 +203,8 @@ {$array['patch_version']} {$array['description']|truncate} - {/foreach} + {/foreach} + {/if} {/if} From b58f3654733be57f83d631b6e53e940144aa4b2c Mon Sep 17 00:00:00 2001 From: botanic Date: Mon, 8 Sep 2014 02:07:42 -0700 Subject: [PATCH 56/93] upgrade smarty to 3.1.19 --- code/web/private_php/ams/smarty/README | 4 +- .../ams/smarty/SMARTY_3.1_NOTES.txt | 2 +- .../web/private_php/ams/smarty/change_log.txt | 238 +- .../ams/smarty/libs/Smarty.class.php | 482 +- .../ams/smarty/libs/SmartyBC.class.php | 927 +-- .../web/private_php/ams/smarty/libs/debug.tpl | 214 +- .../smarty/libs/plugins/block.textformat.php | 21 +- .../smarty/libs/plugins/function.counter.php | 40 +- .../smarty/libs/plugins/function.cycle.php | 47 +- .../smarty/libs/plugins/function.fetch.php | 117 +- .../libs/plugins/function.html_checkboxes.php | 78 +- .../libs/plugins/function.html_image.php | 68 +- .../libs/plugins/function.html_options.php | 81 +- .../libs/plugins/function.html_radios.php | 76 +- .../plugins/function.html_select_date.php | 169 +- .../plugins/function.html_select_time.php | 72 +- .../libs/plugins/function.html_table.php | 45 +- .../smarty/libs/plugins/function.mailto.php | 45 +- .../ams/smarty/libs/plugins/function.math.php | 54 +- .../libs/plugins/modifier.capitalize.php | 59 +- .../libs/plugins/modifier.date_format.php | 36 +- .../libs/plugins/modifier.debug_print_var.php | 61 +- .../smarty/libs/plugins/modifier.escape.php | 32 +- .../libs/plugins/modifier.regex_replace.php | 30 +- .../smarty/libs/plugins/modifier.replace.php | 23 +- .../smarty/libs/plugins/modifier.spacify.php | 18 +- .../smarty/libs/plugins/modifier.truncate.php | 33 +- .../libs/plugins/modifiercompiler.cat.php | 59 +- .../modifiercompiler.count_characters.php | 65 +- .../modifiercompiler.count_paragraphs.php | 55 +- .../modifiercompiler.count_sentences.php | 55 +- .../plugins/modifiercompiler.count_words.php | 63 +- .../libs/plugins/modifiercompiler.default.php | 70 +- .../libs/plugins/modifiercompiler.escape.php | 251 +- .../plugins/modifiercompiler.from_charset.php | 67 +- .../libs/plugins/modifiercompiler.indent.php | 65 +- .../libs/plugins/modifiercompiler.lower.php | 62 +- .../libs/plugins/modifiercompiler.noprint.php | 46 +- .../modifiercompiler.string_format.php | 51 +- .../libs/plugins/modifiercompiler.strip.php | 66 +- .../plugins/modifiercompiler.strip_tags.php | 62 +- .../plugins/modifiercompiler.to_charset.php | 67 +- .../plugins/modifiercompiler.unescape.php | 101 +- .../libs/plugins/modifiercompiler.upper.php | 59 +- .../plugins/modifiercompiler.wordwrap.php | 93 +- .../plugins/outputfilter.trimwhitespace.php | 34 +- .../plugins/shared.escape_special_chars.php | 26 +- .../plugins/shared.literal_compiler_param.php | 8 +- .../libs/plugins/shared.make_timestamp.php | 15 +- .../libs/plugins/shared.mb_str_replace.php | 20 +- .../smarty/libs/plugins/shared.mb_unicode.php | 22 +- .../libs/plugins/shared.mb_wordwrap.php | 32 +- .../variablefilter.htmlspecialchars.php | 10 +- .../libs/sysplugins/smarty_cacheresource.php | 337 +- .../smarty_cacheresource_custom.php | 159 +- .../smarty_cacheresource_keyvaluestore.php | 228 +- .../libs/sysplugins/smarty_config_source.php | 37 +- .../smarty_internal_cacheresource_file.php | 88 +- .../smarty_internal_compile_append.php | 21 +- .../smarty_internal_compile_assign.php | 24 +- .../smarty_internal_compile_block.php | 438 +- .../smarty_internal_compile_break.php | 152 +- .../smarty_internal_compile_call.php | 25 +- .../smarty_internal_compile_capture.php | 32 +- .../smarty_internal_compile_config_load.php | 31 +- .../smarty_internal_compile_continue.php | 153 +- .../smarty_internal_compile_debug.php | 20 +- .../smarty_internal_compile_eval.php | 26 +- .../smarty_internal_compile_extends.php | 160 +- .../smarty_internal_compile_for.php | 70 +- .../smarty_internal_compile_foreach.php | 76 +- .../smarty_internal_compile_function.php | 65 +- .../sysplugins/smarty_internal_compile_if.php | 185 +- .../smarty_internal_compile_include.php | 252 +- .../smarty_internal_compile_include_php.php | 29 +- .../smarty_internal_compile_insert.php | 26 +- .../smarty_internal_compile_ldelim.php | 22 +- .../smarty_internal_compile_nocache.php | 37 +- ..._internal_compile_private_block_plugin.php | 38 +- ...ternal_compile_private_function_plugin.php | 26 +- ...arty_internal_compile_private_modifier.php | 279 +- ..._compile_private_object_block_function.php | 30 +- ...ternal_compile_private_object_function.php | 59 +- ...ernal_compile_private_print_expression.php | 99 +- ...ernal_compile_private_registered_block.php | 224 +- ...al_compile_private_registered_function.php | 160 +- ...ernal_compile_private_special_variable.php | 31 +- .../smarty_internal_compile_rdelim.php | 22 +- .../smarty_internal_compile_section.php | 81 +- .../smarty_internal_compile_setfilter.php | 142 +- .../smarty_internal_compile_while.php | 43 +- .../smarty_internal_compilebase.php | 48 +- .../sysplugins/smarty_internal_config.php | 70 +- .../smarty_internal_config_file_compiler.php | 51 +- .../smarty_internal_configfilelexer.php | 451 +- .../smarty_internal_configfileparser.php | 835 ++- .../libs/sysplugins/smarty_internal_data.php | 168 +- .../libs/sysplugins/smarty_internal_debug.php | 78 +- .../smarty_internal_filter_handler.php | 27 +- .../smarty_internal_function_call_handler.php | 107 +- .../smarty_internal_get_include_path.php | 94 +- .../smarty_internal_nocache_insert.php | 104 +- .../sysplugins/smarty_internal_parsetree.php | 789 +- .../smarty_internal_resource_eval.php | 190 +- .../smarty_internal_resource_extends.php | 146 +- .../smarty_internal_resource_file.php | 33 +- .../smarty_internal_resource_php.php | 51 +- .../smarty_internal_resource_registered.php | 45 +- .../smarty_internal_resource_stream.php | 83 +- .../smarty_internal_resource_string.php | 55 +- ...smarty_internal_smartytemplatecompiler.php | 43 +- .../sysplugins/smarty_internal_template.php | 191 +- .../smarty_internal_templatebase.php | 297 +- .../smarty_internal_templatecompilerbase.php | 1493 ++-- .../smarty_internal_templatelexer.php | 1570 ++-- .../smarty_internal_templateparser.php | 6596 ++++++++++------- .../sysplugins/smarty_internal_utility.php | 407 +- .../sysplugins/smarty_internal_write_file.php | 32 +- .../libs/sysplugins/smarty_resource.php | 289 +- .../sysplugins/smarty_resource_custom.php | 39 +- .../sysplugins/smarty_resource_recompiled.php | 19 +- .../sysplugins/smarty_resource_uncompiled.php | 23 +- .../libs/sysplugins/smarty_security.php | 145 +- 123 files changed, 12977 insertions(+), 10115 deletions(-) diff --git a/code/web/private_php/ams/smarty/README b/code/web/private_php/ams/smarty/README index bf03403aa..50e0d60e5 100644 --- a/code/web/private_php/ams/smarty/README +++ b/code/web/private_php/ams/smarty/README @@ -1,4 +1,4 @@ -Smarty 3.1.13 +Smarty 3.1.19 Author: Monte Ohrt Author: Uwe Tews @@ -120,7 +120,7 @@ $smarty->unregisterObject($object_name) $smarty->unregisterFilter($type, $function_name) $smarty->unregisterResource($resource_type) -$smarty->compileAllTemplates($extention = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null) +$smarty->compileAllTemplates($extension = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null) $smarty->clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null) $smarty->testInstall() diff --git a/code/web/private_php/ams/smarty/SMARTY_3.1_NOTES.txt b/code/web/private_php/ams/smarty/SMARTY_3.1_NOTES.txt index e56e56f67..57709f0d7 100644 --- a/code/web/private_php/ams/smarty/SMARTY_3.1_NOTES.txt +++ b/code/web/private_php/ams/smarty/SMARTY_3.1_NOTES.txt @@ -199,7 +199,7 @@ Relative paths are available with {include file="..."} and $smarty->fetch('./foo.tpl') cannot be relative to a template, an exception is thrown. - Adressing a specific $template_dir + Addressing a specific $template_dir Smarty 3.1 introduces the $template_dir index notation. $smarty->fetch('[foo]bar.tpl') and {include file="[foo]bar.tpl"} diff --git a/code/web/private_php/ams/smarty/change_log.txt b/code/web/private_php/ams/smarty/change_log.txt index 69642e276..7eb58320d 100644 --- a/code/web/private_php/ams/smarty/change_log.txt +++ b/code/web/private_php/ams/smarty/change_log.txt @@ -1,9 +1,227 @@ -===== Smarty-3.1.13 ===== + ===== 3.1.20-dev ===== (xx.xx.2014) + ===== 3.1.19 ===== (06.30.2014) + 20.06.2014 + - bugfix template variables could not be passed as paramter in {include} when the include was in a {nocache} section (topic 25131) + + 17.06.2014 + - bugfix large template text of some charsets could cause parsing errors (topic 24630) + + 08.06.2014 + - bugfix registered objects did not work after spelling fixes of 06.06.2014 + - bugfix {block} tags within {literal} .. {/literal} got not displayed correctly (topic 25024) + - bugfix UNC WINDOWS PATH like "\\psf\path\to\dir" did not work as template directory (Issue 192) + - bugfix {html_image} security check did fail on files relative to basedir (Issue 191) + + 06.06.2014 + - fixed PHPUnit outputFilterTrimWhitespaceTests.php assertion of test result + - fixed spelling, PHPDoc , minor errors, code cleanup + + 02.06.2014 + - using multiple cwd with relative template dirs could result in identical compiled file names. (issue 194 and topic 25099) + + 19.04.2014 + - bugfix calling createTemplate(template, data) with empty data array caused notice of array to string conversion (Issue 189) + - bugfix clearCompiledTemplate() did not delete files on WINDOWS when a compile_id was specified + + 18.04.2014 + - revert bugfix of 5.4.2014 because %-e date format is not supported on all operating systems + + ===== 3.1.18 ===== (07.04.2014) + 06.04.2014 + - bugfix template inheritance fail when using custom resource after patch of 8.3.2014 (Issue 187) + - bugfix update of composer file (Issue 168 and 184) + + 05.04.2014 + - bugfix default date format leads to extra spaces when displaying dates with single digit days (Issue 165) + + 26.03.2014 + - bugfix Smart_Resource_Custom should not lowercase the resource name (Issue 183) + + 24.03.2014 + - bugfix using a {foreach} property like @iteration could fail when used in inheritance parent templates (Issue 182) + + 20.03.2014 + - bugfix $smarty->auto_literal and mbsting.func_overload 2, 6 or 7 did fail (forum topic 24899) + + 18.03.2014 + - revert change of 17.03.2014 + +17.03.2014 + - bugfix $smarty->auto_literal and mbsting.func_overload 2, 6 or 7 did fail (forum topic 24899) + + 15.03.2014 + - bugfix Smarty_CacheResource_Keyvaluestore did use different keys on read/writes and clearCache() calls (Issue 169) + + 13.03.2014 + - bugfix clearXxx() change of 27.1.2014 did not work when specifing cache_id or compile_id (forum topic 24868 and 24867) + + ===== 3.1.17 ===== + 08.03.2014 + - bugfix relative file path {include} within {block} of child templates did throw exception on first call (Issue 177) + + 17.02.2014 + - bugfix Smarty failed when executing PHP on HHVM (Hip Hop 2.4) because uniqid('',true) does return string with ',' (forum topic 20343) + + 16.02.2014 + - bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175) + + 05.02.2014 + - bugfix shared.literal_compiler_param.php did throw an exception when literal did contain a '-' (smarty-developers group) + + 27.01.2014 + - bugfix $smarty->debugging = true; did show the variable of the $smarty object not the variables used in display() call (forum topic 24764) + - bugfix clearCompiledTemplate(), clearAll() and clear() should use realpath to avoid possible exception from RecursiveDirectoryIterator (Issue 171) + + 26.01.2014 + - bugfix undo block nesting checks for {nocache} for reasons like forum topic 23280 (forum topic 24762) + + 18.01.2014 + - bugfix the compiler did fail when using template inheritance and recursive {include} (smarty-developers group) + + 11.01.2014 + - bugfix "* }" (spaces before right delimiter) was interpreted by mistake as comment end tag (Issue 170) + - internals content cache should be clear when updating cache file + + 08.01.2014 + - bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 169) + - bugfix SmartyBC.class.php should use require_once to load Smarty.class.php (forum topic 24683) + + ===== 3.1.16 ===== + 15.12.2013 + - bugfix {include} with {block} tag handling (forum topic 24599, 24594, 24682) (Issue 161) + Read 3.1.16_RELEASE_NOTES for more details + - enhancement additional debug output at $smarty->_parserdebug = true; + + 07.11.2013 + - bugfix too restrictive handling of {include} within {block} tags. 3.1.15 did throw errors where 3.1.14 did not (forum topic 24599) + - bugfix compiler could fail if PHP mbstring.func_overload is enabled (Issue 164) + + 28.10.2013 + - bugfix variable resource name at custom resource plugin did not work within {block} tags (Issue 163) + - bugfix notice "Trying to get property of non-object" removed (Issue 163) + - bugfix correction of modifier capitalize fix from 3.10.2013 (issue 159) + - bugfix multiple {block}s with same name in parent did not work (forum topic 24631) + + 20.10.2013 + - bugfix a variable file name at {extends} tag did fail (forum topic 24618) + + 14.10.2013 + - bugfix yesterdays fix could result in an undefined variable + + 13.10.2013 + - bugfix variable names on {include} in template inheritance did unextepted error message (forum topic 24594) (Issue 161) +.- bugfix relative includes with same name like {include './foo.tpl'} from different folder failed (forum topic 24590)(Issue 161) + + 04.10.2013 + - bugfix variable file names at {extends} had been disbabled by mistake with the rewrite of + template inheritance of 24.08.2013 (forum topic 24585) + +03.10.2013 + - bugfix loops using modifier capitalize did eat up memory (issue 159) + + ===== Smarty 3.1.15 ===== +01.10.2013 + - use current delimiters in compiler error messages (issue 157) + - improvement on performance when using error handler and multiple template folders (issue 152) + +17.09.2013 + - improvement added patch for additional SmartyCompilerException properties for better access to scource information (forum topic 24559) + +16.09.2013 + - bugfix recompiled templates did not show on first request with zend opcache cache (forum topic 24320) + +13.09.2013 + - bugfix html_select_time defaulting error for the Meridian dropdown (forum topic 24549) + +09.09.2012 +- bugfix incorrect compiled code with array(object,method) callback at registered Variable Filter (forum topic 24542) + +27.08.2013 +- bugfix delimiter followed by linebreak did not work as auto literal after update from 24.08.2013 (forum topic 24518) + +24.08.2013 +- bugfix and enhancement + Because several recent problems with template inheritance the {block} tag compiler has been rewriten + - Error messages shown now the correct child template file and line number + - The compiler could fail on some larger UTF-8 text block (forum topic 24455) + - The {strip} tag can now be placed outside {block} tags in child templates (forum topic 24289) +- change SmartyException::$escape is now false by default +- change PHP traceback has been remove for SmartyException and SmartyCompilerException + +14.08.2013 +- bugfix compiled filepath of config file did not observe different config_dir (forum topic 24493) + +13.08.2013 +- bugfix the internal resource cache did not observe config_dir changes (forum topic 24493) + +12.08.2013 +- bugfix internal $tmpx variables must be unique over all inheritance templates (Issue 149) + +10.08.2013 +- bugfix a newline was eaten when a was passed by a Smarty variable and caching was enabled (forum topic 24482) + +29.07.2013 +- bugfix headers already send warning thrown when using 'SMARTY_DEBUG=on' from URL (Issue 148) + +27.07.2013 +- enhancement allow access to properties of registered opjects for Smarty2 BC (forum topic 24344) + +26.07.2013 +- bugfix template inheritance nesting problem (forum topic 24387) + +15.7.2013 +- update code generated by PSR-2 standards fixer which introduced PHP 5.4 incompatibilities of 14.7.2013 + +14.7.2013 +- bugfix increase of internal maximum parser stacksize to allow more complex tag code {forum topic 24426} +- update for PHP 5.4 compatibility +- reformat source to PSR-2 standard + +12.7.2013 +- bugfix Do not remove '//' from file path at normalization (Issue 142) + +2.7.2013 +- bugfix trimwhitespace would replace captured items in wrong order (forum topic 24387) + +===== Smarty-3.1.14 ===== +27.06.2013 +- bugfix removed PHP 5.5 deprecated preg_replace /e option in modifier capitalize (forum topic 24389) + +17.06.2013 +- fixed spelling in sources and documentation (from smarty-developers forum Veres Lajos) +- enhancement added constant SMARTY::CLEAR_EXPIRED for the change of 26.05.2013 (forum topic 24310) +- bugfix added smarty_security.php to composer.json (Issue 135) + +26.05.2013 +- enhancement an expire_time of -1 in clearCache() and clearAllCache() will delete outdated cache files + by their individual cache_lifetime used at creation (forum topic 24310) + +21.05.2013 +- bugfix modifier strip_tags:true was compiled into wrong code (Forum Topic 24287) +- bugfix /n after ?> in Smarty.class.php did start output buffering (Issue 138) + +25.04.2013 +- bugfix escape and wordrap modifier could be compiled into wrong code when used in {nocache}{/nocache} + section but caching is disabled (Forum Topic 24260) + +05.04.2013 +- bugfix post filter must not run when compiling inheritance child blocks (Forum Topic 24094) +- bugfix after the fix for Issue #130 compiler exceptions got double escaped (Forum Topic 24199) + +28.02.2013 +- bugfix nocache blocks could be lost when using CACHING_LIFETIME_SAVED (Issue #133) +- bugfix Compile ID gets nulled when compiling child blocks (Issue #134) + + +24.01.2013 +- bugfix wrong tag type in smarty_internal_templatecompilerbase.php could cause wrong plugin search order (Forum Topic 24028) + +===== Smarty-3.1.13 ===== 13.01.2013 - enhancement allow to disable exception message escaping by SmartyException::$escape = false; (Issue #130) 09.01.2013 -- bugfix compilation did fail when a prefilter did modify an {extends} tag (Forum Topic 23966) +- bugfix compilation did fail when a prefilter did modify an {extends} tag c - bugfix template inheritance could fail if nested {block} tags in childs did contain {$smarty.block.child} (Issue #127) - bugfix template inheritance could fail if {block} tags in childs did have similar name as used plugins (Issue #128) - added abstract method declaration doCompile() in Smarty_Internal_TemplateCompilerBase (Forum Topic 23969) @@ -417,7 +635,7 @@ 03/09/2011 - bugfix createTemplate() must default to cache_id and compile_id of Smarty object - bugfix Smarty_CacheResource_KeyValueStore must include $source->uid in cache filepath to keep templates with same - name but different folders seperated + name but different folders separated - added cacheresource.apc.php example in demo folder 02/09/2011 @@ -608,7 +826,7 @@ - changed ./ and ../ behaviour 14/02/2011 -- added {block ... hide} option to supress block if no child is defined +- added {block ... hide} option to suppress block if no child is defined 13/02/2011 - update handling of recursive subtemplate calls @@ -722,7 +940,7 @@ - bugfix on compiler object destruction. compiler_object property was by mistake unset. 09/03/2011 --bugfix a variable filter should run before modifers on an output tag (see change of 23/07/2010) +-bugfix a variable filter should run before modifiers on an output tag (see change of 23/07/2010) 08/03/2011 - bugfix loading config file without section should load only defaults @@ -1026,10 +1244,10 @@ request_use_auto_globals - bugfix passing scope attributes in doublequoted strings did not work at {include} {assign} and {append} 25/07/2010 -- another bugfix of change from 23/07/2010 when compiling modifer +- another bugfix of change from 23/07/2010 when compiling modifier 24/07/2010 -- bugfix of change from 23/07/2010 when compiling modifer +- bugfix of change from 23/07/2010 when compiling modifier 23/07/2010 - changed execution order. A variable filter does now run before modifiers on output of variables @@ -1336,7 +1554,7 @@ request_use_auto_globals - bugfix on {if} tags 01/12/2010 -- changed back modifer handling in parser. Some restrictions still apply: +- changed back modifier handling in parser. Some restrictions still apply: if modifiers are used in side {if...} expression or in mathematical expressions parentheses must be used. - bugfix the {function..} tag did not accept the name attribute in double quotes @@ -1948,7 +2166,7 @@ NOTICE: existing compiled template and cache files must be deleted - fixed exceptions in function plugins - fixed notice error in Smarty.class.php - allow chained objects to span multiple lines -- fixed error in modifers +- fixed error in modifiers 03/20/2009 - moved /plugins folder into /libs folder @@ -1956,7 +2174,7 @@ NOTICE: existing compiled template and cache files must be deleted - autoappend a directory separator if the xxxxx_dir definition have no trailing one 03/19/2009 -- allow array definition as modifer parameter +- allow array definition as modifier parameter - changed modifier to use multi byte string funktions. 03/17/2009 diff --git a/code/web/private_php/ams/smarty/libs/Smarty.class.php b/code/web/private_php/ams/smarty/libs/Smarty.class.php index 40532fc2a..6291e4cd5 100644 --- a/code/web/private_php/ams/smarty/libs/Smarty.class.php +++ b/code/web/private_php/ams/smarty/libs/Smarty.class.php @@ -2,33 +2,29 @@ /** * Project: Smarty: the PHP compiling template engine * File: Smarty.class.php - * SVN: $Id: Smarty.class.php 4694 2013-01-13 21:13:14Z uwe.tews@googlemail.com $ - * + * SVN: $Id: Smarty.class.php 4848 2014-06-08 18:12:09Z Uwe.Tews@googlemail.com $ * This library 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 2.1 of the License, or (at your option) any later version. - * * This library 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 this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * * For questions, help, comments, discussion, etc., please join the * Smarty mailing list. Send a blank e-mail to * smarty-discussion-subscribe@googlegroups.com * - * @link http://www.smarty.net/ + * @link http://www.smarty.net/ * @copyright 2008 New Digital Group, Inc. - * @author Monte Ohrt - * @author Uwe Tews - * @author Rodney Rehm - * @package Smarty - * @version 3.1.13 + * @author Monte Ohrt + * @author Uwe Tews + * @author Rodney Rehm + * @package Smarty + * @version 3.1.19 */ /** @@ -92,20 +88,21 @@ if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR /** * Load always needed external class files */ -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_data.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_templatebase.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_template.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_resource.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_resource_file.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_cacheresource.php'; -include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_cacheresource_file.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_templatebase.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_template.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_resource.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_resource_file.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php'; +include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_cacheresource_file.php'; /** * This is the main Smarty class + * * @package Smarty */ -class Smarty extends Smarty_Internal_TemplateBase { - +class Smarty extends Smarty_Internal_TemplateBase +{ /**#@+ * constant definitions */ @@ -113,7 +110,7 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * smarty version */ - const SMARTY_VERSION = 'Smarty-3.1.13'; + const SMARTY_VERSION = 'Smarty-3.1.19'; /** * define variable scopes @@ -128,6 +125,11 @@ class Smarty extends Smarty_Internal_TemplateBase { const CACHING_OFF = 0; const CACHING_LIFETIME_CURRENT = 1; const CACHING_LIFETIME_SAVED = 2; + /** + * define constant for clearing cache files be saved expiration datees + */ + const CLEAR_EXPIRED = - 1; + /** * define compile check modes */ @@ -201,106 +203,133 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * auto literal on delimiters with whitspace + * * @var boolean */ public $auto_literal = true; /** * display error on not assigned variables + * * @var boolean */ public $error_unassigned = false; /** * look up relative filepaths in include_path + * * @var boolean */ public $use_include_path = false; /** * template directory + * * @var array */ private $template_dir = array(); /** * joined template directory string used in cache keys + * * @var string */ public $joined_template_dir = null; /** * joined config directory string used in cache keys + * * @var string */ public $joined_config_dir = null; /** * default template handler + * * @var callable */ public $default_template_handler_func = null; /** * default config handler + * * @var callable */ public $default_config_handler_func = null; /** * default plugin handler + * * @var callable */ public $default_plugin_handler_func = null; /** * compile directory + * * @var string */ private $compile_dir = null; /** * plugins directory + * * @var array */ private $plugins_dir = array(); /** * cache directory + * * @var string */ private $cache_dir = null; /** * config directory + * * @var array */ private $config_dir = array(); /** * force template compiling? + * * @var boolean */ public $force_compile = false; /** * check template for modifications? + * * @var boolean */ public $compile_check = true; /** * use sub dirs for compiled/cached files? + * * @var boolean */ public $use_sub_dirs = false; /** * allow ambiguous resources (that are made unique by the resource handler) + * * @var boolean */ public $allow_ambiguous_resources = false; /** * caching enabled + * * @var boolean */ public $caching = false; /** * merge compiled includes + * * @var boolean */ public $merge_compiled_includes = false; + /** + * template inheritance merge compiled includes + * + * @var boolean + */ + public $inheritance_merge_compiled_includes = true; /** * cache lifetime in seconds + * * @var integer */ public $cache_lifetime = 3600; /** * force cache file creation + * * @var boolean */ public $force_cache = false; @@ -320,11 +349,13 @@ class Smarty extends Smarty_Internal_TemplateBase { public $compile_id = null; /** * template left-delimiter + * * @var string */ public $left_delimiter = "{"; /** * template right-delimiter + * * @var string */ public $right_delimiter = "}"; @@ -333,7 +364,6 @@ class Smarty extends Smarty_Internal_TemplateBase { */ /** * class name - * * This should be instance of Smarty_Security. * * @var string @@ -360,7 +390,6 @@ class Smarty extends Smarty_Internal_TemplateBase { public $allow_php_templates = false; /** * Should compiled-templates be prevented from being called directly? - * * {@internal * Currently used by Smarty_Internal_Template only. * }} @@ -371,7 +400,6 @@ class Smarty extends Smarty_Internal_TemplateBase { /**#@-*/ /** * debug mode - * * Setting this to true enables the debug-console. * * @var boolean @@ -383,12 +411,12 @@ class Smarty extends Smarty_Internal_TemplateBase { *
  • NONE => no debugging control allowed
  • *
  • URL => enable debugging when SMARTY_DEBUG is found in the URL.
  • * + * * @var string */ public $debugging_ctrl = 'NONE'; /** * Name of debugging URL-param. - * * Only used when $debugging_ctrl is set to 'URL'. * The name of the URL-parameter that activates debugging. * @@ -397,16 +425,19 @@ class Smarty extends Smarty_Internal_TemplateBase { public $smarty_debug_id = 'SMARTY_DEBUG'; /** * Path of debug template. + * * @var string */ public $debug_tpl = null; /** * When set, smarty uses this value as error_reporting-level. + * * @var int */ public $error_reporting = null; /** * Internal flag for getTags() + * * @var boolean */ public $get_used_tags = false; @@ -417,16 +448,19 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Controls whether variables with the same name overwrite each other. + * * @var boolean */ public $config_overwrite = true; /** * Controls whether config values of on/true/yes and off/false/no get converted to boolean. + * * @var boolean */ public $config_booleanize = true; /** * Controls whether hidden config sections/vars are read from the file. + * * @var boolean */ public $config_read_hidden = false; @@ -439,16 +473,19 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * locking concurrent compiles + * * @var boolean */ public $compile_locking = true; /** * Controls whether cache resources should emply locking mechanism + * * @var boolean */ public $cache_locking = false; /** * seconds to wait for acquiring a lock before ignoring the write lock + * * @var float */ public $locking_timeout = 10; @@ -457,19 +494,19 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * global template functions + * * @var array */ public $template_functions = array(); /** * resource type used if none given - * * Must be an valid key of $registered_resources. + * * @var string */ public $default_resource_type = 'file'; /** * caching type - * * Must be an element of $cache_resource_types. * * @var string @@ -477,121 +514,145 @@ class Smarty extends Smarty_Internal_TemplateBase { public $caching_type = 'file'; /** * internal config properties + * * @var array */ public $properties = array(); /** * config type + * * @var string */ public $default_config_type = 'file'; /** * cached template objects + * * @var array */ public $template_objects = array(); /** * check If-Modified-Since headers + * * @var boolean */ public $cache_modified_check = false; /** * registered plugins + * * @var array */ public $registered_plugins = array(); /** * plugin search order + * * @var array */ public $plugin_search_order = array('function', 'block', 'compiler', 'class'); /** * registered objects + * * @var array */ public $registered_objects = array(); /** * registered classes + * * @var array */ public $registered_classes = array(); /** * registered filters + * * @var array */ public $registered_filters = array(); /** * registered resources + * * @var array */ public $registered_resources = array(); /** * resource handler cache + * * @var array */ public $_resource_handlers = array(); /** * registered cache resources + * * @var array */ public $registered_cache_resources = array(); /** * cache resource handler cache + * * @var array */ public $_cacheresource_handlers = array(); /** * autoload filter + * * @var array */ public $autoload_filters = array(); /** * default modifier + * * @var array */ public $default_modifiers = array(); /** * autoescape variable output + * * @var boolean */ public $escape_html = false; /** * global internal smarty vars + * * @var array */ public static $_smarty_vars = array(); /** * start time for execution time calculation + * * @var int */ public $start_time = 0; /** * default file permissions + * * @var int */ public $_file_perms = 0644; /** * default dir permissions + * * @var int */ public $_dir_perms = 0771; /** * block tag hierarchy + * * @var array */ public $_tag_stack = array(); /** * self pointer to Smarty object + * * @var Smarty */ public $smarty; /** * required by the compiler for BC + * * @var string */ public $_current_file = null; /** * internal flag to enable parser debugging + * * @var bool */ public $_parserdebug = false; @@ -605,7 +666,7 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Initialize new Smarty object - * + */ public function __construct() { @@ -628,7 +689,6 @@ class Smarty extends Smarty_Internal_TemplateBase { } } - /** * Class destructor */ @@ -645,36 +705,34 @@ class Smarty extends Smarty_Internal_TemplateBase { $this->smarty = $this; } - /** * <> Generic getter. - * * Calls the appropriate getter function. * Issues an E_USER_NOTICE if no valid getter is found. * - * @param string $name property name + * @param string $name property name + * * @return mixed */ public function __get($name) { $allowed = array( - 'template_dir' => 'getTemplateDir', - 'config_dir' => 'getConfigDir', - 'plugins_dir' => 'getPluginsDir', - 'compile_dir' => 'getCompileDir', - 'cache_dir' => 'getCacheDir', + 'template_dir' => 'getTemplateDir', + 'config_dir' => 'getConfigDir', + 'plugins_dir' => 'getPluginsDir', + 'compile_dir' => 'getCompileDir', + 'cache_dir' => 'getCacheDir', ); if (isset($allowed[$name])) { return $this->{$allowed[$name]}(); } else { - trigger_error('Undefined property: '. get_class($this) .'::$'. $name, E_USER_NOTICE); + trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); } } /** * <> Generic setter. - * * Calls the appropriate setter function. * Issues an E_USER_NOTICE if no valid setter is found. * @@ -684,11 +742,11 @@ class Smarty extends Smarty_Internal_TemplateBase { public function __set($name, $value) { $allowed = array( - 'template_dir' => 'setTemplateDir', - 'config_dir' => 'setConfigDir', - 'plugins_dir' => 'setPluginsDir', - 'compile_dir' => 'setCompileDir', - 'cache_dir' => 'setCacheDir', + 'template_dir' => 'setTemplateDir', + 'config_dir' => 'setConfigDir', + 'plugins_dir' => 'setPluginsDir', + 'compile_dir' => 'setCompileDir', + 'cache_dir' => 'setCacheDir', ); if (isset($allowed[$name])) { @@ -701,7 +759,8 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Check if a template resource exists * - * @param string $resource_name template name + * @param string $resource_name template name + * * @return boolean status */ public function templateExists($resource_name) @@ -712,14 +771,15 @@ class Smarty extends Smarty_Internal_TemplateBase { // check if it does exists $result = $tpl->source->exists; $this->template_objects = $save; + return $result; } /** * Returns a single or all global variables * - * @param object $smarty - * @param string $varname variable name or null + * @param string $varname variable name or null + * * @return string variable value or or array of variables */ public function getGlobal($varname = null) @@ -735,6 +795,7 @@ class Smarty extends Smarty_Internal_TemplateBase { foreach (self::$global_tpl_vars AS $key => $var) { $_result[$key] = $var->value; } + return $_result; } } @@ -742,26 +803,29 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Empty cache folder * - * @param integer $exp_time expiration time - * @param string $type resource type + * @param integer $exp_time expiration time + * @param string $type resource type + * * @return integer number of cache files deleted */ - function clearAllCache($exp_time = null, $type = null) + public function clearAllCache($exp_time = null, $type = null) { // load cache resource and call clearAll $_cache_resource = Smarty_CacheResource::load($this, $type); Smarty_CacheResource::invalidLoadedCache($this); + return $_cache_resource->clearAll($this, $exp_time); } /** * Empty cache for a specific template * - * @param string $template_name template name - * @param string $cache_id cache id - * @param string $compile_id compile id - * @param integer $exp_time expiration time - * @param string $type resource type + * @param string $template_name template name + * @param string $cache_id cache id + * @param string $compile_id compile id + * @param integer $exp_time expiration time + * @param string $type resource type + * * @return integer number of cache files deleted */ public function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null) @@ -769,20 +833,23 @@ class Smarty extends Smarty_Internal_TemplateBase { // load cache resource and call clear $_cache_resource = Smarty_CacheResource::load($this, $type); Smarty_CacheResource::invalidLoadedCache($this); + return $_cache_resource->clear($this, $template_name, $cache_id, $compile_id, $exp_time); } /** * Loads security class and enables security * - * @param string|Smarty_Security $security_class if a string is used, it must be class-name - * @return Smarty current Smarty instance for chaining - * @throws SmartyException when an invalid class name is provided + * @param string|Smarty_Security $security_class if a string is used, it must be class-name + * + * @return Smarty current Smarty instance for chaining + * @throws SmartyException when an invalid class name is provided */ public function enableSecurity($security_class = null) { if ($security_class instanceof Smarty_Security) { $this->security_policy = $security_class; + return $this; } elseif (is_object($security_class)) { throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security."); @@ -803,6 +870,7 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Disable security + * * @return Smarty current Smarty instance for chaining */ public function disableSecurity() @@ -815,145 +883,164 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Set template directory * - * @param string|array $template_dir directory(s) of template sources - * @return Smarty current Smarty instance for chaining + * @param string|array $template_dir directory(s) of template sources + * + * @return Smarty current Smarty instance for chaining */ public function setTemplateDir($template_dir) { $this->template_dir = array(); foreach ((array) $template_dir as $k => $v) { - $this->template_dir[$k] = rtrim($v, '/\\') . DS; + $this->template_dir[$k] = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($v, '/\\')) . DS; } $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); + return $this; } /** * Add template directory(s) * - * @param string|array $template_dir directory(s) of template sources - * @param string $key of the array element to assign the template dir to - * @return Smarty current Smarty instance for chaining + * @param string|array $template_dir directory(s) of template sources + * @param string $key of the array element to assign the template dir to + * + * @return Smarty current Smarty instance for chaining * @throws SmartyException when the given template directory is not valid */ - public function addTemplateDir($template_dir, $key=null) + public function addTemplateDir($template_dir, $key = null) { // make sure we're dealing with an array $this->template_dir = (array) $this->template_dir; if (is_array($template_dir)) { foreach ($template_dir as $k => $v) { + $v = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($v, '/\\')) . DS; if (is_int($k)) { // indexes are not merged but appended - $this->template_dir[] = rtrim($v, '/\\') . DS; + $this->template_dir[] = $v; } else { // string indexes are overridden - $this->template_dir[$k] = rtrim($v, '/\\') . DS; + $this->template_dir[$k] = $v; } } - } elseif ($key !== null) { - // override directory at specified index - $this->template_dir[$key] = rtrim($template_dir, '/\\') . DS; } else { - // append new directory - $this->template_dir[] = rtrim($template_dir, '/\\') . DS; + $v = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($template_dir, '/\\')) . DS; + if ($key !== null) { + // override directory at specified index + $this->template_dir[$key] = $v; + } else { + // append new directory + $this->template_dir[] = $v; + } } $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); + return $this; } /** * Get template directories * - * @param mixed index of directory to get, null to get all + * @param mixed $index index of directory to get, null to get all + * * @return array|string list of template directories, or directory of $index */ - public function getTemplateDir($index=null) + public function getTemplateDir($index = null) { if ($index !== null) { return isset($this->template_dir[$index]) ? $this->template_dir[$index] : null; } - return (array)$this->template_dir; + return (array) $this->template_dir; } /** * Set config directory * - * @param string|array $template_dir directory(s) of configuration sources - * @return Smarty current Smarty instance for chaining + * @param $config_dir + * + * @return Smarty current Smarty instance for chaining */ public function setConfigDir($config_dir) { $this->config_dir = array(); foreach ((array) $config_dir as $k => $v) { - $this->config_dir[$k] = rtrim($v, '/\\') . DS; + $this->config_dir[$k] = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($v, '/\\')) . DS; } $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); + return $this; } /** * Add config directory(s) * - * @param string|array $config_dir directory(s) of config sources - * @param string key of the array element to assign the config dir to + * @param string|array $config_dir directory(s) of config sources + * @param mixed $key key of the array element to assign the config dir to + * * @return Smarty current Smarty instance for chaining */ - public function addConfigDir($config_dir, $key=null) + public function addConfigDir($config_dir, $key = null) { // make sure we're dealing with an array $this->config_dir = (array) $this->config_dir; if (is_array($config_dir)) { foreach ($config_dir as $k => $v) { + $v = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($v, '/\\')) . DS; if (is_int($k)) { // indexes are not merged but appended - $this->config_dir[] = rtrim($v, '/\\') . DS; + $this->config_dir[] = $v; } else { // string indexes are overridden - $this->config_dir[$k] = rtrim($v, '/\\') . DS; + $this->config_dir[$k] = $v; } } - } elseif( $key !== null ) { - // override directory at specified index - $this->config_dir[$key] = rtrim($config_dir, '/\\') . DS; } else { - // append new directory - $this->config_dir[] = rtrim($config_dir, '/\\') . DS; + $v = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($config_dir, '/\\')) . DS; + if ($key !== null) { + // override directory at specified index + $this->config_dir[$key] = rtrim($v, '/\\') . DS; + } else { + // append new directory + $this->config_dir[] = rtrim($v, '/\\') . DS; + } } $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); + return $this; } /** * Get config directory * - * @param mixed index of directory to get, null to get all + * @param mixed $index index of directory to get, null to get all + * * @return array|string configuration directory */ - public function getConfigDir($index=null) + public function getConfigDir($index = null) { if ($index !== null) { return isset($this->config_dir[$index]) ? $this->config_dir[$index] : null; } - return (array)$this->config_dir; + return (array) $this->config_dir; } /** * Set plugins directory * - * @param string|array $plugins_dir directory(s) of plugins - * @return Smarty current Smarty instance for chaining + * @param string|array $plugins_dir directory(s) of plugins + * + * @return Smarty current Smarty instance for chaining */ public function setPluginsDir($plugins_dir) { $this->plugins_dir = array(); - foreach ((array)$plugins_dir as $k => $v) { + foreach ((array) $plugins_dir as $k => $v) { $this->plugins_dir[$k] = rtrim($v, '/\\') . DS; } @@ -963,8 +1050,8 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Adds directory of plugin files * - * @param object $smarty - * @param string $ |array $ plugins folder + * @param $plugins_dir + * * @return Smarty current Smarty instance for chaining */ public function addPluginsDir($plugins_dir) @@ -988,6 +1075,7 @@ class Smarty extends Smarty_Internal_TemplateBase { } $this->plugins_dir = array_unique($this->plugins_dir); + return $this; } @@ -998,13 +1086,14 @@ class Smarty extends Smarty_Internal_TemplateBase { */ public function getPluginsDir() { - return (array)$this->plugins_dir; + return (array) $this->plugins_dir; } /** * Set compile directory * - * @param string $compile_dir directory to store compiled templates in + * @param string $compile_dir directory to store compiled templates in + * * @return Smarty current Smarty instance for chaining */ public function setCompileDir($compile_dir) @@ -1013,6 +1102,7 @@ class Smarty extends Smarty_Internal_TemplateBase { if (!isset(Smarty::$_muted_directories[$this->compile_dir])) { Smarty::$_muted_directories[$this->compile_dir] = null; } + return $this; } @@ -1029,7 +1119,8 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Set cache directory * - * @param string $cache_dir directory to store cached templates in + * @param string $cache_dir directory to store cached templates in + * * @return Smarty current Smarty instance for chaining */ public function setCacheDir($cache_dir) @@ -1038,6 +1129,7 @@ class Smarty extends Smarty_Internal_TemplateBase { if (!isset(Smarty::$_muted_directories[$this->cache_dir])) { Smarty::$_muted_directories[$this->cache_dir] = null; } + return $this; } @@ -1054,20 +1146,23 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Set default modifiers * - * @param array|string $modifiers modifier or list of modifiers to set - * @return Smarty current Smarty instance for chaining + * @param array|string $modifiers modifier or list of modifiers to set + * + * @return Smarty current Smarty instance for chaining */ public function setDefaultModifiers($modifiers) { $this->default_modifiers = (array) $modifiers; + return $this; } /** * Add default modifiers * - * @param array|string $modifiers modifier or list of modifiers to add - * @return Smarty current Smarty instance for chaining + * @param array|string $modifiers modifier or list of modifiers to add + * + * @return Smarty current Smarty instance for chaining */ public function addDefaultModifiers($modifiers) { @@ -1090,15 +1185,15 @@ class Smarty extends Smarty_Internal_TemplateBase { return $this->default_modifiers; } - /** * Set autoload filters * - * @param array $filters filters to load automatically - * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types + * @param array $filters filters to load automatically + * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types + * * @return Smarty current Smarty instance for chaining */ - public function setAutoloadFilters($filters, $type=null) + public function setAutoloadFilters($filters, $type = null) { if ($type !== null) { $this->autoload_filters[$type] = (array) $filters; @@ -1112,11 +1207,12 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Add autoload filters * - * @param array $filters filters to load automatically - * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types + * @param array $filters filters to load automatically + * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types + * * @return Smarty current Smarty instance for chaining */ - public function addAutoloadFilters($filters, $type=null) + public function addAutoloadFilters($filters, $type = null) { if ($type !== null) { if (!empty($this->autoload_filters[$type])) { @@ -1140,10 +1236,11 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Get autoload filters * - * @param string $type type of filter to get autoloads for. Defaults to all autoload filters - * @return array array( 'type1' => array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type was specified + * @param string $type type of filter to get autoloads for. Defaults to all autoload filters + * + * @return array array( 'type1' => array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type was specified */ - public function getAutoloadFilters($type=null) + public function getAutoloadFilters($type = null) { if ($type !== null) { return isset($this->autoload_filters[$type]) ? $this->autoload_filters[$type] : array(); @@ -1165,8 +1262,9 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * set the debug template * - * @param string $tpl_name - * @return Smarty current Smarty instance for chaining + * @param string $tpl_name + * + * @return Smarty current Smarty instance for chaining * @throws SmartyException if file is not readable */ public function setDebugTemplate($tpl_name) @@ -1182,20 +1280,21 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * creates a template object * - * @param string $template the resource handle of the template file - * @param mixed $cache_id cache id to be used with this template - * @param mixed $compile_id compile id to be used with this template - * @param object $parent next higher level of Smarty variables - * @param boolean $do_clone flag is Smarty object shall be cloned - * @return object template object + * @param string $template the resource handle of the template file + * @param mixed $cache_id cache id to be used with this template + * @param mixed $compile_id compile id to be used with this template + * @param object $parent next higher level of Smarty variables + * @param boolean $do_clone flag is Smarty object shall be cloned + * + * @return object template object */ public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true) { - if (!empty($cache_id) && (is_object($cache_id) || is_array($cache_id))) { + if ($cache_id !== null && (is_object($cache_id) || is_array($cache_id))) { $parent = $cache_id; $cache_id = null; } - if (!empty($parent) && is_array($parent)) { + if ($parent !== null && is_array($parent)) { $data = $parent; $parent = null; } else { @@ -1242,17 +1341,19 @@ class Smarty extends Smarty_Internal_TemplateBase { $tpl->tpl_vars[$_key] = new Smarty_variable($_val); } } + return $tpl; } - /** * Takes unknown classes and loads plugin files for them * class name format: Smarty_PluginType_PluginName * plugin filename format: plugintype.pluginname.php * - * @param string $plugin_name class plugin name to load - * @param bool $check check if already loaded + * @param string $plugin_name class plugin name to load + * @param bool $check check if already loaded + * + * @throws SmartyException * @return string |boolean filepath of loaded file or false */ public function loadPlugin($plugin_name, $check = true) @@ -1267,13 +1368,13 @@ class Smarty extends Smarty_Internal_TemplateBase { // count($_name_parts) < 3 === !isset($_name_parts[2]) if (!isset($_name_parts[2]) || strtolower($_name_parts[0]) !== 'smarty') { throw new SmartyException("plugin {$plugin_name} is not a valid name format"); - return false; } // if type is "internal", get plugin from sysplugins if (strtolower($_name_parts[1]) == 'internal') { $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php'; if (file_exists($file)) { require_once($file); + return $file; } else { return false; @@ -1285,7 +1386,7 @@ class Smarty extends Smarty_Internal_TemplateBase { $_stream_resolve_include_path = function_exists('stream_resolve_include_path'); // loop through plugin dirs and find the plugin - foreach($this->getPluginsDir() as $_plugin_dir) { + foreach ($this->getPluginsDir() as $_plugin_dir) { $names = array( $_plugin_dir . $_plugin_filename, $_plugin_dir . strtolower($_plugin_filename), @@ -1293,6 +1394,7 @@ class Smarty extends Smarty_Internal_TemplateBase { foreach ($names as $file) { if (file_exists($file)) { require_once($file); + return $file; } if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) { @@ -1305,6 +1407,7 @@ class Smarty extends Smarty_Internal_TemplateBase { if ($file !== false) { require_once($file); + return $file; } } @@ -1317,37 +1420,40 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Compile all template files * - * @param string $extension file extension - * @param bool $force_compile force all to recompile - * @param int $time_limit - * @param int $max_errors + * @param string $extension file extension + * @param bool $force_compile force all to recompile + * @param int $time_limit + * @param int $max_errors + * * @return integer number of template files recompiled */ - public function compileAllTemplates($extention = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null) + public function compileAllTemplates($extension = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null) { - return Smarty_Internal_Utility::compileAllTemplates($extention, $force_compile, $time_limit, $max_errors, $this); + return Smarty_Internal_Utility::compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, $this); } /** * Compile all config files * - * @param string $extension file extension - * @param bool $force_compile force all to recompile - * @param int $time_limit - * @param int $max_errors + * @param string $extension file extension + * @param bool $force_compile force all to recompile + * @param int $time_limit + * @param int $max_errors + * * @return integer number of template files recompiled */ - public function compileAllConfig($extention = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null) + public function compileAllConfig($extension = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null) { - return Smarty_Internal_Utility::compileAllConfig($extention, $force_compile, $time_limit, $max_errors, $this); + return Smarty_Internal_Utility::compileAllConfig($extension, $force_compile, $time_limit, $max_errors, $this); } /** * Delete compiled template file * - * @param string $resource_name template name - * @param string $compile_id compile id - * @param integer $exp_time expiration time + * @param string $resource_name template name + * @param string $compile_id compile id + * @param integer $exp_time expiration time + * * @return integer number of template files deleted */ public function clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null) @@ -1355,12 +1461,12 @@ class Smarty extends Smarty_Internal_TemplateBase { return Smarty_Internal_Utility::clearCompiledTemplate($resource_name, $compile_id, $exp_time, $this); } - /** * Return array of tag/attributes of all tags used by an template * - * @param object $templae template object - * @return array of tag/attributes + * @param Smarty_Internal_Template $template + * + * @return array of tag/attributes */ public function getTags(Smarty_Internal_Template $template) { @@ -1370,10 +1476,11 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Run installation test * - * @param array $errors Array to write errors into, rather than outputting them + * @param array $errors Array to write errors into, rather than outputting them + * * @return boolean true if setup is fine, false if something is wrong */ - public function testInstall(&$errors=null) + public function testInstall(&$errors = null) { return Smarty_Internal_Utility::testInstall($this, $errors); } @@ -1382,7 +1489,13 @@ class Smarty extends Smarty_Internal_TemplateBase { * Error Handler to mute expected messages * * @link http://php.net/set_error_handler - * @param integer $errno Error level + * + * @param integer $errno Error level + * @param $errstr + * @param $errfile + * @param $errline + * @param $errcontext + * * @return boolean */ public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext) @@ -1394,7 +1507,7 @@ class Smarty extends Smarty_Internal_TemplateBase { $smarty_dir = realpath(SMARTY_DIR); if ($smarty_dir !== false) { Smarty::$_muted_directories[SMARTY_DIR] = array( - 'file' => $smarty_dir, + 'file' => $smarty_dir, 'length' => strlen($smarty_dir), ); } @@ -1411,7 +1524,7 @@ class Smarty extends Smarty_Internal_TemplateBase { continue; } $dir = array( - 'file' => $file, + 'file' => $file, 'length' => strlen($file), ); } @@ -1485,20 +1598,55 @@ if (Smarty::$_CHARSET !== 'UTF-8') { /** * Smarty exception class + * * @package Smarty */ -class SmartyException extends Exception { - public static $escape = true; - public function __construct($message) { - $this->message = self::$escape ? htmlentities($message) : $message; +class SmartyException extends Exception +{ + public static $escape = false; + + public function __toString() + { + return ' --> Smarty: ' . (self::$escape ? htmlentities($this->message) : $this->message) . ' <-- '; } } /** * Smarty compiler exception class + * * @package Smarty */ -class SmartyCompilerException extends SmartyException { +class SmartyCompilerException extends SmartyException +{ + public function __toString() + { + return ' --> Smarty Compiler: ' . $this->message . ' <-- '; + } + + /** + * The line number of the template error + * + * @type int|null + */ + public $line = null; + /** + * The template source snippet relating to the error + * + * @type string|null + */ + public $source = null; + /** + * The raw text of the error message + * + * @type string|null + */ + public $desc = null; + /** + * The resource identifier or template name + * + * @type string|null + */ + public $template = null; } /** @@ -1507,22 +1655,20 @@ class SmartyCompilerException extends SmartyException { function smartyAutoload($class) { $_class = strtolower($class); - $_classes = array( - 'smarty_config_source' => true, - 'smarty_config_compiled' => true, - 'smarty_security' => true, - 'smarty_cacheresource' => true, - 'smarty_cacheresource_custom' => true, + static $_classes = array( + 'smarty_config_source' => true, + 'smarty_config_compiled' => true, + 'smarty_security' => true, + 'smarty_cacheresource' => true, + 'smarty_cacheresource_custom' => true, 'smarty_cacheresource_keyvaluestore' => true, - 'smarty_resource' => true, - 'smarty_resource_custom' => true, - 'smarty_resource_uncompiled' => true, - 'smarty_resource_recompiled' => true, + 'smarty_resource' => true, + 'smarty_resource_custom' => true, + 'smarty_resource_uncompiled' => true, + 'smarty_resource_recompiled' => true, ); if (!strncmp($_class, 'smarty_internal_', 16) || isset($_classes[$_class])) { include SMARTY_SYSPLUGINS_DIR . $_class . '.php'; } } - -?> diff --git a/code/web/private_php/ams/smarty/libs/SmartyBC.class.php b/code/web/private_php/ams/smarty/libs/SmartyBC.class.php index f8f0a138f..cec946746 100644 --- a/code/web/private_php/ams/smarty/libs/SmartyBC.class.php +++ b/code/web/private_php/ams/smarty/libs/SmartyBC.class.php @@ -1,460 +1,467 @@ - - * @author Uwe Tews - * @author Rodney Rehm - * @package Smarty - */ -/** - * @ignore - */ -require(dirname(__FILE__) . '/Smarty.class.php'); - -/** - * Smarty Backward Compatability Wrapper Class - * - * @package Smarty - */ -class SmartyBC extends Smarty { - - /** - * Smarty 2 BC - * @var string - */ - public $_version = self::SMARTY_VERSION; - - /** - * Initialize new SmartyBC object - * - * @param array $options options to set during initialization, e.g. array( 'forceCompile' => false ) - */ - public function __construct(array $options=array()) - { - parent::__construct($options); - // register {php} tag - $this->registerPlugin('block', 'php', 'smarty_php_tag'); - } - - /** - * wrapper for assign_by_ref - * - * @param string $tpl_var the template variable name - * @param mixed &$value the referenced value to assign - */ - public function assign_by_ref($tpl_var, &$value) - { - $this->assignByRef($tpl_var, $value); - } - - /** - * wrapper for append_by_ref - * - * @param string $tpl_var the template variable name - * @param mixed &$value the referenced value to append - * @param boolean $merge flag if array elements shall be merged - */ - public function append_by_ref($tpl_var, &$value, $merge = false) - { - $this->appendByRef($tpl_var, $value, $merge); - } - - /** - * clear the given assigned template variable. - * - * @param string $tpl_var the template variable to clear - */ - public function clear_assign($tpl_var) - { - $this->clearAssign($tpl_var); - } - - /** - * Registers custom function to be used in templates - * - * @param string $function the name of the template function - * @param string $function_impl the name of the PHP function to register - * @param bool $cacheable - * @param mixed $cache_attrs - */ - public function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null) - { - $this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs); - } - - /** - * Unregisters custom function - * - * @param string $function name of template function - */ - public function unregister_function($function) - { - $this->unregisterPlugin('function', $function); - } - - /** - * Registers object to be used in templates - * - * @param string $object name of template object - * @param object $object_impl the referenced PHP object to register - * @param array $allowed list of allowed methods (empty = all) - * @param boolean $smarty_args smarty argument format, else traditional - * @param array $block_functs list of methods that are block format - */ - public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) - { - settype($allowed, 'array'); - settype($smarty_args, 'boolean'); - $this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods); - } - - /** - * Unregisters object - * - * @param string $object name of template object - */ - public function unregister_object($object) - { - $this->unregisterObject($object); - } - - /** - * Registers block function to be used in templates - * - * @param string $block name of template block - * @param string $block_impl PHP function to register - * @param bool $cacheable - * @param mixed $cache_attrs - */ - public function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null) - { - $this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs); - } - - /** - * Unregisters block function - * - * @param string $block name of template function - */ - public function unregister_block($block) - { - $this->unregisterPlugin('block', $block); - } - - /** - * Registers compiler function - * - * @param string $function name of template function - * @param string $function_impl name of PHP function to register - * @param bool $cacheable - */ - public function register_compiler_function($function, $function_impl, $cacheable=true) - { - $this->registerPlugin('compiler', $function, $function_impl, $cacheable); - } - - /** - * Unregisters compiler function - * - * @param string $function name of template function - */ - public function unregister_compiler_function($function) - { - $this->unregisterPlugin('compiler', $function); - } - - /** - * Registers modifier to be used in templates - * - * @param string $modifier name of template modifier - * @param string $modifier_impl name of PHP function to register - */ - public function register_modifier($modifier, $modifier_impl) - { - $this->registerPlugin('modifier', $modifier, $modifier_impl); - } - - /** - * Unregisters modifier - * - * @param string $modifier name of template modifier - */ - public function unregister_modifier($modifier) - { - $this->unregisterPlugin('modifier', $modifier); - } - - /** - * Registers a resource to fetch a template - * - * @param string $type name of resource - * @param array $functions array of functions to handle resource - */ - public function register_resource($type, $functions) - { - $this->registerResource($type, $functions); - } - - /** - * Unregisters a resource - * - * @param string $type name of resource - */ - public function unregister_resource($type) - { - $this->unregisterResource($type); - } - - /** - * Registers a prefilter function to apply - * to a template before compiling - * - * @param callable $function - */ - public function register_prefilter($function) - { - $this->registerFilter('pre', $function); - } - - /** - * Unregisters a prefilter function - * - * @param callable $function - */ - public function unregister_prefilter($function) - { - $this->unregisterFilter('pre', $function); - } - - /** - * Registers a postfilter function to apply - * to a compiled template after compilation - * - * @param callable $function - */ - public function register_postfilter($function) - { - $this->registerFilter('post', $function); - } - - /** - * Unregisters a postfilter function - * - * @param callable $function - */ - public function unregister_postfilter($function) - { - $this->unregisterFilter('post', $function); - } - - /** - * Registers an output filter function to apply - * to a template output - * - * @param callable $function - */ - public function register_outputfilter($function) - { - $this->registerFilter('output', $function); - } - - /** - * Unregisters an outputfilter function - * - * @param callable $function - */ - public function unregister_outputfilter($function) - { - $this->unregisterFilter('output', $function); - } - - /** - * load a filter of specified type and name - * - * @param string $type filter type - * @param string $name filter name - */ - public function load_filter($type, $name) - { - $this->loadFilter($type, $name); - } - - /** - * clear cached content for the given template and cache id - * - * @param string $tpl_file name of template file - * @param string $cache_id name of cache_id - * @param string $compile_id name of compile_id - * @param string $exp_time expiration time - * @return boolean - */ - public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) - { - return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time); - } - - /** - * clear the entire contents of cache (all templates) - * - * @param string $exp_time expire time - * @return boolean - */ - public function clear_all_cache($exp_time = null) - { - return $this->clearCache(null, null, null, $exp_time); - } - - /** - * test to see if valid cache exists for this template - * - * @param string $tpl_file name of template file - * @param string $cache_id - * @param string $compile_id - * @return boolean - */ - public function is_cached($tpl_file, $cache_id = null, $compile_id = null) - { - return $this->isCached($tpl_file, $cache_id, $compile_id); - } - - /** - * clear all the assigned template variables. - */ - public function clear_all_assign() - { - $this->clearAllAssign(); - } - - /** - * clears compiled version of specified template resource, - * or all compiled template files if one is not specified. - * This function is for advanced use only, not normally needed. - * - * @param string $tpl_file - * @param string $compile_id - * @param string $exp_time - * @return boolean results of {@link smarty_core_rm_auto()} - */ - public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null) - { - return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time); - } - - /** - * Checks whether requested template exists. - * - * @param string $tpl_file - * @return boolean - */ - public function template_exists($tpl_file) - { - return $this->templateExists($tpl_file); - } - - /** - * Returns an array containing template variables - * - * @param string $name - * @return array - */ - public function get_template_vars($name=null) - { - return $this->getTemplateVars($name); - } - - /** - * Returns an array containing config variables - * - * @param string $name - * @return array - */ - public function get_config_vars($name=null) - { - return $this->getConfigVars($name); - } - - /** - * load configuration values - * - * @param string $file - * @param string $section - * @param string $scope - */ - public function config_load($file, $section = null, $scope = 'global') - { - $this->ConfigLoad($file, $section, $scope); - } - - /** - * return a reference to a registered object - * - * @param string $name - * @return object - */ - public function get_registered_object($name) - { - return $this->getRegisteredObject($name); - } - - /** - * clear configuration values - * - * @param string $var - */ - public function clear_config($var = null) - { - $this->clearConfig($var); - } - - /** - * trigger Smarty error - * - * @param string $error_msg - * @param integer $error_type - */ - public function trigger_error($error_msg, $error_type = E_USER_WARNING) - { - trigger_error("Smarty error: $error_msg", $error_type); - } - -} - -/** - * Smarty {php}{/php} block function - * - * @param array $params parameter list - * @param string $content contents of the block - * @param object $template template object - * @param boolean &$repeat repeat flag - * @return string content re-formatted - */ -function smarty_php_tag($params, $content, $template, &$repeat) -{ - eval($content); - return ''; -} - -?> \ No newline at end of file + + * @author Uwe Tews + * @author Rodney Rehm + * @package Smarty + */ +/** + * @ignore + */ +require_once(dirname(__FILE__) . '/Smarty.class.php'); + +/** + * Smarty Backward Compatability Wrapper Class + * + * @package Smarty + */ +class SmartyBC extends Smarty +{ + /** + * Smarty 2 BC + * + * @var string + */ + public $_version = self::SMARTY_VERSION; + + /** + * Initialize new SmartyBC object + * + * @param array $options options to set during initialization, e.g. array( 'forceCompile' => false ) + */ + public function __construct(array $options = array()) + { + parent::__construct($options); + // register {php} tag + $this->registerPlugin('block', 'php', 'smarty_php_tag'); + } + + /** + * wrapper for assign_by_ref + * + * @param string $tpl_var the template variable name + * @param mixed &$value the referenced value to assign + */ + public function assign_by_ref($tpl_var, &$value) + { + $this->assignByRef($tpl_var, $value); + } + + /** + * wrapper for append_by_ref + * + * @param string $tpl_var the template variable name + * @param mixed &$value the referenced value to append + * @param boolean $merge flag if array elements shall be merged + */ + public function append_by_ref($tpl_var, &$value, $merge = false) + { + $this->appendByRef($tpl_var, $value, $merge); + } + + /** + * clear the given assigned template variable. + * + * @param string $tpl_var the template variable to clear + */ + public function clear_assign($tpl_var) + { + $this->clearAssign($tpl_var); + } + + /** + * Registers custom function to be used in templates + * + * @param string $function the name of the template function + * @param string $function_impl the name of the PHP function to register + * @param bool $cacheable + * @param mixed $cache_attrs + */ + public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null) + { + $this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs); + } + + /** + * Unregisters custom function + * + * @param string $function name of template function + */ + public function unregister_function($function) + { + $this->unregisterPlugin('function', $function); + } + + /** + * Registers object to be used in templates + * + * @param string $object name of template object + * @param object $object_impl the referenced PHP object to register + * @param array $allowed list of allowed methods (empty = all) + * @param boolean $smarty_args smarty argument format, else traditional + * @param array $block_methods list of methods that are block format + * + * @throws SmartyException + * @internal param array $block_functs list of methods that are block format + */ + public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) + { + settype($allowed, 'array'); + settype($smarty_args, 'boolean'); + $this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods); + } + + /** + * Unregisters object + * + * @param string $object name of template object + */ + public function unregister_object($object) + { + $this->unregisterObject($object); + } + + /** + * Registers block function to be used in templates + * + * @param string $block name of template block + * @param string $block_impl PHP function to register + * @param bool $cacheable + * @param mixed $cache_attrs + */ + public function register_block($block, $block_impl, $cacheable = true, $cache_attrs = null) + { + $this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs); + } + + /** + * Unregisters block function + * + * @param string $block name of template function + */ + public function unregister_block($block) + { + $this->unregisterPlugin('block', $block); + } + + /** + * Registers compiler function + * + * @param string $function name of template function + * @param string $function_impl name of PHP function to register + * @param bool $cacheable + */ + public function register_compiler_function($function, $function_impl, $cacheable = true) + { + $this->registerPlugin('compiler', $function, $function_impl, $cacheable); + } + + /** + * Unregisters compiler function + * + * @param string $function name of template function + */ + public function unregister_compiler_function($function) + { + $this->unregisterPlugin('compiler', $function); + } + + /** + * Registers modifier to be used in templates + * + * @param string $modifier name of template modifier + * @param string $modifier_impl name of PHP function to register + */ + public function register_modifier($modifier, $modifier_impl) + { + $this->registerPlugin('modifier', $modifier, $modifier_impl); + } + + /** + * Unregisters modifier + * + * @param string $modifier name of template modifier + */ + public function unregister_modifier($modifier) + { + $this->unregisterPlugin('modifier', $modifier); + } + + /** + * Registers a resource to fetch a template + * + * @param string $type name of resource + * @param array $functions array of functions to handle resource + */ + public function register_resource($type, $functions) + { + $this->registerResource($type, $functions); + } + + /** + * Unregisters a resource + * + * @param string $type name of resource + */ + public function unregister_resource($type) + { + $this->unregisterResource($type); + } + + /** + * Registers a prefilter function to apply + * to a template before compiling + * + * @param callable $function + */ + public function register_prefilter($function) + { + $this->registerFilter('pre', $function); + } + + /** + * Unregisters a prefilter function + * + * @param callable $function + */ + public function unregister_prefilter($function) + { + $this->unregisterFilter('pre', $function); + } + + /** + * Registers a postfilter function to apply + * to a compiled template after compilation + * + * @param callable $function + */ + public function register_postfilter($function) + { + $this->registerFilter('post', $function); + } + + /** + * Unregisters a postfilter function + * + * @param callable $function + */ + public function unregister_postfilter($function) + { + $this->unregisterFilter('post', $function); + } + + /** + * Registers an output filter function to apply + * to a template output + * + * @param callable $function + */ + public function register_outputfilter($function) + { + $this->registerFilter('output', $function); + } + + /** + * Unregisters an outputfilter function + * + * @param callable $function + */ + public function unregister_outputfilter($function) + { + $this->unregisterFilter('output', $function); + } + + /** + * load a filter of specified type and name + * + * @param string $type filter type + * @param string $name filter name + */ + public function load_filter($type, $name) + { + $this->loadFilter($type, $name); + } + + /** + * clear cached content for the given template and cache id + * + * @param string $tpl_file name of template file + * @param string $cache_id name of cache_id + * @param string $compile_id name of compile_id + * @param string $exp_time expiration time + * + * @return boolean + */ + public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) + { + return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time); + } + + /** + * clear the entire contents of cache (all templates) + * + * @param string $exp_time expire time + * + * @return boolean + */ + public function clear_all_cache($exp_time = null) + { + return $this->clearCache(null, null, null, $exp_time); + } + + /** + * test to see if valid cache exists for this template + * + * @param string $tpl_file name of template file + * @param string $cache_id + * @param string $compile_id + * + * @return boolean + */ + public function is_cached($tpl_file, $cache_id = null, $compile_id = null) + { + return $this->isCached($tpl_file, $cache_id, $compile_id); + } + + /** + * clear all the assigned template variables. + */ + public function clear_all_assign() + { + $this->clearAllAssign(); + } + + /** + * clears compiled version of specified template resource, + * or all compiled template files if one is not specified. + * This function is for advanced use only, not normally needed. + * + * @param string $tpl_file + * @param string $compile_id + * @param string $exp_time + * + * @return boolean results of {@link smarty_core_rm_auto()} + */ + public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null) + { + return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time); + } + + /** + * Checks whether requested template exists. + * + * @param string $tpl_file + * + * @return boolean + */ + public function template_exists($tpl_file) + { + return $this->templateExists($tpl_file); + } + + /** + * Returns an array containing template variables + * + * @param string $name + * + * @return array + */ + public function get_template_vars($name = null) + { + return $this->getTemplateVars($name); + } + + /** + * Returns an array containing config variables + * + * @param string $name + * + * @return array + */ + public function get_config_vars($name = null) + { + return $this->getConfigVars($name); + } + + /** + * load configuration values + * + * @param string $file + * @param string $section + * @param string $scope + */ + public function config_load($file, $section = null, $scope = 'global') + { + $this->ConfigLoad($file, $section, $scope); + } + + /** + * return a reference to a registered object + * + * @param string $name + * + * @return object + */ + public function get_registered_object($name) + { + return $this->getRegisteredObject($name); + } + + /** + * clear configuration values + * + * @param string $var + */ + public function clear_config($var = null) + { + $this->clearConfig($var); + } + + /** + * trigger Smarty error + * + * @param string $error_msg + * @param integer $error_type + */ + public function trigger_error($error_msg, $error_type = E_USER_WARNING) + { + trigger_error("Smarty error: $error_msg", $error_type); + } +} + +/** + * Smarty {php}{/php} block function + * + * @param array $params parameter list + * @param string $content contents of the block + * @param object $template template object + * @param boolean &$repeat repeat flag + * + * @return string content re-formatted + */ +function smarty_php_tag($params, $content, $template, &$repeat) +{ + eval($content); + + return ''; +} diff --git a/code/web/private_php/ams/smarty/libs/debug.tpl b/code/web/private_php/ams/smarty/libs/debug.tpl index 12eef0ffd..61b8876a4 100644 --- a/code/web/private_php/ams/smarty/libs/debug.tpl +++ b/code/web/private_php/ams/smarty/libs/debug.tpl @@ -1,133 +1,137 @@ {capture name='_smarty_debug' assign=debug_output} - - - - Smarty Debug Console - - - + #table_config_vars th { + color: maroon; + } -

    Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var nofilter}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}

    + {/literal} + + + -{if !empty($template_data)} -

    included templates & config files (load time in seconds)

    +

    Smarty Debug Console + - {if isset($template_name)}{$template_name|debug_print_var nofilter}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}

    -
    -{foreach $template_data as $template} - {$template.name} - - (compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"}) + {if !empty($template_data)} +

    included templates & config files (load time in seconds)

    +
    + {foreach $template_data as $template} + {$template.name} + + (compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"} + ) -
    -{/foreach} -
    -{/if} +
    + {/foreach} +
    + {/if} -

    assigned template variables

    +

    assigned template variables

    - - {foreach $assigned_vars as $vars} - - - - {/foreach} -
    ${$vars@key|escape:'html'}{$vars|debug_print_var nofilter}
    + + {foreach $assigned_vars as $vars} + + + + + {/foreach} +
    ${$vars@key|escape:'html'}{$vars|debug_print_var nofilter}
    -

    assigned config file variables (outer template scope)

    +

    assigned config file variables (outer template scope)

    - - {foreach $config_vars as $vars} - - - - {/foreach} +
    {$vars@key|escape:'html'}{$vars|debug_print_var nofilter}
    + {foreach $config_vars as $vars} + + + + + {/foreach} -
    {$vars@key|escape:'html'}{$vars|debug_print_var nofilter}
    - - + + + {/capture} diff --git a/code/web/private_php/ams/smarty/libs/plugins/block.textformat.php b/code/web/private_php/ams/smarty/libs/plugins/block.textformat.php index b22b104a5..abf544939 100644 --- a/code/web/private_php/ams/smarty/libs/plugins/block.textformat.php +++ b/code/web/private_php/ams/smarty/libs/plugins/block.textformat.php @@ -2,13 +2,12 @@ /** * Smarty plugin to format text blocks * - * @package Smarty + * @package Smarty * @subpackage PluginsBlock */ /** * Smarty {textformat}{/textformat} block plugin - * * Type: block function
    * Name: textformat
    * Purpose: format text a certain way with preset styles @@ -23,12 +22,14 @@ * - wrap_boundary - boolean (true) * * - * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat} - * (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat} + * (Smarty online manual) + * * @param array $params parameters * @param string $content contents of the block * @param Smarty_Internal_Template $template template object * @param boolean &$repeat repeat flag + * * @return string content re-formatted * @author Monte Ohrt */ @@ -53,17 +54,17 @@ function smarty_block_textformat($params, $content, $template, &$repeat) case 'indent_char': case 'wrap_char': case 'assign': - $$_key = (string)$_val; + $$_key = (string) $_val; break; case 'indent': case 'indent_first': case 'wrap': - $$_key = (int)$_val; + $$_key = (int) $_val; break; case 'wrap_cut': - $$_key = (bool)$_val; + $$_key = (bool) $_val; break; default: @@ -76,8 +77,6 @@ function smarty_block_textformat($params, $content, $template, &$repeat) } // split into paragraphs $_paragraphs = preg_split('![\r\n]{2}!', $content); - $_output = ''; - foreach ($_paragraphs as &$_paragraph) { if (!$_paragraph) { @@ -102,12 +101,10 @@ function smarty_block_textformat($params, $content, $template, &$repeat) } } $_output = implode($wrap_char . $wrap_char, $_paragraphs); - + if ($assign) { $template->assign($assign, $_output); } else { return $_output; } } - -?> \ No newline at end of file diff --git a/code/web/private_php/ams/smarty/libs/plugins/function.counter.php b/code/web/private_php/ams/smarty/libs/plugins/function.counter.php index 3906badf0..4da85a14e 100644 --- a/code/web/private_php/ams/smarty/libs/plugins/function.counter.php +++ b/code/web/private_php/ams/smarty/libs/plugins/function.counter.php @@ -1,22 +1,24 @@ * Name: counter
    * Purpose: print out a counter value * * @author Monte Ohrt - * @link http://www.smarty.net/manual/en/language.function.counter.php {counter} - * (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.function.counter.php {counter} + * (Smarty online manual) + * * @param array $params parameters * @param Smarty_Internal_Template $template template object + * * @return string|null */ function smarty_function_counter($params, $template) @@ -26,16 +28,16 @@ function smarty_function_counter($params, $template) $name = (isset($params['name'])) ? $params['name'] : 'default'; if (!isset($counters[$name])) { $counters[$name] = array( - 'start'=>1, - 'skip'=>1, - 'direction'=>'up', - 'count'=>1 - ); + 'start' => 1, + 'skip' => 1, + 'direction' => 'up', + 'count' => 1 + ); } $counter =& $counters[$name]; if (isset($params['start'])) { - $counter['start'] = $counter['count'] = (int)$params['start']; + $counter['start'] = $counter['count'] = (int) $params['start']; } if (!empty($params['assign'])) { @@ -45,9 +47,9 @@ function smarty_function_counter($params, $template) if (isset($counter['assign'])) { $template->assign($counter['assign'], $counter['count']); } - + if (isset($params['print'])) { - $print = (bool)$params['print']; + $print = (bool) $params['print']; } else { $print = empty($counter['assign']); } @@ -61,18 +63,16 @@ function smarty_function_counter($params, $template) if (isset($params['skip'])) { $counter['skip'] = $params['skip']; } - + if (isset($params['direction'])) { $counter['direction'] = $params['direction']; } - if ($counter['direction'] == "down") + if ($counter['direction'] == "down") { $counter['count'] -= $counter['skip']; - else + } else { $counter['count'] += $counter['skip']; - - return $retval; - -} + } -?> \ No newline at end of file + return $retval; +} diff --git a/code/web/private_php/ams/smarty/libs/plugins/function.cycle.php b/code/web/private_php/ams/smarty/libs/plugins/function.cycle.php index 1778ffb53..8dc5cd9d5 100644 --- a/code/web/private_php/ams/smarty/libs/plugins/function.cycle.php +++ b/code/web/private_php/ams/smarty/libs/plugins/function.cycle.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ /** * Smarty {cycle} function plugin - * * Type: function
    * Name: cycle
    * Date: May 3, 2002
    @@ -31,15 +30,17 @@ * {cycle name=row} * * - * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle} - * (Smarty online manual) - * @author Monte Ohrt - * @author credit to Mark Priatel - * @author credit to Gerard - * @author credit to Jason Sweat + * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle} + * (Smarty online manual) + * @author Monte Ohrt + * @author credit to Mark Priatel + * @author credit to Gerard + * @author credit to Jason Sweat * @version 1.3 + * * @param array $params parameters * @param Smarty_Internal_Template $template template object + * * @return string|null */ @@ -48,18 +49,20 @@ function smarty_function_cycle($params, $template) static $cycle_vars; $name = (empty($params['name'])) ? 'default' : $params['name']; - $print = (isset($params['print'])) ? (bool)$params['print'] : true; - $advance = (isset($params['advance'])) ? (bool)$params['advance'] : true; - $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false; + $print = (isset($params['print'])) ? (bool) $params['print'] : true; + $advance = (isset($params['advance'])) ? (bool) $params['advance'] : true; + $reset = (isset($params['reset'])) ? (bool) $params['reset'] : false; if (!isset($params['values'])) { - if(!isset($cycle_vars[$name]['values'])) { + if (!isset($cycle_vars[$name]['values'])) { trigger_error("cycle: missing 'values' parameter"); + return; } } else { - if(isset($cycle_vars[$name]['values']) - && $cycle_vars[$name]['values'] != $params['values'] ) { + if (isset($cycle_vars[$name]['values']) + && $cycle_vars[$name]['values'] != $params['values'] + ) { $cycle_vars[$name]['index'] = 0; } $cycle_vars[$name]['values'] = $params['values']; @@ -71,13 +74,13 @@ function smarty_function_cycle($params, $template) $cycle_vars[$name]['delimiter'] = ','; } - if(is_array($cycle_vars[$name]['values'])) { + if (is_array($cycle_vars[$name]['values'])) { $cycle_array = $cycle_vars[$name]['values']; } else { - $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']); + $cycle_array = explode($cycle_vars[$name]['delimiter'], $cycle_vars[$name]['values']); } - if(!isset($cycle_vars[$name]['index']) || $reset ) { + if (!isset($cycle_vars[$name]['index']) || $reset) { $cycle_vars[$name]['index'] = 0; } @@ -86,21 +89,19 @@ function smarty_function_cycle($params, $template) $template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); } - if($print) { + if ($print) { $retval = $cycle_array[$cycle_vars[$name]['index']]; } else { $retval = null; } - if($advance) { - if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) { + if ($advance) { + if ($cycle_vars[$name]['index'] >= count($cycle_array) - 1) { $cycle_vars[$name]['index'] = 0; } else { - $cycle_vars[$name]['index']++; + $cycle_vars[$name]['index'] ++; } } return $retval; } - -?> \ No newline at end of file diff --git a/code/web/private_php/ams/smarty/libs/plugins/function.fetch.php b/code/web/private_php/ams/smarty/libs/plugins/function.fetch.php index eca1182d5..3506d4a8d 100644 --- a/code/web/private_php/ams/smarty/libs/plugins/function.fetch.php +++ b/code/web/private_php/ams/smarty/libs/plugins/function.fetch.php @@ -2,50 +2,53 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ /** * Smarty {fetch} plugin - * * Type: function
    * Name: fetch
    * Purpose: fetch file, web or ftp data and display results * - * @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch} - * (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch} + * (Smarty online manual) * @author Monte Ohrt + * * @param array $params parameters * @param Smarty_Internal_Template $template template object + * + * @throws SmartyException * @return string|null if the assign parameter is passed, Smarty assigns the result to a template variable */ function smarty_function_fetch($params, $template) { if (empty($params['file'])) { - trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE); + trigger_error("[plugin] fetch parameter 'file' cannot be empty", E_USER_NOTICE); + return; } - + // strip file protocol if (stripos($params['file'], 'file://') === 0) { $params['file'] = substr($params['file'], 7); } - + $protocol = strpos($params['file'], '://'); if ($protocol !== false) { $protocol = strtolower(substr($params['file'], 0, $protocol)); } - + if (isset($template->smarty->security_policy)) { if ($protocol) { // remote resource (or php stream, …) - if(!$template->smarty->security_policy->isTrustedUri($params['file'])) { + if (!$template->smarty->security_policy->isTrustedUri($params['file'])) { return; } } else { // local file - if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) { + if (!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) { return; } } @@ -54,53 +57,54 @@ function smarty_function_fetch($params, $template) $content = ''; if ($protocol == 'http') { // http fetch - if($uri_parts = parse_url($params['file'])) { + if ($uri_parts = parse_url($params['file'])) { // set defaults $host = $server_name = $uri_parts['host']; $timeout = 30; $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; - $agent = "Smarty Template Engine ". Smarty::SMARTY_VERSION; + $agent = "Smarty Template Engine " . Smarty::SMARTY_VERSION; $referer = ""; $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; $_is_proxy = false; - if(empty($uri_parts['port'])) { + if (empty($uri_parts['port'])) { $port = 80; } else { $port = $uri_parts['port']; } - if(!empty($uri_parts['user'])) { + if (!empty($uri_parts['user'])) { $user = $uri_parts['user']; } - if(!empty($uri_parts['pass'])) { + if (!empty($uri_parts['pass'])) { $pass = $uri_parts['pass']; } // loop through parameters, setup headers - foreach($params as $param_key => $param_value) { - switch($param_key) { + foreach ($params as $param_key => $param_value) { + switch ($param_key) { case "file": case "assign": case "assign_headers": break; case "user": - if(!empty($param_value)) { + if (!empty($param_value)) { $user = $param_value; } break; case "pass": - if(!empty($param_value)) { + if (!empty($param_value)) { $pass = $param_value; } break; case "accept": - if(!empty($param_value)) { + if (!empty($param_value)) { $accept = $param_value; } break; case "header": - if(!empty($param_value)) { - if(!preg_match('![\w\d-]+: .+!',$param_value)) { - trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE); + if (!empty($param_value)) { + if (!preg_match('![\w\d-]+: .+!', $param_value)) { + trigger_error("[plugin] invalid header format '" . $param_value . "'", E_USER_NOTICE); + return; } else { $extra_headers[] = $param_value; @@ -108,99 +112,104 @@ function smarty_function_fetch($params, $template) } break; case "proxy_host": - if(!empty($param_value)) { + if (!empty($param_value)) { $proxy_host = $param_value; } break; case "proxy_port": - if(!preg_match('!\D!', $param_value)) { + if (!preg_match('!\D!', $param_value)) { $proxy_port = (int) $param_value; } else { - trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); + trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE); + return; } break; case "agent": - if(!empty($param_value)) { + if (!empty($param_value)) { $agent = $param_value; } break; case "referer": - if(!empty($param_value)) { + if (!empty($param_value)) { $referer = $param_value; } break; case "timeout": - if(!preg_match('!\D!', $param_value)) { + if (!preg_match('!\D!', $param_value)) { $timeout = (int) $param_value; } else { - trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); + trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE); + return; } break; default: - trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE); + trigger_error("[plugin] unrecognized attribute '" . $param_key . "'", E_USER_NOTICE); + return; } } - if(!empty($proxy_host) && !empty($proxy_port)) { + if (!empty($proxy_host) && !empty($proxy_port)) { $_is_proxy = true; - $fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout); + $fp = fsockopen($proxy_host, $proxy_port, $errno, $errstr, $timeout); } else { - $fp = fsockopen($server_name,$port,$errno,$errstr,$timeout); + $fp = fsockopen($server_name, $port, $errno, $errstr, $timeout); } - if(!$fp) { - trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE); + if (!$fp) { + trigger_error("[plugin] unable to fetch: $errstr ($errno)", E_USER_NOTICE); + return; } else { - if($_is_proxy) { + if ($_is_proxy) { fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n"); } else { fputs($fp, "GET $uri HTTP/1.0\r\n"); } - if(!empty($host)) { + if (!empty($host)) { fputs($fp, "Host: $host\r\n"); } - if(!empty($accept)) { + if (!empty($accept)) { fputs($fp, "Accept: $accept\r\n"); } - if(!empty($agent)) { + if (!empty($agent)) { fputs($fp, "User-Agent: $agent\r\n"); } - if(!empty($referer)) { + if (!empty($referer)) { fputs($fp, "Referer: $referer\r\n"); } - if(isset($extra_headers) && is_array($extra_headers)) { - foreach($extra_headers as $curr_header) { - fputs($fp, $curr_header."\r\n"); + if (isset($extra_headers) && is_array($extra_headers)) { + foreach ($extra_headers as $curr_header) { + fputs($fp, $curr_header . "\r\n"); } } - if(!empty($user) && !empty($pass)) { - fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n"); + if (!empty($user) && !empty($pass)) { + fputs($fp, "Authorization: BASIC " . base64_encode("$user:$pass") . "\r\n"); } fputs($fp, "\r\n"); - while(!feof($fp)) { - $content .= fgets($fp,4096); + while (!feof($fp)) { + $content .= fgets($fp, 4096); } fclose($fp); - $csplit = preg_split("!\r\n\r\n!",$content,2); + $csplit = preg_split("!\r\n\r\n!", $content, 2); $content = $csplit[1]; - if(!empty($params['assign_headers'])) { - $template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0])); + if (!empty($params['assign_headers'])) { + $template->assign($params['assign_headers'], preg_split("!\r\n!", $csplit[0])); } } } else { - trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE); + trigger_error("[plugin fetch] unable to parse URL, check syntax", E_USER_NOTICE); + return; } } else { $content = @file_get_contents($params['file']); if ($content === false) { - throw new SmartyException("{fetch} cannot read resource '" . $params['file'] ."'"); + throw new SmartyException("{fetch} cannot read resource '" . $params['file'] . "'"); } } @@ -210,5 +219,3 @@ function smarty_function_fetch($params, $template) return $content; } } - -?> \ No newline at end of file diff --git a/code/web/private_php/ams/smarty/libs/plugins/function.html_checkboxes.php b/code/web/private_php/ams/smarty/libs/plugins/function.html_checkboxes.php index 1866bc2f3..d78680368 100644 --- a/code/web/private_php/ams/smarty/libs/plugins/function.html_checkboxes.php +++ b/code/web/private_php/ams/smarty/libs/plugins/function.html_checkboxes.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ /** * Smarty {html_checkboxes} function plugin - * * File: function.html_checkboxes.php
    * Type: function
    * Name: html_checkboxes
    @@ -32,15 +31,17 @@ * - escape (optional) - escape the content (not value), defaults to true * * - * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} - * (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} + * (Smarty online manual) * @author Christopher Kvarme - * @author credits to Monte Ohrt + * @author credits to Monte Ohrt * @version 1.0 - * @param array $params parameters + * + * @param array $params parameters * @param object $template template object + * * @return string - * @uses smarty_function_escape_special_chars() + * @uses smarty_function_escape_special_chars() */ function smarty_function_html_checkboxes($params, $template) { @@ -58,8 +59,8 @@ function smarty_function_html_checkboxes($params, $template) $extra = ''; - foreach($params as $_key => $_val) { - switch($_key) { + foreach ($params as $_key => $_val) { + switch ($_key) { case 'name': case 'separator': $$_key = (string) $_val; @@ -89,7 +90,7 @@ function smarty_function_html_checkboxes($params, $template) if (method_exists($_sel, "__toString")) { $_sel = smarty_function_escape_special_chars((string) $_sel->__toString()); } else { - trigger_error("html_checkboxes: selected attribute contains an object of class '". get_class($_sel) ."' without __toString() method", E_USER_NOTICE); + trigger_error("html_checkboxes: selected attribute contains an object of class '" . get_class($_sel) . "' without __toString() method", E_USER_NOTICE); continue; } } else { @@ -101,7 +102,7 @@ function smarty_function_html_checkboxes($params, $template) if (method_exists($_val, "__toString")) { $selected = smarty_function_escape_special_chars((string) $_val->__toString()); } else { - trigger_error("html_checkboxes: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE); + trigger_error("html_checkboxes: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE); } } else { $selected = smarty_function_escape_special_chars((string) $_val); @@ -116,7 +117,8 @@ function smarty_function_html_checkboxes($params, $template) case 'assign': break; - case 'strict': break; + case 'strict': + break; case 'disabled': case 'readonly': @@ -131,11 +133,11 @@ function smarty_function_html_checkboxes($params, $template) break; } - // omit break; to fall through! + // omit break; to fall through! default: - if(!is_array($_val)) { - $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; + if (!is_array($_val)) { + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; } else { trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE); } @@ -143,76 +145,79 @@ function smarty_function_html_checkboxes($params, $template) } } - if (!isset($options) && !isset($values)) - return ''; /* raise error here? */ + if (!isset($options) && !isset($values)) { + return ''; + } /* raise error here? */ $_html_result = array(); if (isset($options)) { - foreach ($options as $_key=>$_val) { + foreach ($options as $_key => $_val) { $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); } } else { - foreach ($values as $_i=>$_key) { + foreach ($values as $_i => $_key) { $_val = isset($output[$_i]) ? $output[$_i] : ''; $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); } } - if(!empty($params['assign'])) { + if (!empty($params['assign'])) { $template->assign($params['assign'], $_html_result); } else { return implode("\n", $_html_result); } - } -function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape=true) { +function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape = true) +{ $_output = ''; - + if (is_object($value)) { if (method_exists($value, "__toString")) { $value = (string) $value->__toString(); } else { - trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE); + trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE); + return ''; } } else { $value = (string) $value; } - + if (is_object($output)) { if (method_exists($output, "__toString")) { $output = (string) $output->__toString(); } else { - trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE); + trigger_error("html_options: output is an object of class '" . get_class($output) . "' without __toString() method", E_USER_NOTICE); + return ''; } } else { $output = (string) $output; } - + if ($labels) { if ($label_ids) { $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value)); $_output .= '