function loginUser($u, $p) { global $_SESSION; if (!file_exists($this->passwd_filename)) { $this->signed_username = Null; unset($_SESSION['username']); return FALSE; } else { $res = FALSE; $txt = ContentOfFile($this->passwd_filename); $lines = split("\n", $txt); foreach ($lines as $line) { list($un, $pn) = explode('=', $line, 2); if (trim($un) == $u) { $res = trim($pn) == $p; break; } } if ($res) { $_SESSION['username'] = $u; $this->signed_username = $u; return TRUE; } else { $this->signed_username = Null; unset($_SESSION['username']); return FALSE; } } }
function BackupFile($file, $bak = '.bak') { $content = ContentOfFile($file); $index = 0; $backup_fn = $file . $bak . $index; while (file_exists($backup_fn)) { $backup_fn = $file . $bak . $index; $index = $index + 1; } SaveTextIntoFile($content, $backup_fn); return $backup_fn; }
function getData() { parent::getData(); $param =& $this->param; $user = $this->site->username(); if (empty($user)) { $user = "******"; } $error = false; // echo "<pre>"; print_r ($_POST); echo "</pre>"; if (isset($_GET['key'])) { $data_src = 'key'; $data_key = $_GET['key']; } else { $data_src = $_POST['datasrc']; } $data_source_is_dates = $data_src == "dates"; if ($data_source_is_dates) { $start_date = $_POST['startdate']; $end_date = $_POST['enddate']; $error = !isValidDate($start_date) or !empty($end_date) and !isValidDate($end_date); } elseif ($data_src == 'key') { $commitsfiles = array($data_key); } else { @($commitsmonthfiles = $_POST['commitsmonthfiles']); if (isset($commitsmonthfiles)) { $commitsfiles = array(); while (list($y, $v_yfiles) = each($commitsmonthfiles)) { while (list($m, $v_mfiles) = each($v_yfiles)) { while (list($d, $v_file) = each($v_mfiles)) { $commitsfiles[] = $v_file; } } } } $error = count($commitsfiles) == 0; } // @$commitsfiles = $_POST['commitsfiles']; $param['DIS_GET_SelectedYear'] = ""; if (isset($_POST['selected_years'])) { $selected_years = $_POST['selected_years']; while (list($k, $y) = each($selected_years)) { $param['DIS_GET_SelectedYear'] .= "{$y}:"; } } if (!isset($commitsfiles)) { $commitsfiles = array(); } // if (isset ($_GET['key'])) { $commitsfiles[] = $_GET['key']; }; $param['DIS_Application'] = "show"; $param['DIS_Command'] = "cmd"; $param['DIS_Result'] = "Result"; if (!$error) { @($operation = $_POST['show']); if (!isset($operation)) { $operation = 'ShowLogs'; } $param['DIS_Parameters'] = "Login used = {$user} <BR>"; @($filter = $_POST['filter']); if (!isset($filter) or strlen($filter) == 0) { $filter = 'profil'; } else { $param['DIS_Parameters'] .= "Filter used = {$filter} <BR>"; if ($filter == 'text') { @($filter_text = $_POST['textfilters']); $filter_text = cleanedTextModule($filter_text); $filter_file_tempo_name = tempnam($SCMLOGS['tmpdir'], "FILTER_TEMPO_"); $filter_file_tempo = fopen($filter_file_tempo_name, "w"); fwrite($filter_file_tempo, $filter_text); fclose($filter_file_tempo); $param['DIS_Parameters'] .= "Filter text = {$filter_text} <BR>"; } } @($format = $_POST['format']); if (!isset($format) or strlen($format) == 0) { $format = 'html'; } else { $param['DIS_Parameters'] .= "Formating used = {$format} <BR>"; } @($type = $_POST['type']); if (!isset($type) or strlen($type) == 0) { $type = 'filtered'; } else { $param['DIS_Parameters'] .= "Output type used = {$type} <BR>"; } @($only_user = $_POST['only_user']); if (!isset($only_user) or strlen($only_user) == 0) { $only_user = ''; } else { $param['DIS_Parameters'] .= "Only commits from user = {$only_user} <BR>"; } @($only_tag = $_POST['only_tag']); if (!isset($only_tag) or strlen($only_tag) == 0) { $only_tag = ''; } else { $param['DIS_Parameters'] .= "Only commits about TAG = {$only_tag} <BR>"; } $is_mail_operation = FALSE; switch ($operation) { case 'EmailLogs': $is_mail_operation = TRUE; $param['DIS_Message'] = "Email {$user} all the logs <BR>(in the selected files)<BR>\n"; $processing_fct = "EmailLogsAction"; break; case 'ShowRawLogs': $param['DIS_Message'] = "Show the RAW logs file (selected files)<BR>\n"; $processing_fct = "ShowRawLogsAction"; break; case 'EmailMyLogs': $is_mail_operation = TRUE; $only_user = $user; $param['DIS_Message'] = "Email {$user} all the logs (in the selected files) \n"; $param['DIS_Message'] .= " from <STRONG>{$user}</STRONG><BR>"; $processing_fct = "EmailMyLogsAction"; break; case 'ShowMyLogs': $only_user = $user; $param['DIS_Message'] = "Show {$user} all the logs (in the selected files) \n"; $param['DIS_Message'] .= " from <STRONG>{$user}</STRONG><BR>\n"; $processing_fct = "ShowMyLogsAction"; break; case 'EmailOnlyLogsFor': $is_mail_operation = TRUE; $param['DIS_Message'] = "Email {$user} all the logs (in the selected files)\n"; $param['DIS_Message'] .= " from user : <STRONG>{$only_user}</STRONG>\n"; $param['DIS_Message'] .= " with tag : <STRONG>{$only_tag}</STRONG><BR>\n"; $processing_fct = "EmailOnlyLogsForAction"; break; case 'ShowOnlyLogsFor': $param['DIS_Message'] = "Show {$user} all the logs (in the selected files)\n"; $param['DIS_Message'] .= " from user : <STRONG>{$only_user}</STRONG>\n"; $param['DIS_Message'] .= " with tag : <STRONG>{$only_tag}</STRONG><BR>\n"; $processing_fct = "ShowOnlyLogsForAction"; break; case 'ShowLogs': default: $param['DIS_Message'] = "Show {$user} all the logs (in the selected files)<BR>\n"; $processing_fct = "ShowLogsAction"; break; } if ($is_mail_operation and $user == 'none') { $error = TRUE; $param['DIS_Message'] = "Operation not allowed"; $param['DIS_Result'] = "Email operation is only for authentified users."; } } if (!$error) { $file_tempo_name = tempnam($SCMLOGS['tmpdir'], "TEMPO_"); $file_tempo = fopen($file_tempo_name, "w"); $param['DIS_Data'] = ""; $repo = SCMLogs_repository(); if ($data_source_is_dates) { $datesforsvn = "{" . $start_date . "}"; $param['DIS_Data'] .= "from " . $start_date . " "; if (empty($end_date)) { $datesforsvn .= ":HEAD"; $param['DIS_Data'] .= " to HEAD"; } elseif (isValidDate($end_date)) { $datesforsvn .= ":{" . $end_date . "}"; $param['DIS_Data'] .= " to " . $end_date . " "; } else { $datesforsvn .= ":HEAD"; $param['DIS_Data'] .= " to HEAD"; } $datesforsvn = str_replace("/", "-", $datesforsvn); $ccmd = $SCMLOGS['svn_bin_path'] . 'svn log --config-dir . -v -r "' . $datesforsvn . '" ' . $repo->svnfile_root(); ob_start(); $res = system($ccmd); $logs = ob_get_contents(); fwrite($file_tempo, $logs); ob_end_clean(); } else { $logsdir = $repo->logsdir; while (list($k, $v_file) = each($commitsfiles)) { $param['DIS_Data'] .= "<li>{$v_file}"; if (preg_match("/^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])\$/", $v_file, $matches)) { $v_file = $logsdir . '/' . $matches[1] . '/' . $matches[2] . '/' . $v_file; } if (preg_match("/^(" . SCMLogs_CurrentCommitFile() . ")\$/", $v_file, $matches)) { $v_file = $logsdir . '/' . $v_file; } //$param['DIS_Data'] .= " :: <em>$v_file</em>"; $param['DIS_Data'] .= "</li>\n"; fwrite($file_tempo, ContentOfFile($v_file)); } } fclose($file_tempo); if ($processing_fct != '') { ob_start(); $param['DIS_Format'] = $format; $param['DIS_Type'] = $type; if ($filter == 'text') { $param_filter = $filter_file_tempo_name; } else { $param_filter = $filter; } set_time_limit(150); $param['DIS_Command'] = $processing_fct($file_tempo_name, $user, $param_filter, $only_user, $only_tag, $format, $type); $param['DIS_Result'] = ob_get_contents(); ob_end_clean(); } else { $param['DIS_Format'] = ''; $param['DIS_Command'] = "Not Yet Implemented"; } if (isset($filter_file_tempo_name)) { RemoveFile($filter_file_tempo_name); } RemoveFile($file_tempo_name); } else { $param['DIS_Format'] = ''; $param['DIS_Parameters'] = "..."; $param['DIS_Command'] = "..."; if (empty($param['DIS_Message'])) { $param['DIS_Message'] = "Please select at least one file or valid dates!!!"; } if (empty($param['DIS_Data'])) { $param['DIS_Data'] = "no file or valid dates selected"; } if (empty($param['DIS_Result'])) { $param['DIS_Result'] = "..."; } } $param['only_user'] =& $only_user; $param['only_tag'] =& $only_tag; $param['commitsfiles'] =& $commitsfiles; }
<?php include LIB_DIR . "file.inc"; $DIS_Application = "Users"; // Operation $op = value_from_POST_GET('op'); $do_save = isset($op) && $op == 'save'; // Administration $admin = value_from_POST_GET('admin'); $is_admin = isset($admin) && isValidAdminPassword($admin); if ($is_admin && !$do_save) { $DIS_UsersText = ContentOfFile(reportersFilename()); } else { if ($do_save) { BackupFile(reportersFilename()); SaveTextIntoFile($_POST['userDataText'], reportersFilename()); loadUsersInformation(); $DIS_UsersMessage = "Modification saved .."; } // Display $users = $GLOBALS['reporting']["users"]; }
$week_filename = weekFilename($year, $week); $week_url = weekUrl($year, $week); $DIS_SaveMessage .= "<br><a href='{$week_url}'>{$week_filename}</a><br>\n"; } else { switch ($op) { case "SaveUrl": @($reporturl = $_POST['reporturl']); if (!isset($reporturl) or $reporturl != "http://" or strlen($reporturl) > 0) { $report_content = ContentOfUrl($reporturl); } break; case "SaveFile": @($reportlocalfile = $_FILES['reportlocalfile']['tmp_name']); if (!isset($reportlocalfile) or strlen($reportlocalfile) > 0) { //echo "LOCALFILE = $reportlocalfile...<BR>"; $report_content = ContentOfFile($reportlocalfile); } break; case "SaveText": $report_content = stripslashes($_POST['report_content']); break; default: break; } $DIS_Username = $username; $DIS_Year = $year; $DIS_Week = $week; $DIS_RawText = $report_content; $DIS_SaveRelatedDate = ""; $DIS_SaveRelatedDate .= "Week {$week} : "; $DIS_SaveRelatedDate .= strftime("%b %d", firstDayOfWeek($week, $year));
$DIS_EditRelatedDate .= " of " . $year; $DIS_EditReportingText = ""; $already_exists = False; $is_read_only = False; $DIS_EditMessage = ""; $target_file = userFilename($username, $year, $week); if (file_exists($target_file)) { $already_exists = True; $DIS_EditMessage .= "Your Report already exists !!!<BR>"; $DIS_EditMessage .= "[ link to your report :: <A target=\"_blank\"\r\n\t\t\tHREF=\"" . userFilename($username, $year, $week) . "\">Reporting {$week} of {$year} of {$username}</A><NR>"; if (!is_writeable($target_file)) { $is_read_only = True; $DIS_EditMessage .= "Your Report is readonly !!! <BR>"; $DIS_EditMessage .= " => If you really want to modify it, ask the administrator to change access on it.<BR>"; } $DIS_EditReportingText = ContentOfFile($target_file); } else { if (isset($_POST['cat_sel'])) { $cat_sel = $_POST['cat_sel']; $DIS_EditReportingText = ""; while (list($key, $val) = each($cat_sel)) { $DIS_EditReportingText .= "<h2>{$val}</h2>\n"; $selected_cat = $GLOBALS['reporting']["categories"][$val]; reset($selected_cat); next($selected_cat); $DIS_EditReportingText .= "<ul>\n"; if (count($selected_cat) > 1) { while (list($skey, $sval) = each($selected_cat)) { $DIS_EditReportingText .= " <h3>{$sval}</h3>\n"; $DIS_EditReportingText .= " <ul>\n"; $DIS_EditReportingText .= " <li>...</li>\n";
<?php require INC_DIR . "reporting_lib.inc"; require LIB_DIR . "date.inc"; include INC_DIR . "layout_helper.inc"; $current_year = currentYear(); // Get value from _POST or _GET $selected_user = value_from_POST_GET('selected_user'); $selected_year = value_from_POST_GET('selected_year', $current_year); // Assign value for Display $DIS_Application = "Browse User Reports"; $DIS_ListYears = array(); $reporting_dirs = listOfKnownYear(); $listUserReports = array(); $weeks_range = range(1, 52); while (list($k_week, $v) = each($weeks_range)) { if (strlen($k_week) < 2) { $k_week = '0' . $k_week; } if (userReportExists($selected_user, $selected_year, $k_week)) { $ufn = userFilename($selected_user, $selected_year, $k_week); $listUserReports[$k_week] = ContentOfFile($ufn); } } krsort($listUserReports); $DIS_AllUsers = active_users() + inactive_users(); @($DIS_PostUsername_HTML_SELECT = userList_HTML_SELECT('selected_user', $DIS_AllUsers, 'Select username', $selected_user));