function createDiruserfile()
 {
     $dir = '__path_httpd_root/' . $this->main->getParentName() . '/__dirprotect';
     $dirfile = $dir . '/' . $this->main->getFileName();
     $chownug = $this->main->__var_username . ':apache';
     if (!lxfile_exists($dir)) {
         lxuser_mkdir($chownug, $dir);
         lxfile_generic_chmod($dir, '0750');
     }
     lxfile_rm($dirfile);
     if ($this->main->status == 'on') {
         $fstr = '';
         foreach ($this->main->diruser_a as $v) {
             $fstr .= $v->nname . ':' . crypt($v->param) . "\n";
         }
         lxuser_put_contents($chownug, $dirfile, $fstr);
         lxfile_generic_chmod($dirfile, '0750');
     }
 }
 function syncSpamUserPref()
 {
     global $gbl, $sgbl, $ghtml;
     // The parent can be either a domain or a user. CHeck for the @ sign.
     if (csa($this->main->nname, "@")) {
         list($user, $domain) = explode("@", $this->main->nname);
     } else {
         $domain = $this->main->nname;
         $user = null;
     }
     $sysuser = mmail__qmail::getUserGroup($domain);
     // --- issue #578/#721 - missing in version 6.1.6
     //	$mailpath = "/home/lxadmin/mail";
     $mailpath = mmail__qmail::getDir($domain);
     if ($user) {
         //	$prefpath = "$mailpath/domains/{$domain}/{$user}/.bogopref.cf";
         $prefpath = "{$mailpath}/{$user}/.bogopref.cf";
     } else {
         return;
     }
     $prefdir = dirname($prefpath);
     if (!lxfile_exists(dirname($prefpath))) {
         lxuser_mkdir($sysuser, dirname($prefpath));
     }
     $wname = fix_nname_to_be_variable($this->main->nname);
     $fdata = null;
     $cutoff = $this->main->spam_hit / 10 + 0.2;
     $fdata .= "spam_cutoff  {$cutoff}\n";
     $fdata .= "spam_subject_tag={$this->main->subject_tag}\n";
     $fdata .= "wordlist R,user,{$wname}.wordlist.db,1\n";
     $fdata .= "wordlist R,system,wordlist.db,2\n";
     $fdata .= "wordlist R,system,kloxo.wordlist.db,3\n";
     lxuser_put_contents($sysuser, $prefpath, $fdata);
     if (!lxfile_real("/var/bogofilter/{$wname}.wordlist.db")) {
         new_process_cmd($sysuser, null, "bogofilter -d /var/bogofilter/ --wordlist=R,user,{$wname}.wordlist.db,1  -n < /etc/my.cnf");
     }
     lxfile_touch("/var/bogofilter/wordlist.db");
     // Using generic because spamassasin is used on windows too. Or at least can be used.
     //lxfile_generic_chown("/var/bogofilter", mmail__qmail::getUserGroup($domain));
 }
 static function readAuthorizedKey($username)
 {
     $p = os_get_home_dir($username);
     if ($p === '/tmp' && $username) {
         if (!lxfile_exists("/home/{$username}")) {
             lxfile_mkdir("/home/{$username}");
             lxshell_return("usermod", "-d", "/home/{$username}", $username);
             lxfile_unix_chown("/home/{$username}", "{$username}:{$username}");
             $p = "/home/{$username}";
         }
     }
     if (!$p) {
         return;
     }
     $f = "{$p}/.ssh/authorized_keys";
     if (lxfile_exists("{$f}2")) {
         $s = lfile_get_contents("{$f}2");
         $s = "\n{$s}\n";
         lxuser_put_contents($username, $f, $s, FILE_APPEND);
         lunlink("{$f}2");
     }
     return lfile_get_contents($f);
 }
Exemple #4
0
 function replaceVariables($filename)
 {
     $cont = lfile_get_contents($filename);
     $cont = str_replace("<%domainname%>", $this->nname, $cont);
     $cont = str_replace("<%contactemail%>", $this->__var_parent_contactemail, $cont);
     $cont = str_replace("<%clientname%>", $this->__var_clientname, $cont);
     lxuser_put_contents($this->username, $filename, $cont);
 }
