コード例 #1
0
ファイル: ffile__commonlib.php プロジェクト: soar-team/kloxo
 static function moveToTrash($user, $root, $name)
 {
     $trashcont = "{$root}/.trash/.__trash_" . basename($name);
     $fullpath = "{$root}/{$name}";
     lxfile_rm_rec("{$root}/.trash/" . basename($name));
     lxfile_rm_rec($trashcont);
     $res = lxuser_mkdir($user, "{$root}/.trash/");
     lfile_put_contents($trashcont, $name . "\n");
     $res = new_process_mv_rec($user, $fullpath, "{$root}/.trash");
     //unlink($f);
 }
コード例 #2
0
 function writeAuthorizedKey($key)
 {
     if_demo_throw_exception('sshkey');
     $username = $this->main->username;
     $p = os_get_home_dir($username);
     if (!$p) {
         return;
     }
     lxuser_mkdir($username, "{$p}/.ssh");
     $f = "{$p}/.ssh/authorized_keys";
     lxuser_put_contents($username, $f, $key);
     lxuser_chmod($username, "{$p}/.ssh", "0700");
     lxuser_chmod($username, $f, "0700");
 }
コード例 #3
0
 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');
     }
 }
コード例 #4
0
 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));
 }
コード例 #5
0
ファイル: weblib.php プロジェクト: zseand/kloxo
 function doStatsPageProtection()
 {
     $filename = $this->getStatsProtectFileName();
     $dir = dirname($filename);
     $owner = "{$this->username}:apache";
     $password = crypt($this->stats_password);
     $content = "{$this->stats_username}:{$password}\n";
     lxuser_mkdir($owner, $dir);
     lxfile_generic_chmod($dir, '750');
     lxuser_put_contents($owner, $filename, $content);
     lxfile_generic_chmod($filename, '750');
 }
コード例 #6
0
ファイル: commonfslib.php プロジェクト: zseand/kloxo
/**
 * Writes a string to a file
 * 
 * @param string $username  file owner
 * @param string $file path to the file
 * @param mixed $data the data to write
 * @param int $flag
 */
function lxuser_put_contents($username, $file, $data, $flag = 0)
{
    $file = expand_real_root($file);
    dprint("Debug: filename is: " . $file . "\n");
    if (is_soft_or_hardlink($file)) {
        log_log("link_error", "{$file} is hard or symlink. Not writing\n");
        return false;
    }
    if (!lxuser_mkdir($username, dirname($file))) {
        return false;
    }
    if ($flag == FILE_APPEND) {
        $mode = 'a';
    } else {
        $mode = 'w';
    }
    $f = fopen($file, $mode);
    if (!$f) {
        return false;
    } else {
        if (flock($f, LOCK_EX)) {
            $bytes = fwrite($f, $data);
            lxfile_generic_chown($file, $username);
            flock($f, LOCK_UN);
            fclose($f);
            return $bytes;
        } else {
            return false;
        }
    }
}
コード例 #7
0
ファイル: client__synclib.php プロジェクト: soar-team/kloxo
 function do_restore($docd)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $name = $this->main->getPathFromName('nname');
     $fullpath = "{$sgbl->__path_customer_root}/{$name}/";
     lxuser_mkdir($this->main->username, $fullpath);
     lxfile_generic_chown($docd, $this->main->username);
     lxuser_unzip_with_throw($this->main->username, $fullpath, $docd);
     lxfile_generic_chown($fullpath, "{$this->main->username}:apache");
     lxfile_generic_chmod($fullpath, "0750");
 }