관리-도구
편집 파일: destinationEdit.php
<?php include("../connect.php"); if ($_POST['Submit']) { if ($_POST['fileDelete'] == 'Y') { $sql = "update destination_email set upload_filename='' where sno=" . $_GET['id']; mysql_query($sql); } $dotpos = strpos($_POST['txtpagename'],".",0); $filename = substr($_POST['txtpagename'],0,$dotpos); if ($_POST['fileyesno'] == 'YES') { $dotposX = strpos($_FILES["file"]["name"],".",0); $filenameX = substr($_FILES["file"]["name"],0,$dotposX); $extension = substr($_FILES["file"]["name"],$dotposX,strlen($_FILES["file"]["name"])-$dotposX); move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $filename . $extension); $sql = "update destination_email set page_name='" . $_POST['txtpagename'] . "', destination_name='" . addslashes($_POST['txtdestinationname']) . "', email_subject='" . addslashes($_POST['txtsubject']) . "', email_body='" . addslashes($_POST['editor1']) . "', destination_email='" . $_POST['txtemailaddress'] . "', upload_filename='" . $filename . $extension . "' where sno=" . $_GET['id']; } else { $sql = "update destination_email set page_name='" . $_POST['txtpagename'] . "', destination_name='" . addslashes($_POST['txtdestinationname']) . "', email_subject='" . addslashes($_POST['txtsubject']) . "', email_body='" . addslashes($_POST['editor1']) . "', destination_email='" . $_POST['txtemailaddress'] . "' where sno=" . $_GET['id']; } mysql_query($sql); $to = 'anshulbhaigupta@yahoo.co.in'; $subject = 'Auto-Reply Email Modified for ' . $_GET['addtarget'] . ' - ' . $_POST['txtdestinationname']; $from = 'no-reply@finestweddingsites.com'; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: $from"; $message = 'Auto-Reply Email has been Modified for ' . $_GET['addtarget'] . ' - ' . $_POST['txtdestinationname']; $mail_sent = @mail($to,$subject,$message,$headers); header("location:destinationDone.php?action=Edit&addtarget=" . $_POST['addtarget']); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Edit Destination</title> <style type="text/css"> <!-- .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; } .style3 {font-size: 24px; font-family: Georgia, "Times New Roman", Times, serif;} body { background-image: url(../images/back.jpg); margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; }--> </style> <script language="javascript"> function validateForm() { if (document.getElementById('txtpagename').value == '') { alert("Please enter the name of the HTML or PHP page."); document.getElementById('txtpagename').focus(); return false; } if (document.getElementById('txtdestinationname').value == '') { alert("Please enter Destination Name."); document.getElementById('txtdestinationname').focus(); return false; } if (document.getElementById('file').value == '') document.getElementById('fileyesno').value = 'NO'; else document.getElementById('fileyesno').value = 'YES'; if (document.getElementById('txtsubject').value == '') { alert("Please enter the Subject of Email."); document.getElementById('txtsubject').focus(); return false; } if (document.getElementById('txtemailaddress').value == '') { alert("Email Address can not be left blank."); document.getElementById('txtemailaddress').focus(); return false; } if (echeck(document.getElementById('txtemailaddress').value)==false) { document.getElementById('txtemailaddress').focus() return false; } } function echeck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1) { alert("Invalid E-mail ID1") return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) { alert("Invalid E-mail ID2") return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) { alert("Invalid E-mail ID3") return false } // if (str.indexOf(at,(lat+1))!=-1) // { // alert("Invalid E-mail ID4") // return false // } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) { alert("Invalid E-mail ID5") return false } if (str.indexOf(dot,(lat+2))==-1) { alert("Invalid E-mail ID6") return false } // if (str.indexOf(" ")!=-1) // { // alert("Invalid E-mail ID7") // return false // } return true } function reloadpage() { var len = document.getElementById('cmbpagename').length; var i = 1; for (i = 1; i < len; i++) { if (document.getElementById('cmbpagename')[i].selected) window.location="destinationEdit.php?id=" + document.getElementById('cmbpagename')[i].value + "&addtarget=" + document.getElementById('addtarget').value; } } </script> <script type="text/javascript" src="ckeditor/ckeditor.js"></script> <script src="ckeditor/_samples/sample.js" type="text/javascript"></script> <link href="ckeditor/_samples/sample.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style4 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; } .style5 { font-family: Georgia, "Times New Roman", Times, serif; font-size: 14px; font-weight: bold; } --> </style> </head> <body> <form action="destinationEdit.php?id=<?php echo $_GET['id']; ?>" method="post" enctype="multipart/form-data" name="frmnewDestination" id="frmnewDestination" onsubmit="return validateForm()"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff"> <tr> <td><table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td height="50" colspan="2" align="center" valign="middle"><table width="95%" border="0" cellspacing="5" cellpadding="5"> <tr> <td><span class="style5">Fill out this form and save to Modify the Auto-Reply Email Message. </span></td> </tr> </table></td> </tr> <?php $sql = "select * from destination_email where destination_type='" . $_GET['addtarget'] . "' order by destination_name"; $res = mysql_query($sql); ?> <tr> <td align="right" valign="top" nowrap="nowrap"><span class="style1">Select HTML/PHP Page Name :</span></td> <td align="left" valign="top" bgcolor="#FFFFFF"><label> <input name="addtarget" type="hidden" id="addtarget" value="<?php echo $_GET['addtarget']; ?>" /> <select name="cmbpagename" id="cmbpagename" onchange="reloadpage()"> <option value="Select One" <?php if ($_GET['id'] == "") { ?> selected="selected" <?php } ?>>Select One</option> <?php while ($row = mysql_fetch_row($res)) {?> <option value="<?php echo $row[0]; ?>" <?php if ($row[0] == $_GET['id']) { ?> selected="selected" <?php } ?>><?php echo $row[2] . " [" . $row[1] . "]"; ?></option> <?php } ?> </select> </label></td> </tr> <?php if ($_GET['id'] == '') {?> <tr> <td colspan="2" align="right" valign="top" height="25px"> </td> </tr> <?php } else { $sql = "select * from destination_email where sno=" . $_GET['id']; $res = mysql_query($sql); $row=mysql_fetch_row($res); ?> <tr> <td width="15%" align="right" valign="top"><span class="style1">HTML/PHP Page Name : </span></td> <td width="85%" align="left" valign="top" bgcolor="#FFFFFF"><input name="txtpagename" type="text" id="txtpagename" value="<?php echo $row[1]; ?>" size="40" /> <span class="style4">(Ex: az_destination_agave.php)</span></td> </tr> <tr> <td align="right" valign="top" class="style1">Destination Name : </td> <td align="left" valign="top" bgcolor="#FFFFFF"><input name="txtdestinationname" type="text" id="txtdestinationname" value="<?php echo $row[2]; ?>" size="40" /> <span class="style4">(Ex: Agave Of Sedona)</span></td> </tr> <tr> <td align="right" valign="top" class="style1">Current Uploaded PDF File : </td> <td align="left" valign="top" bgcolor="#FFFFFF"><a target="_blank" href="<?php echo "uploads/" . $row[6]; ?>"><?php echo $row[6]; ?></a> <span class="style4"><input name="fileDelete" type="checkbox" id="fileDelete" value="Y" /> [Remove this file]</span></td> </tr> <tr> <td align="right" valign="top" class="style1">Upload PDF File : </td> <td align="left" valign="top" bgcolor="#FFFFFF"><input name="file" id="file" type="file" size="40" /> <input name="fileyesno" id="fileyesno" type="hidden" size="2" value="" /></td> </tr> <tr> <td align="right" valign="top" class="style1" nowrap="nowrap">From Email Address : </td> <td align="left" valign="top" bgcolor="#FFFFFF"><input name="txtemailaddress" type="text" id="txtemailaddress" value="<?php echo $row[5]; ?>" size="25" /></td> </tr> <tr> <td align="right" valign="top" class="style1">Email Subject : </td> <td align="left" valign="top" bgcolor="#FFFFFF"><input name="txtsubject" type="text" id="txtsubject" value="<?php echo $row[3]; ?>" size="40" /></td> </tr> <tr> <td height="26" colspan="2" align="left" valign="top" class="style1">Email body content :</td> </tr> <tr> <td colspan="2" align="left" valign="top" class="style1"><textarea cols="60" id="editor1" name="editor1" rows="6"><?php echo $row[4]; ?></textarea></td> </tr> <script type="text/javascript"> CKEDITOR.replace( 'editor1', { fullPage : true }); </script> <tr> <td height="41" colspan="2" align="center" valign="middle" bgcolor="#F0F0F0"><input type="submit" name="Submit" id="Submit" value=" Update Destination Information " /></td> </tr> <?php } ?> </table></td> </tr> </table> </form> </body> </html>