|
reSIProcate/repro
9694
|
00001 <?php 00002 require('reprofunctions.php'); 00003 dbgSquirt("============= Modify Resource ==============="); 00004 dbgSquirt("GET --" . dbgShowFile($_GET)); 00005 dbgSquirt("POST --" . dbgShowFile($_POST)); 00006 00007 $result = checkCookies($forceLogin,$error,FALSE); 00008 if (!($result) || $forceLogin) { 00009 // we got an error back that occurred while checkCookies was being run, 00010 // or authentication failed. Either way, bounce them back to the login screen 00011 header("Location: http://" . $_SERVER['HTTP_HOST'] . 00012 dirname($_SERVER['PHP_SELF']) . 00013 "/index.php?error=$error"); 00014 exit; 00015 } 00016 $username = $_COOKIE['user']; 00017 00018 $bounceURL = "Location: http://" . $_SERVER['HTTP_HOST'] . 00019 dirname($_SERVER['PHP_SELF']) . "/userhome.php?error="; 00020 00021 // make sure post variables have arrived. We should always get a resourceId, 00022 // name, and either an edit or a delete 00023 if (!(isset($_POST['resourceId']) && isset($_POST['aor']) && 00024 (isset($_POST['edit']) || isset($_POST['delete'])))) { 00025 header($bounceURL . "The information to modify a resource was not provided. Please enter the information and click Save. If this error reoccurs, contact an administrator."); 00026 exit; 00027 } 00028 00029 // check that resourceId is non-blank ... this shouldn't happen since this is 00030 // a system provided invisible field 00031 if (empty($_POST['resourceId']) || empty($_POST['aor'])) { 00032 header($bounceURL . "The resource to be modified was not specified. Please click one of the Add or Delete buttons. If you see this message again, please contact an administrator."); 00033 exit; 00034 } 00035 $resourceId = $_POST['resourceId']; 00036 $aor = $_POST['aor']; 00037 00038 //see if the operation is Edit or Delete 00039 if ("Delete" == $_POST['delete']) { 00040 // delete that resouce 00041 if (deleteResource($username,$resourceId)) { 00042 // success 00043 $title = "Resource Deleted"; 00044 $heading = "Resource Deleted"; 00045 $msg = "Successfully deleted the resource: <em>$aor</em>"; 00046 } else { 00047 // delete failed 00048 $title = "Error while deleting"; 00049 $heading = "Error while deleting"; 00050 $msg = "An error occurred while deleting the resource <em>$aor</em>. Please contact an administrator."; 00051 } 00052 } else if ("Edit" == $_POST['edit']) { 00053 // get displayed values 00054 $forwardType = $_POST['forwardType']; 00055 $forward = $_POST['forward']; 00056 $voicemail = $_POST['voicemail']; 00057 00058 // redirect to a new page for handling edits to an existing URL 00059 header("Location: http://" . $_SERVER['HTTP_HOST'] . 00060 dirname($_SERVER['PHP_SELF']) . "/editresource.php?resourceId=$resourceId&aor=$aor&forwardType=$forwardType&forward=$forward&voicemail=$voicemail"); 00061 exit; 00062 } else { 00063 // shouldn't get here ... this means no valid action was requested 00064 header($bounceURL . "Error while modifying resources. Please contact an administrator."); 00065 exit; 00066 } 00067 00068 ?> 00069 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 00070 00071 <!-- 00072 System: Repro 00073 File: modifyresource.php 00074 Purpose: Allows a user to edit or delete a resource that is attached to their account 00075 Author: S. Chanin 00076 --> 00077 <html> 00078 <head> 00079 <link rel="stylesheet" type="text/css" href="repro_style.css" /> 00080 <title><?php echo $title; ?></title> 00081 </head> 00082 00083 <body> 00084 <h1 class="title">Repro</h1> 00085 <h1><?php echo $heading; ?></h1> 00086 <hr /> 00087 <p><?php echo $msg; ?></p> 00088 <br /><hr /> 00089 <a href="userhome.php">Return to User Home</a><br /> 00090 <a href="logout.php">Logout</a><br /> 00091 00092 </body> 00093 </html>
1.7.5.1