/** * @return void * @param * @param * @desc Special getfromlist for ffile. The concept is that the the whole directory tree is available virtually under an ffile object, thus enabling us to get any object at any level. This is different from other objects where there is only one level of children. */ function getFfileFromVirtualList($name) { $name = coreFfile::getRealpath($name); $name = '/' . $name; $ffile = new Ffile($this->__masterserver, $this->__readserver, "__path_log", $name, $this->getParentO()->username); $ffile->__parent_o = $this; $ffile->get(); $ffile->readonly = 'on'; return $ffile; }
function getFfileFromVirtualList($name) { $name = coreFfile::getRealpath($name); $name = '/' . $name; $parent_name = $this->getParentName(); $ffile = new Ffile($this->__masterserver, $this->syncserver, "__path_httpd_root/{$parent_name}/{$parent_name}", $name, $this->nname); $ffile->__parent_o = $this; $ffile->get(); return $ffile; }
static function add($parent, $class, $param) { $param['parent_clname'] = $parent->getClName(); $param['syncserver'] = $parent->syncserver; $param['path'] = coreFfile::getRealpath($param['path']); $param['nname'] = $param['parent_clname'] . "___" . $param['path']; // Update the parent. The syncing of dirprotect is handled by the web object. $web = $parent; $web->setUpdateSubaction('add_delete_dirprotect'); return $param; }
function getFfileFromVirtualList($name) { $root = $gbl->getSessionV('ffile_root'); if (!$root) { throw new lxException("no_root_dir_specified", 'template'); } $name = coreFfile::getRealpath($name); $name = '/' . $name; $ffile = new Ffile($this->__masterserver, $this->__readserver, $root, $name, "lxlabs"); $ffile->__parent_o = $this; $ffile->get(); return $ffile; }
function getFfileFromVirtualList($name) { global $gbl, $sgbl, $login, $ghtml; $parent = $this->getParentO(); if ($this->isClass('ostemplate_xen')) { $path = "d"; } $root = "{$gen->rootdir}/vps/{$parent->ttype}/{$parent->nname}/"; $name = coreFfile::getRealpath($name); $name = "/{$name}"; $ffile = new Ffile(null, $server, $root, $name, "root"); $ffile->__parent_o = $this; $ffile->get(); $ffile->browsebackup = 'on'; return $ffile; }
function getFfileFromVirtualList($name) { global $gbl, $sgbl, $login, $ghtml; $name = coreFfile::getRealpath($name); $name = "/{$name}"; $parent = $this->getParentO(); $root = "__path_program_home/{$this->getParentO()->get__table()}/{$this->getParentO()->nname}/__backup/"; $fullpath = "{$root}/{$name}"; if ($parent->isClient()) { $syncserver = "localhost"; } else { $syncserver = $parent->syncserver; } rl_exec_get(null, $syncserver, array("lxbackup", "MakeSureDirectoryExists"), array("{$root}/")); $ffile = new Ffile(null, $syncserver, $root, $name, 'lxlabs'); $ffile->__parent_o = $this; $ffile->get(); return $ffile; }
function getFfileFromVirtualList($name) { global $gbl, $sgbl, $login, $ghtml; $parent = $this->getParentO(); $bserver = $parent->getBackupServer(); if (is_disabled_or_null($bserver)) { throw new lxException("backup_server_is_not_configured"); } $bs = new CentralBackupServer(null, null, $bserver); $bs->get(); if ($bs->dbaction === 'add') { throw new lxException("backup_server_is_not_there"); } $server = $bs->slavename; $root = "{$bs->snapshotdir}/vps/{$parent->ttype}/{$parent->nname}/"; $name = coreFfile::getRealpath($name); $name = "/{$name}"; $ffile = new Ffile(null, $server, $root, $name, "root"); $ffile->__parent_o = $this; $ffile->get(); $ffile->browsebackup = 'on'; return $ffile; }
function getFfileFromVirtualList($name) { $name = coreFfile::getRealpath($name); $htroot = $this->getFullDocRoot(); $confroot = "__path_httpd_root/{$this->nname}/"; if ($name === '__lx_error_log') { $root = "{$confroot}/stats/"; $name = "{$this->nname}-error_log"; $readonly = 'on'; $showheader = false; $numlines = '20'; $extraid = "__lx_error_log"; if ($this->__driverappclass === 'lighttpd') { rl_exec_get(null, $this->syncserver, array("web__lighttpd", 'fixErrorLog'), array($this->nname)); } } else { if ($name === '__lx_access_log') { $root = "{$confroot}/stats/"; $name = "{$this->nname}-custom_log"; $readonly = 'on'; $showheader = false; $numlines = '20'; $extraid = "__lx_access_log"; } else { if ($name === '__lx_php_log') { $root = "/home/{$this->customer_name}/__processed_stats/"; $name = "{$this->nname}.phplog"; $readonly = 'on'; $showheader = false; $numlines = '20'; $extraid = "__lx_php_log"; } else { $root = $htroot; $readonly = 'off'; $showheader = true; $name = '/' . $name; $numlines = null; $extraid = null; } } } $ffile = new Ffile($this->__masterserver, $this->syncserver, $root, $name, $this->username); $ffile->__parent_o = $this; $ffile->get(); $ffile->readonly = $readonly; $ffile->__flag_showheader = $showheader; $ffile->numlines = $numlines; $ffile->__var_extraid = $extraid; return $ffile; }
function getFfileFromVirtualList($name) { list($mailacc, $domain) = explode("@", $this->nname); $mailpath = mmail__qmail::getDir($domain); $name = coreFfile::getRealpath($name); $name = '/' . $name; $ffile = new Ffile($this->__masterserver, $this->__readserver, "{$mailpath}/{$mailacc}", $name, mmail__qmail::getUserGroup($domain)); $ffile->__parent_o = $this; $ffile->get(); return $ffile; }
function getFfileFromVirtualList($name) { $name = coreFfile::getRealpath($name); $name = '/' . $name; $ffile = new Ffile($this->__masterserver, $this->websyncserver, "__path_customer_root/{$this->getPathFromName()}", $name, "{$this->username}"); $ffile->__parent_o = $this; $ffile->get(); return $ffile; }
function setFileType() { global $gbl, $sgbl, $login, $ghtml; $this->base = basename($this->nname); $this->fullpath = $this->getFullPath(); $sel_append = NULL; if (isset($gbl->c_session->ssession_vars["frm_clip_action"]) && $gbl->c_session->ssession_vars['frm_clip_root'] == $this->root && $gbl->c_session->ssession_vars['frm_clip_server'] === $this->syncserver) { $selaction = $gbl->c_session->ssession_vars["frm_clip_action"]; $sellist = $gbl->c_session->ssession_vars["frm_clip_list"]; if (array_search_bool($this->nname, $sellist)) { $sel_append = "_" . $selaction; } } if ($this->base === "..") { $this->ttype = "back"; return; } if ($this->base === ".trash") { $this->ttype = "trash"; $this->protect = "na"; return; } if ($this->isInsideTrash()) { $this->protect = "na"; } /* if ($this->is_link()) { $this->ttype = "link"; return; } */ $this->ttype = "{$this->ttype}{$sel_append}"; if ($this->is_dir()) { if ($this->getParentO()->is__table('web')) { if (strpos(dirname($this->nname), '/') === false || dirname($this->nname) === '/') { if ($this->base != "www") { $this->protect = "na"; } } if (!isset($this->protect)) { try { $protname = $this->getParentO()->nname . "_" . coreFfile::getRealPath($this->nname); $prot = $this->getParentO()->getFromList("dirprotect", $protname); if ($prot->status != 'nonexistant') { $this->protect = "on"; } else { $this->protect = 'off'; } } catch (exception $e) { $this->protect = "off"; } } } return; } $this->protect = "na"; }
function getFfileFromVirtualList($name) { if ($this->isXen() && $this->isOn('status')) { throw new lxexception('to_use_filemanager_shut_down_xen_vm_first'); } if (!$this->isXen() && !$this->vpsid) { throw new lxexception('something_wrong_there_is_no_vpsid'); } $name = coreFfile::getRealpath($name); $name = '/' . $name; if ($this->isXen()) { $root = "__path_home_dir/xen/{$this->nname}/mnt"; } else { if ($this->isOn('status')) { $root = "/vz/root/{$this->vpsid}"; } else { $root = "{$this->corerootdir}/{$this->vpsid}/"; } } $ffile = new Ffile($this->__masterserver, $this->syncserver, $root, $name, "root"); $ffile->__parent_o = $this; $ffile->get(); return $ffile; }
function dbactionUpdate($subaction) { if_demo_throw_exception('ffile'); if ($this->main->isOn('readonly')) { throw new lxexception('file_manager_is_readonly', ''); } switch ($subaction) { case "edit": lfile_put_contents($this->main->getFullPath(), $this->main->content); break; case "upload": $filename = $this->main->getFullPath() . "/{$this->main->upload_file_name}"; dprintr($this->main->upload_overwrite_f); if (!$this->main->isOn('upload_overwrite_f')) { if (lfile_exists($filename)) { throw new lxexception('file_exists_upload', 'upload_name_f'); } } getFromFileserv($this->main->__var_upload_tmp_server, $this->main->__var_upload_filepass, $filename); break; case "rename": $directory = dirname($this->main->fullpath); $new = $directory . "/" . $this->main->newname; if (lfile_exists($new)) { throw new lxexception('file_exists_rename', ''); } lxfile_mv_rec($this->main->fullpath, $new); //lxfile_unix_chown($new, $this->main->__username_o); break; case "paste": if ($this->main->paste_list) { // Hack... SPecifically checking for pasteaction. Should just use it directly in the command. $arglist[] = $this->main->__username_o; foreach ($this->main->paste_list as &$_tl) { $_tl = $this->main->root . $_tl; } //$arglist = array_merge($arglist, $this->main->paste_list); $arglist[] = $this->main->paste_list; $arglist[] = $this->main->fullpath; if ($this->main->pasteaction === 'copy') { foreach ($this->main->paste_list as $p) { lxfile_cp_rec($p, $this->main->fullpath); } } else { foreach ($this->main->paste_list as $p) { lxfile_mv_rec($p, $this->main->fullpath); } } //lxfile_unix_chown_rec($this->main->fullpath, $this->main->__username_o); } break; case "perm": throw new lxexception('no_perm_setting', ''); break; case "newdir": $i = 1; $rpath = $this->main->fullpath; $name = "/" . $this->main->newfolder_f; $path = $rpath . $name; if (lxfile_exists($path)) { throw new lxexception('file_exists', ''); } lxfile_mkdir($path); break; case "zip_file": foreach ($this->main->zip_file_list as &$_t_f) { $_t_f = coreFfile::removeLeadingSlash($_t_f); $_t_f = basename($_t_f); $_t_f = "\"{$_t_f}\""; } $list = implode(" ", $this->main->zip_file_list); $oldir = getcwd(); $fullpath = expand_real_root($this->main->fullpath); do_exec_system($this->main->__username_o, $fullpath, "c:/Progra~1/7-Zip/7z a NewArchive.zip {$list}", $out, $err, $ret, null); break; case "filedelete": foreach ($this->main->filedelete_list as $f) { ffile__common::moveToTrash($this->main->root, $f); } break; case "restore_trash": foreach ($this->main->restore_trash_list as $f) { ffile__common::restoreFromTrash($this->main->root, $f); } break; case "clear_trash": foreach ($this->main->clear_trash_list as $f) { ffile__common::clearFromTrash($this->main->root, $f); } break; case "zipextract": $fulzippath = $this->main->root . $this->main->zip_extract_dir_f; if (!lxfile_exists(null, $fulzippath)) { lxfile_mkdir($fulzippath); } else { $zipdir = new Ffile("localhost", "localhost", $this->main->root, $this->main->zip_extract_dir_f, $this->main->__username_o); $zipdir->get(); if (!$zipdir->is_dir()) { throw new lxexception("file_exists_but_not_dir", 'unzippath', $this->main->zip_extract_dir_f); } } $command = "c:/Progra~1/7-zip/7z x -y"; $dir = expand_real_root($fulzippath); $file = expand_real_root($this->main->getFullPath()); if (!csa($file, ":")) { $fullpath = getcwd() . "/{$file}"; } else { $fullpath = $file; } $oldir = getcwd(); $fullpath = expand_real_root($fullpath); do_exec_system($this->main->__username_o, $dir, "{$command} {$fullpath}", $out, $err, $ret, null); break; } }
static function getContent($__username_o, $root, $path, $stat, $numlines) { if ($stat['ttype'] === "zip" || $stat['ttype'] === 'tgz' || $stat['ttype'] === 'tar') { $res = lxshell_getzipcontent($path); //$res = str_replace(" ", " ", $res); $list = explode("\n", $res); $list = preg_grep("/Archive:/", $list, PREG_GREP_INVERT); $stat['zipcontent'] = implode("\n", $list); } else { if (self::is_image($path)) { $stat = self::get_image_info($path); } else { if (!coreFfile::is_a_directory($stat['mode'])) { $stat = self::getFile($stat, $path, $numlines); } } } return $stat; }
function postAdd() { global $gbl, $sgbl, $login, $ghtml; $gen = $login->getObject('general')->generalmisc_b; $parent = $this->getParentO(); $domdefault = $parent->getObject('domaindefault'); $web = $this->getObject("web"); $mmail = $this->getObject('mmail'); $dns = $this->getObject("dns"); $web->remove_processed_stats = $domdefault->remove_processed_stats; $dname = $this->nname; //$dname = self::createUusername($dname); $web->ftpusername = substr($dname, 0, 31); $gen = $login->getObject('general')->generalmisc_b; $web->__var_extrabasedir = $gen->extrabasedir; $this->cpstatus = 'on'; $this->ttype = 'virtual'; $web->ttype = 'virtual'; $mmail->ttype = 'virtual'; if ($this->isClass('subdomain')) { $parentdomain = $parent->getFromList('domaina', $this->subdomain_parent); } if ($this->isOn("simple_add_f") || $this->isClass('subdomain')) { if ($this->isClass('subdomain')) { $cparent = $parentdomain; } else { $cparent = $parent; } $this->template_used = $cparent->template_used; $this->resourceplan_used = $cparent->resourceplan_used; $this->priv = clone $cparent->priv; $this->listpriv = clone $cparent->listpriv; $this->disable_per = $cparent->disable_per; $this->password = $cparent->password; $this->realpass = $cparent->realpass; $this->priv->phpfcgiprocess_num = 0; $web->priv->phpfcgiprocess_num = 0; $this->priv->phpfcgi_flag = 'off'; $web->priv->phpfcgi_flag = 'off'; } else { $this->realpass = $parent->realpass; $this->password = crypt($this->realpass); if ($this->isOn('use_resourceplan_f')) { $template = getFromAny(array($login, $parent), 'resourceplan', $this->resourceplan_f); if (!$template) { throw new lxexception("the_resourceplan_doesnt_exist", 'resourceplan_f', $this->resourceplan_f); } $this->template_used = $this->resourceplan_f; $this->resourceplan_used = $this->resourceplan_f; $this->priv = clone $template->priv; $this->listpriv = clone $template->listpriv; $this->disable_per = $template->disable_per; if (!$this->dnstemplate_f) { $list = domainBase::getDnsTemplateList($parent); $this->dnstemplate_f = $list[0]; } } } if (!$this->docroot) { $this->docroot = $this->nname; } $this->docroot = coreFfile::getRealpath($this->docroot); if ($this->isClass('subdomain')) { $dnstemplate = $parentdomain->getObject('dns'); } else { $dnstemplate = new Dnstemplate($this->__masterserver, null, $this->dnstemplate_f); $dnstemplate->get(); if ($dnstemplate->dbaction === 'add') { throw new lxexception('the_dns_template_doesnt_exist', 'dnstemplate_f', $this->dnstemplate_f); } } //$mmail->catchall = $domaindefault->catchall; if (!$mmail->catchall) { $mmail->catchall = 'Delete'; } $web->ipaddress = $dnstemplate->getIpForBaseDomain(); $web->docroot = $this->docroot; ///#656 When adding a subdomain, the Document Root field is not being validated if (csa($web->docroot, " /")) { throw new lxexception("document_root_may_not_contain_spaces", 'docroot', ""); } else { $domain_validation = str_split($web->docroot); $domain_validation_num = strlen($web->docroot) - 1; if ($domain_validation[$domain_validation_num] == " ") { throw new lxexception("document_root_may_not_contain_spaces", 'docroot', ""); } } $web->docroot = trim($web->docroot, "/"); $dns->copyObject($dnstemplate); $dns->dbaction = 'add'; $web->syncserver = $parent->websyncserver; $dns->syncserver = implode(",", $parent->dnssyncserver_list); $mmail->syncserver = $parent->mmailsyncserver; $dns->zone_type = 'master'; unset($this->cttype); if ($this->isClass('subdomain')) { $this->dtype = 'subdomain'; } else { $this->dtype = 'maindomain'; } $mmail->fixSyncServer(); $web->fixSyncServer(); $dns->fixSyncServer(); if ($sgbl->dbg < 0) { if (getOsForServer($dns->syncserver) === 'windows') { throw new lxexception('no_dns_on_windows'); } if (getOsForServer($mmail->syncserver) === 'windows') { throw new lxexception('no_mail_on_windows'); } } $skelf = "__path_client_root/{$parent->nname}/skeleton.zip"; if (!lxfile_exists($skelf)) { $skelf = "__path_client_root/admin/skeleton.zip"; } //--- for new user-skeleton (since 6.1.7) if (!lxfile_exists($skelf)) { // MR -- must using \- for zip name $skelf = "__path_kloxo_httpd_root/" . "user\\-skeleton.zip"; } if (!lxfile_exists($skelf)) { $skelf = "__path_kloxo_httpd_root/skeleton.zip"; } if (!lxfile_exists($skelf)) { $skelf = null; } if ($skelf) { $web->__var_skelmachine = getOneIPForLocalhost($web->syncserver); $ret = cp_fileserv($skelf); $web->__var_skelfile = $ret; } else { $web->__var_skelfile = null; } $ftpuser = new Ftpuser(null, $web->syncserver, $web->ftpusername); $ftpuser->initThisdef(); //$uuser = new Uuser(null, $web->syncserver, $dname); //$uuser->initThisdef(); //$web->addObject('uuser', $uuser); $ftpuser->directory = $this->docroot; $parent->addObject('ftpuser', $ftpuser); $ftpuser->username = $parent->username; if ($this->getRealClientParentO()->username) { $web->username = $this->getRealClientParentO()->username; } else { $web->username = $this->getRealClientParentO()->nname; } $rp = $this->getRealClientParentO(); $web->customer_name = $rp->getPathFromName('nname'); $mmail->systemuser = $web->username; $this->mmailpserver = $mmail->syncserver; $this->webpserver = $web->syncserver; $this->dnspserver = $dns->syncserver; // hack hack convert listpriv into a differnet object. $this->generateCMList(); $this->distributeChildQuota(); $driverapp = $gbl->getSyncClass($this->__masterserver, $web->syncserver, 'web'); //////////////////// //$uuser->syncserver = $web->syncserver; $ftpuser->syncserver = $web->syncserver; //$ftpuser->directory = "/domain/$this->nname"; //Hack hack uuser needs driver to be redone, since the driver was created when uuser had no syncserver.... //$uuser->createSyncClass(); $ftpuser->createSyncClass(); $web->createSyncClass(); $mmail->createSyncClass(); $dns->createSyncClass(); //$uuser->realpass = $this->realpass; //$uuser->password = crypt($this->realpass); $ftpuser->realpass = $this->realpass; $ftpuser->password = crypt($this->realpass); $mmail->remotelocalflag = 'local'; $web->stats_username = $this->nname; $web->stats_password = null; // Gotta Add postmaster... $mailaccount = new Mailaccount($this->__masterserver, $this->__readserver, "postmaster@{$this->nname}"); $mailaccount->initThisdef(); $mailaccount->__parent_o = $mmail; $mailaccount->syncserver = $mmail->syncserver; $mailaccount->parent_clname = $mmail->getClName(); $mailaccount->postAdd(); $mailaccount->cpstatus = 'on'; $mailaccount->password = $this->password; $mailaccount->realpass = $this->realpass; //$mailaccount->metadbaction = 'writeonly'; $mmail->addToList('mailaccount', $mailaccount); $spam = new Spam($this->__masterserver, $this->__readserver, $this->nname); $spam->initThisdef(); $res['syncserver'] = $mmail->syncserver; $spam->create($res); $spam->parent_clname = $mmail->getClName(); $mmail->addObject('spam', $spam); /* Not needed, instead the admin can configure this after the domain is created. if ($maindomain) { $parked = new addondomain(null, null, "{$this->nname}.$maindomain"); $parked->initThisdef(); $res['mail_flag'] = 'off'; $parked->create($res); $parked->parent_clname = $this->getClName(); $this->addToList('addondomain', $parked); } */ //$uuser->shellflag = 'off'; //$uuser->shell = '--Disabled--'; /* if (exists_in_db($this->__masterserver, "uuser", $uuser->nname)) { throw new lxexception('user_exists_in_db', 'uuser'); } */ /* $backup = new LxBackup($this->__masterserver, $this->__readserver, $this->getClName()); $backup->initThisDef(); $this->AddObject('lxbackup', $backup); */ //lxfile_mkdir("__path_program_home/domain/$this->nname/__backup"); $this->lxclientpostAdd(); $this->generateDomainKey(true); }
function zipFile() { foreach ($this->main->zip_file_list as &$_t_f) { $_t_f = coreFfile::removeLeadingSlash($_t_f); $_t_f = basename($_t_f); $_t_f = "\"{$_t_f}\""; } $list = implode(" ", $this->main->zip_file_list); $oldir = getcwd(); $fullpath = expand_real_root($this->main->fullpath); /* $fz = $fullpath . "/" . $this->main->zip_file_f; if (lxfile_exists($fz)) { throw new lxexception('file_exists', 'zip_file_f', $this->main->zip_file_f); } */ $date = date("M-d-H"); //check_file_if_owned_by_and_throw("NewArchive-$date.zip", $this->main->__username_o); $ret = new_process_cmd($this->main->__username_o, $fullpath, "zip -qu -r NewArchive-{$date} {$list}"); return "{$fullpath}/NewArchive-{$date}.zip"; }
function getFfileFromVirtualList($name) { $name = coreFfile::getRealpath($name); $name = "/{$name}"; $root = "__path_mail_root/domains/{$this->nname}/"; $ffile = new Ffile($this->__masterserver, $this->syncserver, $root, $name, $this->username); $ffile->__parent_o = $this; $ffile->get(); $ffile->readonly = 'on'; return $ffile; }