chown($user_dir . "/{$docfile}", $vhost->owner); chgrp($user_dir . "/{$docfile}", $vhost->owner); chmod($user_dir . "/{$docfile}", 0755); } } setmsg(t('Saved'), 'notice', "?task=edit&name={$name}"); } if ($do == 'delete') { $user_dir = "{$home}/{$vhost->owner}/{$name}"; foreach ($error_documents as $doc) { $docfile = intval($doc) . '.shtml'; if (file_exists($user_dir . "/{$docfile}")) { @unlink($user_dir . "/{$docfile}"); } } setmsg(t('Saved'), 'notice', "?task=edit&name={$name}"); } $content = is_file($file) ? file_get_contents($file) : ''; break; case 'webalizer': if (!isadmin()) { break; } $sites = ZVhosts::getVhosts(); $output = array(); set_time_limit(0); foreach ($sites as $s) { $output[] = 'Processing site ' . $s->name; $log_dir = $home . "/{$s->owner}/logs/{$s->name}"; $stat_dir = $home . "/{$s->owner}/logs/{$s->name}/html"; $webalizer_path = $zh . "/webalizer/bin/webalizer";
$cmd = "/etc/init.d/proftpd {$o}"; } elseif ($a == 'mysql' && in_array($o, array('start', 'stop', 'restart'))) { $cmd = "/etc/init.d/mysql {$o}"; } else { $cmd = "Invalid command"; } $res = shell_exec("{$cmd} 2>&1"); setmsg(t('Response: ') . $res, 'notice'); break; case 'svn': if (!isadmin()) { setmsg(t('Permission Denied')); } $cmd = "svn up " . ZH; $msg = `{$cmd}`; setmsg("<pre>{$msg}</pre>", 'notice'); break; default: $user = $me; $group = $roles[$role]; if (isadmin()) { if ($_REQUEST['refresh'] == 1 || !isset($_SESSION['services'])) { $_SESSION['services'] = getServicesStatus(); } $services = $_SESSION['services']; } if (!isset($_SESSION['stats'])) { $_SESSION['stats'] = getStatistics(); } $stats = $_SESSION['stats']; break;
$token = token(); $name = isset($_REQUEST['name']) ? $_REQUEST['name'] : ''; if (!isadmin() && $me != $name) { setmsg(t('Permission Denied.')); //break; } $name = preg_replace("/[^a-z0-9]+/i", "", $name); if (!$name) { redirect('user.php'); } $user = ZUser::getUser($name); if (checkToken()) { if (ZUser::removeUser($name)) { setmsg(t('Removed!'), 'notice'); } else { setmsg(t('Error')); } } break; case 'list': default: $task = 'list'; $start = 0; $limit = 20; if ($role == 0) { // user redirect('?task=edit&name=' . $me); //$users = array(ZUser::getUser($me)); } elseif ($role == 1) { // admin $users = ZUser::getUsers($start, $limit);
} } else { if ($op == 'edit') { foreach ($_REQUEST as $k => $v) { $_REQUEST[$k] = str_replace(':', '', $v); } if (ZFtp::updateFtpAccount($owner, $name, $password, $_REQUEST['docroot'], $_REQUEST['writable'])) { setmsg(t('Ftp Account Modified.'), 'notice', 'ftp.php'); } } } } } break; case 'sync': if (syncFtpUsers()) { setmsg(t('Ftp configuration updated!'), 'notice'); } else { setmsg(t('Can not write the configuration file.'), 'error'); } break; case 'list': default: $task = 'list'; $owner = isadmin() ? '' : $me; $accounts = ZFtp::getFtpAccounts($owner); break; } if (!$norender) { include template('ftp'); }
break; } $sql = "DROP DATABASE `{$dbname}`;"; $res = mysql_query($sql); if (!$res) { $error = mysql_error(); setmsg($error, 'error', 'self'); } setmsg(t('Database deleted!'), 'notice', "db.php?task=edit&name={$user}"); //redirect("?task=edit&name=$user"); break; case 'error': break; case 'flush': $sql = "FLUSH PRIVILEGES"; mysql_query($sql); setmsg(t('FLUSH PRIVILEGES'), 'notice'); // no break needed // no break needed case 'list': default: $task = 'list'; $users = ZDatabase::getDbUsers(); break; } if (!$norender) { include template('db'); } if (is_resource($db)) { mysql_close($db); }
function restart_request() { sync(); touch(ZH_TMP . "/run/is_dirty"); touch(ZH_TMP . "/run/restart_needed"); setmsg(t('Apache restart is pending.'), 'notice'); }
setmsg(t('Error')); } } if (checktoken() && 'edit' == $op) { $package = array(); $package['name'] = strip_tags($_REQUEST['name']); $package['desc'] = strip_tags($_REQUEST['desc']); $package['space'] = $_REQUEST['space']; $package['bandwidth'] = $_REQUEST['bandwidth']; $package['site'] = intval($_REQUEST['site']); $package['ftp'] = intval($_REQUEST['ftp']); $package['sql'] = intval($_REQUEST['sql']); $package['state'] = intval($_REQUEST['state']); $package['updated'] = date('Y-m-d H:i:s'); if (ZPackage::updatePackage($id, $package)) { setmsg(t("Package Updated."), 'notice', 'package.php'); } } break; case 'list': default: $task = 'list'; $packages = ZPackage::getPackages(false, 'all'); if ($_REQUEST['get'] == 'json') { $arr = array('records' => $packages, 'total' => count($packages)); echo json_encode($arr); $norender = true; } break; } if (!$norender) {
$sql = "SELECT * FROM task WHERE state=0"; $tasks = $pdo->fetchAll($sql); break; case 'login': if (checktoken()) { $user = addslashes($_REQUEST['user']); $pass = addslashes($_REQUEST['pass']); if (auth($user, $pass)) { $_SESSION[$sess_key]['myname'] = $user; //session_commit(); setmsg(t('You\'ve successfully logged in.'), 'notice', 'index.php'); } else { setmsg(t("Login Incorrect.")); } } break; case 'logout': foreach ($_SESSION as $k => $v) { unset($_SESSION[$k]); } setmsg(t('You\'ve successfully logged out.'), 'notice', 'misc.php?task=login'); break; case 'extra': break; case 'list': default: break; } if (!$norender) { include template('misc'); }