Implementing fixfile for action class
This commit is contained in:
parent
ca4c8d63dd
commit
60ec88174e
|
@ -56,6 +56,13 @@ class m_action {
|
||||||
return $this->set('fix_dir',$user, array('dir'=>$dir));
|
return $this->set('fix_dir',$user, array('dir'=>$dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* function to set the cration of a file
|
||||||
|
*/
|
||||||
|
function fix_file($file,$user="root") {
|
||||||
|
return $this->set('fix_file',$user, array('file'=>$file));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function to delete file / folder
|
* function to delete file / folder
|
||||||
*/
|
*/
|
||||||
|
@ -95,6 +102,7 @@ class m_action {
|
||||||
*/
|
*/
|
||||||
function set($type,$user,$parameters) {
|
function set($type,$user,$parameters) {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
|
$err->log("action","set",$type);
|
||||||
|
|
||||||
$serialized=serialize($parameters);
|
$serialized=serialize($parameters);
|
||||||
switch($type){
|
switch($type){
|
||||||
|
@ -107,6 +115,9 @@ class m_action {
|
||||||
case 'move':
|
case 'move':
|
||||||
$query="insert into actions values ('','MOVE','$serialized',now(),'','','$user','');";
|
$query="insert into actions values ('','MOVE','$serialized',now(),'','','$user','');";
|
||||||
break;
|
break;
|
||||||
|
case 'fix_file':
|
||||||
|
$query="insert into actions values ('','FIXFILE','$serialized',now(),'','','$user','');";
|
||||||
|
break;
|
||||||
case 'fix_dir':
|
case 'fix_dir':
|
||||||
$query="insert into actions values ('','FIXDIR','$serialized',now(),'','','$user','');";
|
$query="insert into actions values ('','FIXDIR','$serialized',now(),'','','$user','');";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -418,7 +418,7 @@ class m_admin {
|
||||||
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
||||||
*/
|
*/
|
||||||
function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0, $notes = "", $force=0, $create_dom=false, $db_server_id) {
|
function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0, $notes = "", $force=0, $create_dom=false, $db_server_id) {
|
||||||
global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$hooks;
|
global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$hooks,$action;
|
||||||
$err->log("admin","add_mem",$login."/".$mail);
|
$err->log("admin","add_mem",$login."/".$mail);
|
||||||
if (!$this->enabled) {
|
if (!$this->enabled) {
|
||||||
$err->raise("admin",_("-- Only administrators can access this page! --"));
|
$err->raise("admin",_("-- Only administrators can access this page! --"));
|
||||||
|
@ -475,7 +475,10 @@ class m_admin {
|
||||||
$db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created,notes,db_server_id) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type', NOW(), '$notes', '$db_server_id');");
|
$db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created,notes,db_server_id) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type', NOW(), '$notes', '$db_server_id');");
|
||||||
$db->query("INSERT INTO local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');");
|
$db->query("INSERT INTO local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');");
|
||||||
$this->renew_update($uid, $duration);
|
$this->renew_update($uid, $duration);
|
||||||
exec("sudo /usr/lib/alternc/mem_add ".$login." ".$uid);
|
#exec("sudo /usr/lib/alternc/mem_add ".$login." ".$uid);
|
||||||
|
$action->create_dir(getuserpath("$login"));
|
||||||
|
$action->fix_dir(getuserpath("$login"));
|
||||||
|
|
||||||
// Triggering hooks
|
// Triggering hooks
|
||||||
$mem->su($uid);
|
$mem->su($uid);
|
||||||
// TODO: old hook method FIXME: when unused remove this
|
// TODO: old hook method FIXME: when unused remove this
|
||||||
|
@ -663,7 +666,7 @@ EOF;
|
||||||
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
||||||
*/
|
*/
|
||||||
function del_mem($uid) {
|
function del_mem($uid) {
|
||||||
global $err,$quota,$classes,$cuid,$mem,$dom,$hooks;
|
global $err,$quota,$classes,$cuid,$mem,$dom,$hooks,$action;
|
||||||
$err->log("admin","del_mem",$uid);
|
$err->log("admin","del_mem",$uid);
|
||||||
|
|
||||||
if (!$this->enabled) {
|
if (!$this->enabled) {
|
||||||
|
@ -687,12 +690,24 @@ EOF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* New way of deleting or backup delted user html folders using action class
|
||||||
|
*/
|
||||||
|
$archive=variable_get('archive_del_data');
|
||||||
|
$path=getuserpath($tt['login']);
|
||||||
|
if($archive == 1 ){
|
||||||
|
echo("archive");
|
||||||
|
$action->archive($path,"html");
|
||||||
|
}else{
|
||||||
|
echo("del");
|
||||||
|
$action->del($path);
|
||||||
|
}
|
||||||
$hooks->invoke("alternc_del_member");
|
$hooks->invoke("alternc_del_member");
|
||||||
$hooks->invoke("hook_admin_del_member");
|
$hooks->invoke("hook_admin_del_member");
|
||||||
|
|
||||||
if (($db->query("DELETE FROM membres WHERE uid='$uid';")) &&
|
if (($db->query("DELETE FROM membres WHERE uid='$uid';")) &&
|
||||||
($db->query("DELETE FROM local WHERE uid='$uid';"))) {
|
($db->query("DELETE FROM local WHERE uid='$uid';"))) {
|
||||||
exec("sudo /usr/lib/alternc/mem_del ".$tt["login"]);
|
|
||||||
$mem->unsu();
|
$mem->unsu();
|
||||||
// If this user was (one day) an administrator one, he may have a list of his own accounts. Let's associate those accounts to nobody as a creator.
|
// If this user was (one day) an administrator one, he may have a list of his own accounts. Let's associate those accounts to nobody as a creator.
|
||||||
$db->query("UPDATE membres SET creator=2000 WHERE creator='$uid';");
|
$db->query("UPDATE membres SET creator=2000 WHERE creator='$uid';");
|
||||||
|
|
|
@ -552,7 +552,7 @@ class m_bro {
|
||||||
@touch($absolute."/".$_FILES['userfile']['name']);
|
@touch($absolute."/".$_FILES['userfile']['name']);
|
||||||
}
|
}
|
||||||
if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $absolute."/".$_FILES['userfile']['name'])) {
|
if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $absolute."/".$_FILES['userfile']['name'])) {
|
||||||
$action->fix_dir($absolute."/".$_FILES['userfile']['name']);
|
$action->fix_file($absolute."/".$_FILES['userfile']['name']);
|
||||||
return $absolute."/".$_FILES['userfile']['name'];
|
return $absolute."/".$_FILES['userfile']['name'];
|
||||||
} else {
|
} else {
|
||||||
$err->raise("bro",_("Cannot create the requested file. Please check the permissions"));
|
$err->raise("bro",_("Cannot create the requested file. Please check the permissions"));
|
||||||
|
|
|
@ -731,7 +731,7 @@ CREATE TABLE IF NOT EXISTS `vm_history` (
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `actions` (
|
CREATE TABLE IF NOT EXISTS `actions` (
|
||||||
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
type enum ('CREATE_FILE','CREATE_DIR','DELETE','MOVE','FIXDIR'),
|
type enum ('CREATE_FILE','CREATE_DIR','DELETE','MOVE','FIXDIR','FIXFILE'),
|
||||||
parameters longtext default NULL,
|
parameters longtext default NULL,
|
||||||
creation timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
creation timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
begin timestamp,
|
begin timestamp,
|
||||||
|
|
Loading…
Reference in New Issue