Example #1
0
 function updateSwitchProgram($param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if_demo_throw_exception('switchprog');
     $this->web_driver = $gbl->getSyncClass($this->__masterserver, $this->nname, 'web');
     $this->dns_driver = $gbl->getSyncClass($this->__masterserver, $this->nname, 'dns');
     $this->spam_driver = $gbl->getSyncClass($this->__masterserver, $this->nname, 'spam');
     $a['web'] = $this->web_driver;
     $a['dns'] = $this->dns_driver;
     $a['spam'] = $this->spam_driver;
     foreach ($param as $k => $v) {
         if ($this->{$k} === $v) {
             dprint("No change for {$k}: {$v}\n");
         } else {
             $class = strtilfirst($k, "_");
             $drstring = "{$class}_driver";
             rl_exec_get(null, $this->nname, array($class, 'switchDriver'), array($class, $this->{$drstring}, $v));
             changeDriver($this->nname, $class, $v);
             $fixc = $class;
             if ($class === 'spam') {
                 $fixc = "mmail";
             }
             lxshell_return("__path_php_path", "../bin/fix/fix{$fixc}.php", "--server={$this->nname}");
             $a[$class] = $v;
             rl_exec_get(null, $this->nname, 'slave_save_db', array('driver', $a));
         }
     }
 }
Example #2
0
 function dbactionUpdate($subaction)
 {
     if_demo_throw_exception('lxguard');
     $rmt = new Remote();
     $rmt->data['disablehit'] = $this->main->disablehit;
     lfile_put_serialize("__path_home_root/lxguard/config.info", $rmt);
     lxshell_return("__path_php_path", "../bin/common/lxguard.php");
 }
Example #3
0
 function updateLxupdateInfo()
 {
     if_demo_throw_exception();
     if (isUpdating()) {
         throw new lxException("program_is_already_updating");
     } else {
         rl_exec_get($this->__masterserver, 'localhost', array('lxupdate', 'execUpdate'), null);
         throw new lxException("update_scheduled");
     }
 }
Example #4
0
 function updateRemove($param)
 {
     if_demo_throw_exception();
     $server = $this->syncserver;
     $sq = new Sqlite(null, "lxguardhit");
     foreach ($param['_accountselect'] as $ip) {
         $sq->rawQuery("delete from lxguardhit where syncserver = '{$server}' AND ipaddress = '{$ip}'");
     }
     self::save_current_hitlist($server);
 }
Example #5
0
 function shellModify()
 {
     global $gbl, $sgbl, $login, $ghtml;
     if_demo_throw_exception();
     $shell = fix_disabled($this->main->shell, $sgbl->__var_noaccess_shell);
     lxshell_return("usermod", "-s", $shell, $this->main->nname);
     if ($this->main->isOn('disable_system_flag')) {
         lxshell_return("usermod", "-L", $this->main->nname);
     } else {
         lxshell_return("usermod", "-U", $this->main->nname);
     }
 }
Example #6
0
 static function addform($parent, $class, $typetd = null)
 {
     if_demo_throw_exception('short');
     $vlist['sortid'] = null;
     if ($typetd['val'] !== 'separator') {
         $vlist['url'] = null;
         $vlist['description'] = null;
         $vlist['external'] = array('h', 'on');
     }
     $ret['variable'] = $vlist;
     $ret['action'] = 'add';
     return $ret;
 }
 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");
 }
Example #8
0
 function deleteSpecific()
 {
     if_demo_throw_exception('demo');
     $sq = new Sqlite(null, 'ipaddress');
     $sq->rawQuery("delete from ipaddress where syncserver = '{$this->nname}'");
     //$this->fixDatabaseServers();
 }
Example #9
0
 function updatePassword($param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if_demo_throw_exception('lxclient');
     if ($this->isLogin() || $this->is__table('auxiliary') && $this->getParentO()->isAuxiliary()) {
         if (!check_password($param['old_password_f'], $this->password)) {
             throw new lxException("Wrong+Password", 'old_password_f');
         }
         unset($param['old_password_f']);
     }
     $this->__old_password = $this->password;
     $param['realpass'] = $param['password'];
     $param['password'] = crypt($param['password']);
     // Hack hack... this is due the forced security password change in the admin. Most likely the referal url, to which it is redirected, is empty. So if you are changing the login password, you can anyway redirect to 'show';
     if ($this->isLogin()) {
         $gbl->__this_redirect = '/display.php?frm_action=show';
     }
     return $param;
 }
Example #10
0
 function updateInformation($param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if_demo_throw_exception('info');
     if (isset($param['cttype'])) {
         if (!$this->isAdmin()) {
             if ($this->getParentO()->isGt($param['cttype'])) {
                 throw new lxException("parent_doesnt_have_privileges", 'cttype', '');
             }
         }
     }
     if ($login->isAdmin()) {
         $gen = $login->getObject('general');
         $gen->disable_admin = $param['disable_admin'];
         if ($gen->isOn('disable_admin')) {
             $list = $login->getList('auxiliary');
             if (count($list) == 0) {
                 throw new lxException("you_should_create_auxiliary_id_before_disabling_admin", '', '');
             }
         }
         $gen->setUpdateSubaction();
         $gen->write();
     }
     return $param;
 }
