function lxshell_expect($strtype, $cmd) { global $gbl, $sgbl, $login, $ghtml; $a = array("ntfsresize" => "expect \"Are you sure you want to proceed (y/[n])? \"\nsend \"y\\r\"\n\n"); $t = lx_tmp_file("expect"); $string = $a['ntfsresize']; lfile_put_contents($t, "spawn {$cmd}\n{$string}"); log_shell("expect {$t} {$cmd}"); system("expect {$t}"); //lunlink($t); }
function getFromRemote($p) { $filepass = $this->main->filepass; getFromRemote($this->main->pasteserver_realip, $filepass[$p], $this->main->fullpath, $p); return; $bp = basename($p); if ($filepass[$p]['type'] === 'dir') { $tfile = lx_tmp_file("__path_tmp", "lx_{$bp}"); getFromFileserv($this->main->pasteserver, $this->main->filepass[$p], $tfile); lxfile_mkdir("{$this->main->fullpath}/{$bp}"); lxshell_unzip("__system__", "{$this->main->fullpath}/{$bp}", $tfile); lunlink($tfile); } else { getFromFileserv($this->main->pasteserver, $this->main->filepass[$p], "{$this->main->fullpath}/{$bp}"); } }
function resizeImage() { $this->throw_if_not_magick(); $oldimage = coreFfile::getRealPath($this->main->old_image_name_f); if ($this->main->isOn('copy_old_image_flag_f')) { lxfile_cp($this->main->getFullPath(), "{$this->main->root}/{$oldimage}"); } $tfile = lx_tmp_file("resizeimage"); lxfile_rm($tfile); $fp = $this->main->getFullPath(); $fp = expand_real_root($fp); $ext = coreFfile::getExtension($fp); $tfile .= ".{$ext}"; $geom = "{$this->main->image_width}x{$this->main->image_height}"; lxfile_cp($this->main->getFullPath(), $tfile); lxshell_user_return($this->main->__username_o, "convert", "-scale", $geom, $tfile, $this->main->getFullPath()); lxfile_rm($tfile); }
public function saveXen() { if (self::getStatus($this->main->nname, self::XEN_HOME) !== 'on') { return null; } $tmp = lx_tmp_file("{$this->main->nname}_ram"); lxshell_return("xm", "save", $this->main->nname, $tmp); return $tmp; }
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); }
function se_submit($contact, $dom, $email) { $tmpfile = lx_tmp_file("se_submit_{$dom}"); include "sesubmit/engines.php"; foreach ($enginelist as $e => $k) { $k = str_replace("[>URL<]", "http://{$dom}", $k); $k = str_replace("[>EMAIL<]", $email, $k); download_file($k, $tmpfile); $var .= "\n\n-----------Submitting to {$e}-------------\n\n"; $var .= lfile_get_contents($tmpfile); } lunlink($tmpfile); lx_mail("kloxo", $contact, "Search Submission Info", $var); lfile_put_contents("/tmp/mine", $var); }
function syncAddFile($domainname) { global $gbl, $sgbl, $login, $ghtml; $dnsfile = "{$sgbl->__path_mara_chroot}/{$sgbl->__path_mara_path}/{$domainname}"; $nameduser = $sgbl->__var_programuser_dns; $fdata = null; //$fdata .= "\$TTL\t\t{$this->main->ttl}\n"; $nameserver = null; $dnsdata = null; foreach ($this->main->dns_record_a as $dns) { if ($dns->ttype === "ns") { $nameserver = $dns->param; $dnsdata .= "{$domainname}. NS {$dns->param}. \n"; } } $ddate = date("Ymd"); $v = rand(0, 99); if ($v < 10) { $v = "0{$v}"; } $ddate = "{$ddate}{$v}"; //$string .= "% SOA {$nameserver}. {$this->main->__var_email}@% 1 10800 3600 604800 86400 \n"; $string = null; $fdata .= $string; $starvalue = null; $fdata .= $dnsdata; foreach ($this->main->dns_record_a as $k => $o) { switch ($o->ttype) { case "ns": //$tmp = "{$domainname} IN NS $o->param. \n"; //$fdata .= $tmp; break; case "mx": $v = $o->priority; $tmp = "{$domainname}. MX {$v} {$o->param}. \n"; $fdata .= $tmp; break; case "a": $key = $o->hostname; $value = $o->param; if ($key === '*') { $starvalue = "* A {$value}"; break; } if ($key !== "__base__") { $key = "{$key}.{$domainname}."; } else { $key = "{$domainname}."; } $tmp = "{$key}\t\t A {$value} \n"; $fdata .= $tmp; break; case "cn": case "cname": $key = $o->hostname; $value = $o->param; $key .= ".{$domainname}."; if ($value !== "__base__") { $value = "{$value}.{$domainname}."; } else { $value = "{$domainname}."; } if ($key === '*') { $starvalue = "*\t\tCNAME {$value}\n"; break; } $tmp = "{$key} CNAME {$value}\n"; $fdata .= $tmp; break; case "txt": $key = $o->hostname; $value = $o->param; if ($o->param === null) { continue; } if ($key !== "__base__") { $key = "{$key}.{$domainname}."; } else { $key = "{$domainname}."; } $value = str_replace("<%domain>", $domainname, $value); $tmp = "{$key} TXT \"{$value}\"\n"; $fdata .= $tmp; break; } } //$fdata .= $starvalue; dprint($dnsfile); $tmpfile = lx_tmp_file($dnsfile); lfile_put_contents($tmpfile, $fdata); $ret = 0; if ($ret) { $out = lxshell_output("named-checkzone", $domainname, $tmpfile); log_log("error", $out); $out = str_replace($tmpfile, "", $out); unlink($tmpfile); throw new lxException("dns_conflict", 'dns', $out); return; } unlink($tmpfile); lfile_put_contents($dnsfile, $fdata); lxfile_unix_chown($dnsfile, $nameduser); }
function installWebmail($ver = null) { // if (!is_numeric($ver)) { return; } log_cleanup("Webmail Checks"); $file = "lxwebmail"; if (!$ver) { $ver = getVersionNumber(get_package_version($file)); log_cleanup("- {$file} version is {$ver}"); } lxfile_mkdir("/var/cache/kloxo"); $path = "/home/kloxo/httpd/webmail"; lxfile_mkdir($path); if (lxfile_exists("/var/cache/kloxo/kloxo-install-firsttime.flg")) { $locverpath = "/var/cache/kloxo/{$file}-version"; $locver = getVersionNumber(file_get_contents($locverpath)); log_cleanup("- local copy version is {$locver}"); if (lxfile_exists("/var/cache/kloxo/{$file}{$locver}.tar.gz")) { log_cleanup("- Use {$file} version {$locver} local copy for installing"); $ver = $locver; } else { log_cleanup("- Download and use version {$ver} for installing"); system("cd /var/cache/kloxo/ ; rm -f {$file}*.tar.gz; wget download.lxcenter.org/download/{$file}{$ver}.tar.gz"); } $DoUpdate = true; } else { if (!lxfile_exists("/var/cache/kloxo/{$file}{$ver}.tar.gz")) { log_cleanup("- Download and use version {$ver} for updating"); system("cd /var/cache/kloxo/ ; rm -f {$file}*.tar.gz; wget download.lxcenter.org/download/{$file}{$ver}.tar.gz"); $DoUpdate = true; } else { log_cleanup("- No update found."); $DoUpdate = false; } } $ret = null; if ($DoUpdate) { $tfile_h = lx_tmp_file("hordeconf"); $tfile_r = lx_tmp_file("roundcubeconf"); if (lxfile_exists("{$path}/horde/config/conf.php")) { lxfile_cp("{$path}/horde/config/conf.php", $tfile_h); } if (lxfile_exists("{$path}/roundcube/config/db.inc.php")) { lxfile_cp("{$path}/roundcube/config/db.inc.php", $tfile_r); } lxfile_rm_rec("{$path}/horde"); lxfile_rm_rec("{$path}/roundcube"); $ret = lxshell_unzip("__system__", $path, "/var/cache/kloxo/{$file}{$ver}.tar.gz"); lxfile_cp($tfile_h, "{$path}/horde/config/conf.php"); lxfile_cp($tfile_r, "{$path}/roundcube/config/db.inc.php"); lxfile_rm($tfile_h); lxfile_rm($tfile_r); } if (!$ret) { return true; } }