From 1546cfc57a8f96bc4d9defd94cdca22b36540cbc Mon Sep 17 00:00:00 2001 From: shubham_meena Date: Mon, 7 Jul 2014 13:56:58 +0530 Subject: [PATCH] fixed few bugs --- .../ams_lib/autoload/plugincache.php | 20 ++++----- .../ryzom_ams/ams_lib/autoload/users.php | 12 +++-- .../ryzom_ams/www/html/func/delete_plugin.php | 23 +--------- .../ryzom_ams/www/html/installer/libsetup.php | 45 ++++++++++--------- .../www/html/templates/layout_user.tpl | 1 + 5 files changed, 38 insertions(+), 63 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/plugincache.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/plugincache.php index 7c43e1877..ae8f1129c 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/plugincache.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/plugincache.php @@ -173,17 +173,13 @@ class Plugincache { * @return boolean */ public static function rrmdir( $dir ) { - if ( is_dir( $dir ) ) { - $objects = scandir( $dir ); - foreach ( $objects as $object ) { - if ( $object != "." && $object != ".." ) { - if ( filetype( $dir . "/" . $object ) == "dir" ) rmdir( $dir . "/" . $object ); - else unlink( $dir . "/" . $object ); - } - } - reset( $objects ); - return rmdir( $dir ); - } + $result=array_diff(scandir($dir),array('.','..')); + foreach($result as $item) + { + if(!@unlink($dir.'/'.$item)) + Plugincache::rrmdir($dir.'/'.$item); + } + return rmdir($dir); } /** @@ -267,4 +263,4 @@ class Plugincache { } return $content; } - } \ No newline at end of file + } diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php index e9463b0b0..b398270e4 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php @@ -289,12 +289,13 @@ class Users{ public static function createUser($values, $user_id){ try { //make connection with and put into shard db - $values['user_id']= $user_id; $dbs = new DBLayer("shard"); $dbs->insert("user", $values); $dbr = new DBLayer("ring"); - $values['user_type'] = 'ut_pioneer'; - $dbr->insert("ring_users", $values); + $valuesRing['user_id'] =$user_id; + $valuesRing['user_name'] = $values['Login']; + $valuesRing['user_type'] = 'ut_pioneer'; + $dbr->insert("ring_users", $valuesRing); ticket_user::createTicketUser( $user_id, 1); return "ok"; } @@ -303,7 +304,7 @@ class Users{ try { $dbl = new DBLayer("lib"); $dbl->insert("ams_querycache", array("type" => "createUser", - "query" => json_encode(array($values["name"],$values["pass"],$values["mail"])), "db" => "shard")); + "query" => json_encode(array($values["Login"],$values["Password"],$values["Email"])), "db" => "shard")); ticket_user::createTicketUser( $user_id , 1 ); return "shardoffline"; }catch (PDOException $e) { @@ -472,6 +473,3 @@ class Users{ } } } - - - diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/delete_plugin.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/delete_plugin.php index 53af36157..f3dc0311a 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/delete_plugin.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/delete_plugin.php @@ -23,7 +23,7 @@ function delete_plugin() { if ( is_dir( "$name[FileName]" ) ) { // removing plugin directory from the code base - if ( rrmdir( "$name[FileName]" ) ) + if ( Plugincache::rrmdir( "$name[FileName]" ) ) { $db -> delete( 'plugins', array( 'id' => $id ), "Id=:id" ); @@ -45,24 +45,3 @@ function delete_plugin() { } } } - -/** - * function to remove a non empty directory - * - * @param $dir directory address - * @return boolean - */ -function rrmdir( $dir ) { - if ( is_dir( $dir ) ) { - $objects = scandir( $dir ); - foreach ( $objects as $object ) { - if ( $object != "." && $object != ".." ) { - if ( filetype( $dir . "/" . $object ) == "dir" ) rmdir( $dir . "/" . $object ); - else unlink( $dir . "/" . $object ); - } - } - reset( $objects ); - return rmdir( $dir ); - } - } - diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/installer/libsetup.php b/code/ryzom/tools/server/ryzom_ams/www/html/installer/libsetup.php index 492f67549..d020f1644 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/installer/libsetup.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/installer/libsetup.php @@ -184,37 +184,38 @@ DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`plugins` ; CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`plugins` ( - `Id` INT(10) NOT NULL AUTO_INCREMENT, - `FileName VARCHAR(255) NOT NULL, + `Id` INT(10) NOT NULL AUTO_INCREMENT, + `FileName` VARCHAR(255) NOT NULL, `Name` VARCHAR(11) NOT NULL, `Type` VARCHAR(12) NOT NULL, `Owner` VARCHAR(25) NOT NULL, `Permission` VARCHAR(5) NOT NULL, `Status` INT(11) NOT NULL DEFAULT 0, `Weight` INT(11) NOT NULL DEFAULT 0, - `Info` TEXT NULL DEFAULT NULL, + `Info` TEXT NULL DEFAULT NULL, PRIMARY KEY (`Id`) ) ENGINE = InnoDB; + -- ----------------------------------------------------- -- Table `" . $cfg['db']['lib']['name'] ."`.`updates` -- ----------------------------------------------------- DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`updates` ; CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`updates` ( - `s.no` int(10) NOT NULL AUTO_INCREMENT, - `PluginId` int(10) DEFAULT NULL, - `UpdatePath` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `UpdateInfo` text COLLATE utf8_unicode_ci, - PRIMARY KEY (`s.no`), - KEY `PluginId` (`PluginId`)) - ENGINE=InnoDB; + `s.no` int(10) NOT NULL AUTO_INCREMENT, + `PluginId` int(10) DEFAULT NULL, + `UpdatePath` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `UpdateInfo` text COLLATE utf8_unicode_ci, + PRIMARY KEY (`s.no`), + KEY `PluginId` (`PluginId`)) + ENGINE=InnoDB; - -- ----------------------------------------- - -- Constraints for table `updates` - -- ----------------------------------------- - ALTER TABLE `" . $cfg['db']['lib']['name'] ."`.`updates` - ADD CONSTRAINT `updates_ibfk_1` FOREIGN KEY (`PluginId`) REFERENCES `plugins` (`Id`); + -- ----------------------------------------- + -- Constraints for table `updates` + -- ----------------------------------------- + ALTER TABLE `" . $cfg['db']['lib']['name'] ."`.`updates` + ADD CONSTRAINT `updates_ibfk_1` FOREIGN KEY (`PluginId`) REFERENCES `plugins` (`Id`); -- ----------------------------------------------------- @@ -1772,14 +1773,14 @@ //Now create an admin account! $hashpass = crypt("admin", Users::generateSALT()); $params = array( - 'name' => "admin", - 'pass' => $hashpass, - 'mail' => "admin@admin.com", + 'Login' => "admin", + 'Password' => $hashpass, + 'Email' => "admin@admin.com", ); try{ - $user_id = WebUsers::createWebuser($params['name'], $params['pass'],$params['mail']); + $user_id = WebUsers::createWebuser($params['Login'], $params['Password'],$params['Email']); $result = Webusers::createUser($params, $user_id); - Users::createPermissions(array($params['name'])); + Users::createPermissions(array($params['Login'])); $dbl = new DBLayer("lib"); $dbl->execute("UPDATE ticket_user SET Permission = 3 WHERE TUserId = :user_id",array('user_id' => $user_id)); print "The admin account is created, you can login with id: admin, pass: admin!"; @@ -1802,5 +1803,5 @@ print "There was an error while installing"; print_r($e); } - } - + } + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl index 301af12b6..4b452962a 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl @@ -5,6 +5,7 @@
  • Settings
  • Create New Ticket
  • + {if isset($hook_info)} {foreach from=$hook_info item=element}
  • {$element.menu_display}
  • {/foreach}{/if}
  • Logout
  • {/block}