Example #11
0
 function syncCreateConf()
 {
     global $gbl, $sgbl, $login, $ghtml;
     global $global_shell_error;
     if_demo_throw_exception('cron');
     $conf_file = "__path_cron_root/{$this->main->username}";
     $list = array('minute', 'hour', 'weekday', 'ddate', 'month');
     $tfile = lx_tmp_file($conf_file);
     $cmd = null;
     if ($this->main->__var_mailto) {
         $cmd .= "MAILTO={$this->main->__var_mailto}\n";
     }
     $result = $this->main->__var_cron_list;
     foreach ($result as &$__r) {
         foreach ($list as $l) {
             $__r[$l] = unserialize(base64_decode($__r["ser_{$l}"]));
         }
     }
     $result = merge_array_object_not_deleted($result, $this->main);
     //dprintr($result);
     foreach ((array) $result as $v) {
         if ($v['ttype'] === 'simple') {
             $v['weekday'] = array('--all--');
             $v['month'] = array('--all--');
             $v['ddate'] = array('--all--');
             if ($v['simple_cron'] === 'every-day') {
                 $v['hour'] = $v['cron_day_hour'];
                 $v['minute'] = 0;
             }
             if ($v['simple_cron'] === 'every-hour') {
                 $v['hour'] = array('--all--');
                 $v['minute'] = 0;
             }
             if ($v['simple_cron'] === 'every-minute') {
                 $v['hour'] = array('--all--');
                 $v['minute'] = array('--all--');
             }
         } else {
             foreach ($v["weekday"] as &$___tq) {
                 if (is_numeric($___tq)) {
                     $___tq -= 1;
                 }
             }
         }
         foreach ($list as $l) {
             $v[$l] = $this->getCronString($v[$l]);
         }
         if (!$v['minute']) {
             $v['minute'] = 0;
         }
         $cmd .= implode("\t", array($v['minute'], $v['hour'], $v['ddate'], $v['month'], $v['weekday'], $v['command']));
         $cmd .= "\n";
     }
     lfile_put_contents($tfile, $cmd);
     if (!posix_getpwnam($this->main->username)) {
         lxfile_rm("/var/spool/cron/{$this->main->username}");
         return;
     }
     $ret = lxshell_return("crontab", "-u", $this->main->username, $tfile);
     if ($ret) {
         // Why exactly was a throw removed? backup/restore?
         //throw new lxException("adding_cron_failed", "", $global_shell_error);
         $gbl->setWarning('adding_cron_failed', '', $global_shell_error);
         $data = lfile_get_contents($tfile);
         log_log("cron_error", $data);
     }
     lunlink($tfile);
 }
Example #12
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;
     }
 }
Example #13
0
 function updateDisable($param, $reason = null)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if ($this->isAdmin()) {
         return;
     }
     if_demo_throw_exception();
     if (!$reason) {
         $reason = "__type:{$login->nname}:{$login->cttype}";
     }
     if (isset($this->status) && $this->status === 'on') {
         $this->disable_reason = $reason;
         $this->setStatus('off');
     }
     return null;
 }
Example #14
0
 function postUpdate()
 {
     // The lxclient postupdate which checks for change of skin...
     if ($this->subaction === 'createtemplate') {
         if ($this->isXen()) {
             $stem = explode("-", $this->ostemplate);
             if ($this->isWindows()) {
                 $name = "{$stem[0]}-";
             } else {
                 $name = "{$stem[0]}-{$stem[1]}-{$stem[2]}-";
             }
             $templatename = "{$name}{$this->newostemplate_name_f}";
             if ($this->isWindows()) {
                 $tempfpath = "__path_program_home/xen/template/{$templatename}.img";
             } else {
                 $tempfpath = "__path_program_home/xen/template/{$templatename}.tar.gz";
             }
             if (lxfile_exists($tempfpath)) {
                 throw new lxException("template_already_exists");
             }
         } else {
             $stem = explode("-", $this->ostemplate);
             $name = "{$stem[0]}-{$stem[1]}-{$stem[2]}-";
             $templatename = "{$name}{$this->newostemplate_name_f}";
             if (lxfile_exists("/vz/template/cache/{$templatename}.tar.gz")) {
                 throw new lxException("template_already_exists");
             }
         }
     }
     if ($this->subaction === 'rebuild' || $this->subaction === 'installkloxo') {
         if_demo_throw_exception();
         $this->setUpOsTemplateDownloadParam();
     }
     parent::postUpdate();
 }
Example #15
0
 function isSync()
 {
     if_demo_throw_exception('ip');
     return false;
 }
Example #16
0
 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;
     }
 }
Example #17
0
 function updatePortConfig($param)
 {
     if_demo_throw_exception('port');
     return $param;
 }
Example #18
0
 function dbactionUpdate($subaction)
 {
     if_demo_throw_exception('ps');
     lxshell_return("kill", "-" . $this->main->signal, $this->main->nname);
 }