%@ LANGUAGE="VBSCRIPT" %>
<% Option Explicit %>
<% If Session("ValidatedAdministrator") <> True Then
Response.Redirect "error.asp?error=denied"
End If %>
Process Admin Page
<%
Dim objRS
Dim objRSTeacher
Dim sSQL
Dim strTmp
Dim strPath
Dim strEmail
Dim strFolder
Dim strFirst
Dim strLast
Dim iPos
Dim bActivated
Dim bDeActivated
Dim bUpdate
Dim objFSO 'File System Object variable
Dim objF 'Folder Object needed for CreateFolder method of the FSO
Dim Mailer 'SoftArtisans SMTPMail Object variable
Dim bAdmin
'Admin can see ALL student records, Teachers only see their student's records and their own
If Session("Admin") = "Admin" Then
sSQL = "SELECT * FROM Students ORDER BY security, name;"
bAdmin = True
Else
sSQL = "SELECT * FROM Students WHERE teacher = '" & Session("Admin") & "' ORDER BY security, name;"
bAdmin = False
End If
Select Case LCase(Trim(Request.Form("action")))
Case "apply changes" 'Changes could be Activate/DeActivate, and Delete
bUpdate = False
'Create the File System object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open sSQL, objConn, adOpenDynamic, adLockOptimistic, adCmdText
'Don't try processing if there are no records
If Not (objRS.EOF And objRS.BOF) Then
'Process the Activatate/Deactivate records first
objRS.MoveFirst
Do While Not objRS.EOF
Select Case LCase(Trim(Request.Form("R" & objRS("email"))))
Case "yes"
'This Activate Record code creates a Folder for the account if one doesn't already exist
If objRS("active") = False Then
If IsNull(objRS("folder")) Then
'Create the account folder name by extracting the Username part of the email address
iPos = instr(objRS("email"), "@")
strFolder = mid(objRS("email"), 1, iPos-1)
'Check if the folder exists before trying to create it. If the folder already exists,
' append a random digit to the name until it is unique
strPath = "c:/vbStudents/" & strFolder
Do While (objFSO.FolderExists(strPath))
strFolder = strFolder & FormatNumber(Int(Rnd * 10), "0")
strPath = "c:/vbStudents/" & strFolder
Loop
'Use the File System Object's CreateFolder method to make the folder
Set objF = objFSO.CreateFolder(strPath)
objRS("folder") = strFolder
Response.Write (objRS("name") & " Activated. Folder: " & objRS("folder") & " created. An email has been sent to " & objRS("email") & " informing them of their account status.
")
Else
Response.Write (objRS("name") & " ReActivated. An email has been sent to " & objRS("email") & " informing them of their account status.
")
End If
objRS("active") = True
bUpdate = True
Set Mailer = Server.CreateObject("SoftArtisans.SMTPMail")
Mailer.FromName = "Guy Campbell"
Mailer.FromAddress = "campbell_guy@hotmail.com"
Mailer.organization = "Visual Basic - Moorpark College"
Mailer.Subject = "Moorpark College -- Visual Basic Account Activation"
Mailer.smtplog = "C:\mysmtplog.txt"
Mailer.live = True
Mailer.RemoteHost = "sunny.moorpark.cc.ca.us"
Mailer.Priority = 3
'CC the Instructor
'Mailer.addcc objRS("teacher"), objRS("teacheremail")
'Tell the Student that their account had been Activated
Mailer.addrecipient objRS("name"), objRS("email")
Mailer.bodytext = "Your Visual Basic Account has been Activated. " & vbCRLF _
& vbCRLF _
& "Name: " & objRS("name") & vbCRLF _
& "eMail: " & objRS("email") & vbCRLF _
& "Password: " & objRS("password") & vbCRLF _
& "Class: " & objRS("classtype") & vbCRLF _
& "Current Status: Activated" & vbCRLF & vbCRLF _
& "Important: All information is case sensitive." & vbCRLF & vbCRLF _
& "Note: You may now log into your Moorpark College--Visual Basic Account:" & vbCRLF _
& "http://cislab.moorpark.cc.ca.us/vbasic" & vbCRLF & vbCRLF _
& "Thank You, " & vbCRLF & vbCRLF & "Guy Campbell" & vbCRLF & "campbell_guy@hotmail.com"
Mailer.SendMail
Mailer.ClearRecipients
'Tell the Instructor that their Student's account has been Activated
Mailer.Subject = "Your VB Student " & objRS("name") & " - Account Activated!"
Mailer.addrecipient objRS("teacher"), objRS("teacheremail")
Mailer.bodytext = "Your Student: " & objRS("name") & " has had their Visual" & vbCrLf & "Basic account Activated. Student Info:" & vbCRLF _
& vbCRLF _
& "Name: " & objRS("name") & vbCRLF _
& "eMail: " & objRS("email") & vbCRLF _
& "Password: " & objRS("password") & vbCRLF _
& "Class: " & objRS("classtype") & vbCRLF _
& "Current Status: Activated" & vbCRLF & vbCRLF _
& "Important: All information is case sensitive." & vbCRLF & vbCRLF _
& "Note: They may now log into their Moorpark College--Visual Basic Account:" & vbCRLF _
& "http://cislab.moorpark.cc.ca.us/vbasic" & vbCRLF & vbCRLF _
& "Thank You, " & vbCRLF & vbCRLF & "Guy Campbell" & vbCRLF & "campbell_guy@hotmail.com"
Mailer.SendMail
Mailer.ClearRecipients
Set Mailer = Nothing
End If
Case "no"
If objRS("active") = True Then
objRS("active") = False
Response.Write (objRS("name") & " DeActivated. An email has been sent to " & objRS("email") & " informing them of their account status.
")
bUpdate = True
Set Mailer = Server.CreateObject("SoftArtisans.SMTPMail")
Mailer.FromName = "Guy Campbell"
Mailer.FromAddress = "campbell_guy@hotmail.com"
Mailer.organization = "Visual Basic - Moorpark College"
Mailer.Subject = "Moorpark College -- Visual Basic Account Confirmation"
Mailer.smtplog = "C:\mysmtplog.txt"
Mailer.live = True
Mailer.RemoteHost = "sunny.moorpark.cc.ca.us"
Mailer.Priority = 3
'CC the Instructor
'Mailer.addcc objRS("teacher"), objRS("teacheremail")
Mailer.addrecipient objRS("name"), objRS("email")
Mailer.bodytext = "Your Visual Basic Account has been Disabled. " & vbCRLF _
& vbCRLF _
& "Name: " & objRS("name") & vbCRLF _
& "eMail: " & objRS("email") & vbCRLF _
& "Password: " & objRS("password") & vbCRLF _
& "Class: " & objRS("classtype") & vbCRLF _
& "Current Status: Disabled" & vbCRLF & vbCRLF _
& "Important: All information is case sensitive." & vbCRLF & vbCRLF _
& "Note: You cannot login to your Moorpark College--Visual Basic Account" & vbCRLF _
& "until your account is reactivated. Please contact me to learn about" & vbCRLF _
& "your account status." & vbCRLF _
& "Thank You, " & vbCRLF & vbCRLF & "Guy Campbell" & vbCRLF & "campbell_guy@hotmail.com"
Mailer.SendMail
Mailer.ClearRecipients
'Tell the Instructor that their Student's account has been Disabled
Mailer.Subject = "Your VB Student " & objRS("name") & " - Account Disabled!"
Mailer.addrecipient objRS("teacher"), objRS("teacheremail")
Mailer.bodytext = "Your Student: " & objRS("name") & " has had their Visual" & vbCrLf & "Basic account Disabled. Student Info:" & vbCRLF _
& vbCRLF _
& "Name: " & objRS("name") & vbCRLF _
& "eMail: " & objRS("email") & vbCRLF _
& "Password: " & objRS("password") & vbCRLF _
& "Class: " & objRS("classtype") & vbCRLF _
& "Current Status: Disabled" & vbCRLF & vbCRLF _
& "Important: All information is case sensitive." & vbCRLF & vbCRLF _
& "Note: They can NOT log into their Moorpark College--Visual Basic Account:" & vbCRLF _
& "http://cislab.moorpark.cc.ca.us/vbasic" & vbCRLF & vbCRLF _
& "Thank You, " & vbCRLF & vbCRLF & "Guy Campbell" & vbCRLF & "campbell_guy@hotmail.com"
Mailer.SendMail
Mailer.ClearRecipients
Set Mailer = Nothing
End If
End Select
objRS.MoveNext
Loop
'Update only if something was modified
If bUpdate = True Then
objRS.MoveFirst
objRS.Update
End If
'Process the Deleted records
objRS.MoveFirst
Do While Not objRS.EOF
For Each strEmail In Request.Form("Delete")
If objRS("email")= strEmail Then
'Delete the Account Record and remove it's directory structure
strPath = "c:/vbStudents/" & objRS("folder")
If objFSO.FolderExists(strPath) And Not IsNull(objRS("folder")) Then
objFSO.DeleteFolder strPath
Response.Write ("Account: " & objRS("name") & " and Folder: " & objRS("folder") & " deleted! ")
Else
Response.Write ("Account: " & objRS("name") & " deleted! ")
End If
objRS.Delete
Exit For
End If
Next
objRS.MoveNext
Loop
End If
%>
<%
Case "cancel changes"
Response.Redirect "admin.asp"
'Edit -- Use QueryString to find which record to edit
Case Else
strTmp = Request.QueryString("email")
sSQL = "SELECT * FROM Students WHERE email = '" & strTmp & "';"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open sSQL, objConn, adOpenDynamic, adLockOptimistic, adCmdText
'Can't edit a record that doesn't exist
If Not (objRS.EOF And objRS.BOF) Then
%>
<%
Else
' No Records Message
Response.Write("
No Edit Record Found!
")
End If
End Select
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
Set objFSO = Nothing
%>