function get_middle($source, $beginning, $ending, $init_pos) {
$beginning_pos = strpos($source, $beginning, $init_pos);
$middle_pos = $beginning_pos + strlen($beginning);
$ending_pos = strpos($source, $ending, $beginning_pos + 1);
$middle = substr($source, $middle_pos, $ending_pos - $middle_pos);
return $middle;
}
if ($argc < 5)
{
echo "Uso: php AddModyCML.php Add/Modify Login Password Path1 Path2 Path3 Path4\n" ;
exit;
}
$command=$argv[1];
$name=$argv[2];
$pass1=$argv[3];
$rname1=substr($argv[4],0,stripos($argv[4],"["));
if (isset($argv[5])) $rname2=substr($argv[5],0,stripos($argv[5],"["));
if (isset($argv[6])) $rname3=substr($argv[6],0,stripos($argv[6],"["));
if (isset($argv[7])) $rname4=substr($argv[7],0,stripos($argv[7],"["));
$root1=get_middle($argv[4],"[","]",0);
if (isset($argv[5])) $root2=get_middle($argv[5],"[","]",0);
if (isset($argv[6])) $root3=get_middle($argv[6],"[","]",0);
if (isset($argv[7])) $root4=get_middle($argv[7],"[","]",0);
echo "$command - $name - $pass1\n";
if (isset($root1)) echo "$rname1 - $root1\n";
if (isset($root2)) echo "$rname2 - $root2\n";
if (isset($root3)) echo "$rname3 - $root3\n";
if (isset($root4)) echo "$rname4 - $root4\n";
for( $i=1; $i<=4; $i++)
{
$caminho="root$i";
$diretorio=$$caminho;
if (!empty($diretorio))
if (!mkdir($diretorio, 0777)) echo "Erro Criando $diretorio";
}
include_once("Userdb.php");
include_once("Global.php");
include_once("lang/$Language.php");
include_once("data/Cwfmini.php");
$action="Checkout";
$language="BrazilianPortuguese";
$detail = 4;
$tformat = 1;
$view = 2;
if( $action == "Checkout" )
{
if( $command == "Del" )
{
$size=strlen($name);
$current= "s:8:\"username\";s:$size:\"$name\"";
$run="cat /usr/local/www/htdocs/cwfm/php/data/user.dat.php | grep $current";
echo $run;
exec ($run);
die();
}
if( $command == "Add" && getUser(md5($name.session_id()), $r) != "" )
{
echo "";
exit;
}
for( $i=1; $i<=4; $i++)
{
if( ${"root".$i} != "" && Last(${"root".$i}) != "/" )
${"root".$i} .= "/";
if( ${"root".$i} == $cwfmPath."/" )
{
echo "";
exit;
}
}
$r = new UserRecordV9;
$r->username = $name;
if( $command == "Add" || $oldPwd != $pass1 )
$r->password = md5($pass1);
else
$r->password = $pass1;
$r->root1 = $root1;
$r->root2 = $root2;
$r->root3 = $root3;
$r->root4 = $root4;
$r->iPath = $root1;
$r->language = $language;
$r->viewM = $view;
$r->detailL = $detail;
$r->timeFormat = $tformat;
$r->rname1 = $rname1;
$r->rname2 = $rname2;
$r->rname3 = $rname3;
$r->rname4 = $rname4;
/*
$r->mkdir = $cbMdH == "true"? 1:0;
$r->upload = $cbUpH == "true"? 1:0;
$r->dwload = $cbDwH == "true"? 1:0;
$r->rmdir = $cbRdH == "true"? 1:0;
$r->delete = $cbDlH == "true"? 1:0;
$r->view = $cbViH == "true"? 1:0;
$r->descV = $cbDvH == "true"? 1:0;
$r->descM = $cbDmH == "true"? 1:0;
$r->cut = $cbCutH == "true"? 1:0;
$r->copy = $cbCopyH == "true"? 1:0;
$r->paste = $cbPasteH == "true"? 1:0;
$r->rendir = $cbRendH == "true"? 1:0;
$r->rename = $cbRenameH == "true"? 1:0;
$r->options = $cbOptH == "true"? 1:0;
$r->chpwd = $cbChpwdH == "true"? 1:0;
$r->editFile = $cbEditFileH == "true"? 1:0;
$r->newFile = $cbNewFileH == "true"? 1:0;
$r->exec = $cbExecH == "true"? 1:0;
$r->icons = $cbIconsH == "true"? 1:0;
$r->mail = ""; */
$r->mkdir = 1;
$r->upload = 1;
$r->dwload = 1;
$r->rmdir = 1;
$r->delete = 1;
$r->view = 1;
$r->descV = 1;
$r->descM = 1;
$r->cut = 1;
$r->copy = 1;
$r->paste = 1;
$r->rendir = 1;
$r->rename = 1;
$r->options = 1;
$r->chpwd = 1;
$r->editFile = 1;
$r->newFile = 1;
$r->exec = 0;
$r->icons = 1;
$r->mail = "";
if( $command == "Modify" )
{
if( modifyUser($r) < 0 )
{
echo "";
exit;
}
}
else
if( $command == "Add" )
{
if( addUser($r) < 0 )
{
echo "";
exit;
}
}
exit;
}
?>