function write_stats($username) { global $stats, $conf_stats_path, $split_folder; $username_efn = escape_filename($username); foreach ($split_folder as $folder) { if (!array_key_exists($folder, $stats)) { continue; } $goto_dir = $conf_stats_path . "/" . $folder; if (!file_exists($goto_dir)) { mkdir($goto_dir); } $goto_file_rel = $folder . "/{$username_efn}.stats"; $goto_file = $conf_stats_path . "/" . $goto_file_rel; $stats_goto = $stats; $stats[$folder] = array("goto" => $goto_file_rel); foreach ($stats as $key => &$value) { if ($key != $folder . "/" && strlen($key) > strlen($folder) + 1 && substr($key, 0, strlen($folder) + 1) == $folder . "/") { $stats[$key] = null; unset($stats[$key]); } } foreach ($stats_goto as $key => &$value) { if ($key != $folder && !(strlen($key) > strlen($folder) + 1 && substr($key, 0, strlen($folder) + 1) == $folder . "/")) { $stats_goto[$key] = null; unset($stats_goto[$key]); } } file_put_contents($goto_file, "\$stats_goto = " . var_export($stats_goto, true) . ";"); chmod($goto_file, 0644); } file_put_contents($conf_stats_path . "/{$username_efn}.stats", "\$stats = " . var_export($stats, true) . ";"); }
function setup_paths($username) { global $conf_base_path, $conf_svn_path, $conf_home_path; $username_efn = escape_filename($username); $userdata = array(); $userdata['username'] = $username; $userdata['efn'] = $username_efn; $userdata['esa'] = escapeshellarg($username); $userdata['home'] = $conf_home_path . "/" . substr($username_efn, 0, 1) . "/" . $username_efn; $userdata['workspace'] = $userdata['home'] . "/workspace"; $userdata['svn'] = $conf_svn_path . "/" . $username_efn; $userdata['svn_watch'] = $conf_base_path . "/watch/syncsvn.{$username_efn}.pid"; $userdata['node_watch'] = $conf_base_path . "/watch/node.{$username_efn}.pid"; $userdata['htpasswd'] = $conf_base_path . "/htpasswd/{$username_efn}"; return $userdata; }
function admin_activity_log($user, $path) { global $conf_stats_path; $svn_ignore = array(".c9", ".svn", ".tmux", ".user", ".svn.fifo", ".inotify_pid", ".nakignore", "global_events", "last_update_rev", ".gcc.out"); // Učitaj stats file unset($stats); $user_efn = escape_filename($user); // Make username safe for filename $stat_path = $conf_stats_path . "/{$user_efn}.stats"; if (file_exists($stat_path)) { eval(file_get_contents($stat_path)); } if (!isset($stats)) { ?> <p>Activity log file doesn't exist or isn't valid... it's possible that stats were never generated for this user.</p> <?php return; } // Stats file can reference other files to be included foreach ($stats as $key => $value) { if (is_array($value) && array_key_exists("goto", $value)) { $goto_path = $conf_stats_path . "/" . $value['goto']; eval(file_get_contents($goto_path)); foreach ($stats_goto as $ks => $vs) { $stats[$ks] = $vs; } $stats_goto = null; } } // Show stats for complete tree below current path $log = merge_down($stats, $path); $counter = show_log($log); if ($counter == 0) { ?> <p>There is no recorded activity in path <b><?php echo $path; ?> </b>.<br>User probably created this path after the last statistics update. You can update the stats manually. If the problem persists after update, please contact your administrator.</p> <?php } }
function local_login($login, $pass) { global $conf_base_path; if (!file_exists("{$conf_base_path}/localusers/{$login}") && $login != "test") { return "Nepostojeći korisnik"; } $login_esa = escapeshellarg($login); $login_efn = escape_filename($login); $pass_esa = escapeshellarg($pass); //print "echo $pass | htpasswd -vi /usr/local/webide/localusers/$login $login"; $result = `echo {$pass_esa} | htpasswd -vi {$conf_base_path}/localusers/{$login_efn} {$login_esa} 2>&1`; /// Same thing via pipes (password not visible in process list...) /*$descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to ); $output = array(); $process = proc_open("htpasswd -vi /usr/local/webide/localusers/$login $login", $descriptorspec, $pipes); if (is_resource($process)) { fwrite($pipes[0], $pass); fclose($pipes[0]); $rez = stream_get_contents($pipes[1]); fclose($pipes[1]); proc_close($process); }*/ if (strstr($result, "correct") || $login == "test" && $pass == "test") { // FIXME $_SESSION['login'] = $login; $_SESSION['server_session'] = ""; $_SESSION['userid'] = ""; $_SESSION['user_type'] = "local"; session_write_close(); return ""; } return "error"; }
function read_stats($username) { global $stats, $conf_stats_path; $username_efn = escape_filename($username); $stat_file = $conf_stats_path . "/" . "{$username_efn}.stats"; $stats = NULL; if (file_exists($stat_file)) { eval(file_get_contents($stat_file)); } if ($stats == NULL) { $stats = array("global_events" => array(), "last_update_rev" => 0); } // Stats file can reference other files to be included foreach ($stats as $key => $value) { if (is_array($value) && array_key_exists("goto", $value)) { $goto_path = $conf_stats_path . "/" . $value['goto']; eval(file_get_contents($goto_path)); foreach ($stats_goto as $ks => $vs) { $stats[$ks] = $vs; } $stats_goto = null; } } }
session_start(); require_once "../lib/config.php"; require_once "../lib/webidelib.php"; if (!isset($_SESSION['login'])) { print "not-logged-in"; return 0; } $login = $_SESSION['login']; if (isset($_REQUEST['users'])) { print `sudo {$conf_base_path}/bin/webidectl list-active | sort`; return 0; } $users_file = $conf_base_path . "/users"; eval(file_get_contents($users_file)); $elogin = escape_filename($login); $login_watch_path = $conf_base_path . "/watch/webidectl.login.{$elogin}"; $verify_watch_path = $conf_base_path . "/watch/webidectl.verify-user.{$elogin}"; if (isset($_REQUEST['serverStatus'])) { if ($users[$login]['status'] != "active" && !file_exists($login_watch_path) && !file_exists($verify_watch_path)) { print "not-logged-in"; return 0; } if (file_exists("{$conf_base_path}/razlog_nerada.txt")) { $radovi = file_get_contents("{$conf_base_path}/razlog_nerada.txt"); } if (preg_match("/\\w/", $radovi)) { print "radovi {$radovi}"; return 0; } if (in_array($login, $conf_deny_users)) {