File manager - Edit - G:/PleskVhosts/indiaminerals.in/vgm.INFOFIXDEVELOPERS.COM/Login.aspx.cs
Back
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Configuration; using WebApp.LIBS; using System.IO; namespace VGM { public partial class Login : System.Web.UI.Page { SqlConnection con; SqlCommand cmd; SqlDataAdapter da; public static void LogLogoutDetails() { try { string dateTime = DateTime.Now.ToString("yyyy-MM-dd"); string time = DateTime.Now.ToString("HH:mm:ss"); // Get additional details string details = "Logout"; // Combine date, time, and details in CSV format with comma delimiter string contentToSave = $"\"{dateTime}\",\"{time}\",\"Logout\",\"{details}\""; // Specify the path to the CSV file (including the file name) string filePath = System.Web.Hosting.HostingEnvironment.MapPath("~/data/LogData.csv"); // Check if the directory exists, if not, create it string directoryPath = Path.GetDirectoryName(filePath); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } // Check if the file exists, if not, create and add headers if (!File.Exists(filePath)) { File.WriteAllText(filePath, "Date,Time,Title,Details" + Environment.NewLine); } // Save the content to the file File.AppendAllText(filePath, contentToSave + Environment.NewLine); } catch (Exception ex) { Console.WriteLine("Error logging logout details: " + ex.Message); } } protected void Page_Load(object sender, EventArgs e) { string cs = ConfigurationManager.ConnectionStrings["gav"].ConnectionString; con = new SqlConnection(cs); con.Open(); } protected void button_Click(object sender, EventArgs e) { if (textbox1.Text == "") { Response.Write("<script>alert('please enter User_name')</script>"); textbox1.Focus(); return; } if (textbox2.Text == "") { Response.Write("<script>alert('please enter password')</script>"); textbox2.Focus(); return; } da = new SqlDataAdapter("select * from login where User_name = '" + textbox1.Text + "' and Password = '" + textbox2.Text + "'", con); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { // Set the session variable to indicate that the user is logged in SiteSession.IsLoggedIn = true; Response.Redirect("~/admin/Dashboard.aspx"); } else { Response.Write("<script>alert('invalid user_name or password')</script>"); } textbox1.Text = ""; textbox2.Text = ""; SaveToCSV(); } private void SaveToCSV() { try { string dateTime = DateTime.Now.ToString("yyyy-MM-dd"); string time = DateTime.Now.ToString("HH:mm:ss"); string tittle = "Login"; // Get additional details (you may customize this part) string details = "Admin Login"; // Combine date, time, and details in CSV format with comma delimiter string contentToSave = $"\"{dateTime}\",\"{time}\",\"{tittle}\",\"{details}\""; // Specify the path to the CSV file (including the file name) string filePath = Server.MapPath("~/data/LogData.csv"); // Check if the directory exists, if not, create it string directoryPath = Path.GetDirectoryName(filePath); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } // Check if the file exists, if not, create and add headers if (!File.Exists(filePath)) { File.WriteAllText(filePath, "Date,Time,Tittle,Details" + Environment.NewLine); } // Save the content to the file File.AppendAllText(filePath, contentToSave + Environment.NewLine); } catch (Exception ex) { Response.Write("<script>alert('An error occurred while saving to CSV: " + ex.Message + "')</script>"); } } } }
| ver. 1.4 |
Github
|
.
| PHP 7.3.33 | Generation time: 0.09 |
proxy
|
phpinfo
|
Settings