Exemple #5
0
 function dbactionUpdate($subaction)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if_demo_throw_exception('ffile');
     $this->aux = new Ffile__common(null, null, $this->nname);
     $this->aux->main = $this->main;
     if ($this->main->isOn('readonly')) {
         throw new lxexception('file_manager_is_readonly', '');
     }
     $chownug = "{$this->main->__username_o}:{$this->main->__username_o}";
     switch ($subaction) {
         case "fancyedit":
         case "edit":
             lxuser_put_contents($chownug, $this->main->getFullPath(), $this->main->content);
             lxuser_return($chownug, "dos2unix", $this->main->getFullPath());
             lxuser_chmod($chownug, $this->main->getFullPath(), "0644");
             break;
         case "upload_s":
             $filename = $this->aux->uploadDirect();
             lxuser_chmod($chownug, $filename, "0644");
             lxfile_generic_chown($filename, $chownug);
             break;
         case "rename":
             $this->aux->reName();
             break;
         case "paste":
             $this->aux->filePaste();
             break;
         case "perm":
             $arg = null;
             $perm = $this->main->newperm;
             $perm = 0 . $perm;
             if ($this->main->isOn('recursive_f')) {
                 new_process_chmod_rec($this->main->__username_o, $this->main->fullpath, $perm);
             } else {
                 lxfile_unix_chmod($this->main->fullpath, "{$perm}");
             }
             break;
         case "newdir":
             $path = $this->aux->newDir();
             lxfile_unix_chown($path, $chownug);
             break;
         case "content":
             if ($this->main->is_image()) {
                 $this->aux->resizeImage();
             } else {
                 throw new lxexception('cannot_save_content', '');
             }
             break;
         case "thumbnail":
             $this->aux->createThumbnail();
             break;
         case "convert_image":
             $this->aux->convertImage();
             break;
         case "zip_file":
             $zipfile = $this->aux->zipFile();
             break;
         case "filedelete":
             $this->aux->moveAllToTrash();
             break;
         case "filerealdelete":
             $this->aux->fileRealDelete();
             break;
         case "restore_trash":
             $this->aux->restoreTrash();
             break;
         case "clear_trash":
             $this->aux->clearTrash();
             break;
         case "download_from_http":
             $fullpath = $this->aux->downloadFromHttp();
             lxfile_unix_chown($fullpath, $chownug);
             break;
         case "download_from_ftp":
             $fullpath = $this->aux->downloadFromFtp();
             lxfile_unix_chown($fullpath, $chownug);
             break;
         case "zipextract":
             $dir = $this->aux->zipExtract();
             break;
     }
 }
Exemple #6
0
function file_put_between_comments($username, $stlist, $endlist, $startstring, $endstring, $file, $string)
{
    global $gbl, $sgbl, $login, $ghtml;
    if (empty($string)) {
        dprint("ERROR: Function file_put_between_comments\nERROR: File " . $file . " has empty \$string\n");
        return;
    }
    $prgm = $sgbl->__var_program_name;
    $startcomment = "###Please Don't edit these comments or the content in between. {$prgm} uses this to recognize the lines it writes to the the file. If the above line is corrupted, it may fail to recognize them, leading to multiple lines.";
    $outlist = null;
    $afterlist = null;
    $outstring = null;
    $afterend = false;
    if (lxfile_exists($file)) {
        $list = lfile_trim($file);
        $inside = false;
        foreach ($list as $l) {
            if (csainlist($l, $stlist)) {
                $inside = true;
            }
            if (csainlist($l, $endlist)) {
                $inside = false;
                $afterend = true;
                continue;
            }
            if ($inside) {
                continue;
            }
            if ($afterend) {
                $afterlist[] = $l;
            } else {
                $outlist[] = $l;
            }
        }
    }
    if ($outlist) {
        $outstring = implode("\n", $outlist);
    }
    $afterstring = implode("\n", $afterlist);
    $outstring = "{$outstring}\n{$startstring}\n{$startcomment}\n{$string}\n{$endstring}\n{$afterstring}\n";
    lxuser_put_contents($username, $file, $outstring);
}