fixed few bugs

This commit is contained in:
shubham_meena 2014-07-07 13:56:58 +05:30
parent 06b6e788f4
commit e00922c699
5 changed files with 38 additions and 63 deletions

View file

@ -173,17 +173,13 @@ class Plugincache {
* @return boolean * @return boolean
*/ */
public static function rrmdir( $dir ) { public static function rrmdir( $dir ) {
if ( is_dir( $dir ) ) { $result=array_diff(scandir($dir),array('.','..'));
$objects = scandir( $dir ); foreach($result as $item)
foreach ( $objects as $object ) { {
if ( $object != "." && $object != ".." ) { if(!@unlink($dir.'/'.$item))
if ( filetype( $dir . "/" . $object ) == "dir" ) rmdir( $dir . "/" . $object ); Plugincache::rrmdir($dir.'/'.$item);
else unlink( $dir . "/" . $object ); }
} return rmdir($dir);
}
reset( $objects );
return rmdir( $dir );
}
} }
/** /**

View file

@ -289,12 +289,13 @@ class Users{
public static function createUser($values, $user_id){ public static function createUser($values, $user_id){
try { try {
//make connection with and put into shard db //make connection with and put into shard db
$values['user_id']= $user_id;
$dbs = new DBLayer("shard"); $dbs = new DBLayer("shard");
$dbs->insert("user", $values); $dbs->insert("user", $values);
$dbr = new DBLayer("ring"); $dbr = new DBLayer("ring");
$values['user_type'] = 'ut_pioneer'; $valuesRing['user_id'] =$user_id;
$dbr->insert("ring_users", $values); $valuesRing['user_name'] = $values['Login'];
$valuesRing['user_type'] = 'ut_pioneer';
$dbr->insert("ring_users", $valuesRing);
ticket_user::createTicketUser( $user_id, 1); ticket_user::createTicketUser( $user_id, 1);
return "ok"; return "ok";
} }
@ -303,7 +304,7 @@ class Users{
try { try {
$dbl = new DBLayer("lib"); $dbl = new DBLayer("lib");
$dbl->insert("ams_querycache", array("type" => "createUser", $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 ); ticket_user::createTicketUser( $user_id , 1 );
return "shardoffline"; return "shardoffline";
}catch (PDOException $e) { }catch (PDOException $e) {
@ -472,6 +473,3 @@ class Users{
} }
} }
} }

View file

@ -23,7 +23,7 @@ function delete_plugin() {
if ( is_dir( "$name[FileName]" ) ) if ( is_dir( "$name[FileName]" ) )
{ {
// removing plugin directory from the code base // removing plugin directory from the code base
if ( rrmdir( "$name[FileName]" ) ) if ( Plugincache::rrmdir( "$name[FileName]" ) )
{ {
$db -> delete( 'plugins', array( 'id' => $id ), "Id=:id" ); $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 );
}
}

View file

@ -184,37 +184,38 @@
DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`plugins` ; DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`plugins` ;
CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`plugins` ( CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`plugins` (
`Id` INT(10) NOT NULL AUTO_INCREMENT, `Id` INT(10) NOT NULL AUTO_INCREMENT,
`FileName VARCHAR(255) NOT NULL, `FileName` VARCHAR(255) NOT NULL,
`Name` VARCHAR(11) NOT NULL, `Name` VARCHAR(11) NOT NULL,
`Type` VARCHAR(12) NOT NULL, `Type` VARCHAR(12) NOT NULL,
`Owner` VARCHAR(25) NOT NULL, `Owner` VARCHAR(25) NOT NULL,
`Permission` VARCHAR(5) NOT NULL, `Permission` VARCHAR(5) NOT NULL,
`Status` INT(11) NOT NULL DEFAULT 0, `Status` INT(11) NOT NULL DEFAULT 0,
`Weight` 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`) ) PRIMARY KEY (`Id`) )
ENGINE = InnoDB; ENGINE = InnoDB;
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `" . $cfg['db']['lib']['name'] ."`.`updates` -- Table `" . $cfg['db']['lib']['name'] ."`.`updates`
-- ----------------------------------------------------- -- -----------------------------------------------------
DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`updates` ; DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`updates` ;
CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`updates` ( CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`updates` (
`s.no` int(10) NOT NULL AUTO_INCREMENT, `s.no` int(10) NOT NULL AUTO_INCREMENT,
`PluginId` int(10) DEFAULT NULL, `PluginId` int(10) DEFAULT NULL,
`UpdatePath` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `UpdatePath` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`UpdateInfo` text COLLATE utf8_unicode_ci, `UpdateInfo` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`s.no`), PRIMARY KEY (`s.no`),
KEY `PluginId` (`PluginId`)) KEY `PluginId` (`PluginId`))
ENGINE=InnoDB; ENGINE=InnoDB;
-- ----------------------------------------- -- -----------------------------------------
-- Constraints for table `updates` -- Constraints for table `updates`
-- ----------------------------------------- -- -----------------------------------------
ALTER TABLE `" . $cfg['db']['lib']['name'] ."`.`updates` ALTER TABLE `" . $cfg['db']['lib']['name'] ."`.`updates`
ADD CONSTRAINT `updates_ibfk_1` FOREIGN KEY (`PluginId`) REFERENCES `plugins` (`Id`); ADD CONSTRAINT `updates_ibfk_1` FOREIGN KEY (`PluginId`) REFERENCES `plugins` (`Id`);
-- ----------------------------------------------------- -- -----------------------------------------------------
@ -1772,14 +1773,14 @@
//Now create an admin account! //Now create an admin account!
$hashpass = crypt("admin", Users::generateSALT()); $hashpass = crypt("admin", Users::generateSALT());
$params = array( $params = array(
'name' => "admin", 'Login' => "admin",
'pass' => $hashpass, 'Password' => $hashpass,
'mail' => "admin@admin.com", 'Email' => "admin@admin.com",
); );
try{ 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); $result = Webusers::createUser($params, $user_id);
Users::createPermissions(array($params['name'])); Users::createPermissions(array($params['Login']));
$dbl = new DBLayer("lib"); $dbl = new DBLayer("lib");
$dbl->execute("UPDATE ticket_user SET Permission = 3 WHERE TUserId = :user_id",array('user_id' => $user_id)); $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!"; print "The admin account is created, you can login with id: admin, pass: admin!";

View file

@ -5,6 +5,7 @@
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=settings"><i class="icon-cog"></i><span class="hidden-tablet"> Settings</span></a></li> <li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=settings"><i class="icon-cog"></i><span class="hidden-tablet"> Settings</span></a></li>
<li class="nav-header hidden-tablet">Actions</li> <li class="nav-header hidden-tablet">Actions</li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=createticket"><i class="icon-pencil"></i><span class="hidden-tablet">Create New Ticket</span></a></li> <li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=createticket"><i class="icon-pencil"></i><span class="hidden-tablet">Create New Ticket</span></a></li>
{if isset($hook_info)} {foreach from=$hook_info item=element}<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=layout_plugin&&name={$element.menu_display}"><i class="icon-th-list"></i><span class="hidden-tablet"> {$element.menu_display}</span></a></li>{/foreach}{/if}
<li style="margin-left: -2px;"><a href="?page=logout"><i class="icon-off"></i><span class="hidden-tablet"> Logout </span></a></li> <li style="margin-left: -2px;"><a href="?page=logout"><i class="icon-off"></i><span class="hidden-tablet"> Logout </span></a></li>
{/block} {/block}