Location: PHPKode > scripts > Form Mail Lite > form/edit.php
<?php
require("header.php");
?>
<SCRIPT TYPE="text/javascript" SRC="admin.js"></SCRIPT>
<?php
if($_POST["edit"]){
$sid=$_POST['sid'];
$Log=file("log/skin.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode(",",$Log[$i]);
if($line[0]==$sid){
$Fid = $line[1];
$Item = $line[2];
$Type = $line[3];
$Cols = $line[4];
$Rows = $line[5];
$Options = $line[6];
$Fault = $line[7];
$H = $line[8];
break;
}
}
}
?>
<?php
if($_POST["ed"]){

if(($_POST["item"] == "action")||($_POST["item"] == "key")||($_POST["item"] == "ip")||($_POST["item"] == "host")||($_POST["item"] == "useragent")||($_POST["item"] == "referer")){
$preview .= 'This Name is invalid.<br>';
$flag = 1;
}
if($_POST["type"] != 0){
if($_POST["item"] == ""){
$preview .= 'Please enter Name.<br>';
$flag = 1;
}
else{
if(preg_match('/[^a-zA-Z0-9]/',$_POST["item"])) {
$preview .= 'This Name seems invalid.<br>';
$flag = 1;
}
$Log=@file("log/skin.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode(",",$Log[$i]);
if(($line[0]!=$_POST['sid'])&&($line[1]==$_POST['fid'])&&($line[2]==$_POST["item"])){
$preview .= 'This Name is already registered.<br>';
$flag = 1;
}
}
}
}
if($_POST["type"] == 0){
$Log=@file("log/skin.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode(",",$Log[$i]);
if(($line[0]!=$_POST['sid'])&&($line[1]==$_POST['fid'])&&($line[3]==0)){
$preview .= 'E-mail is already registered.<br>';
$flag = 1;
}
}
}
if(preg_match('/[^0-9]/',$_POST['sid'])) {
$preview .= 'ID seems invalid.<br>';
$flag = 1;
}
if(preg_match('/[^0-9]/',$_POST['fid'])) {
$preview .= 'Form ID seems invalid.<br>';
$flag = 1;
}
if(preg_match('/[^0-9]/',$_POST['type'])) {
$preview .= 'Type seems invalid.<br>';
$flag = 1;
}
if(preg_match('/[^0-9]/',$_POST['cols'])) {
$preview .= 'Cols seems invalid.<br>';
$flag = 1;
}
if(preg_match('/[^0-9]/',$_POST['rows'])) {
$preview .= 'Rows seems invalid.<br>';
$flag = 1;
}
if(preg_match('/[^0-9]/',$_POST['h'])) {
$preview .= 'Required seems invalid.<br>';
$flag = 1;
}
$err = '';
if($preview != '') {
$err .= $preview;
$flag = 1;
}
}
?>
<?php
if($_POST["ed"]){
$sid=$_POST['sid'];
$Fid=$_POST['fid'];
$Item=$_POST["item"];
$Type=$_POST["type"];
$Cols=$_POST["cols"];
$Rows=$_POST["rows"];
$Options=$_POST["options"];
$Fault=$_POST["fault"];
$H=$_POST["h"];

$Item = strip_tags($Item);
$Options = strip_tags($Options);
$Fault = strip_tags($Fault);
}
?>
<?php
if ($flag){
?>
<?=$err?><br>
<?php
}
?>
<form action="#button" method="POST" name="FORM">
<input type="hidden" name="sid" value="<?=$sid?>"></input>
<select name="fid">
<?php
$Log=@file("log/form.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode(",",$Log[$i]);
$Selected="";
if($line[0]==$Fid){
$Selected="selected";
}
?>
<option value="<?=$line[0]?>" <?=$Selected?>><?=$line[1]?></option>
<?php
}
?>
</select><br>
Name<br>
<input size="30" type="text" name="item" value="<?=$Item?>"></input><br>
Please enter [a-zA-Z0-9].<br>
Type<br>
<select name="type" onclick="chg()">
<?php
$a=array ( "E-mail", "text", "password", "radio", "checkbox", "select", "textarea", "hidden" );
foreach($a as $key => $val){
        $Selected="";
    if($key==$Type){
                $Selected="selected";
}
?>
<option value="<?=$key?>" <?=$Selected?>><?=$val?></option>
<?php
}
?>
</select><br>
Cols<br>
<input size="10" type="text" name="cols" value="<?=$Cols?>"></input><br>
Rows<br>
<input size="10" type="text" name="rows" value="<?=$Rows?>"></input><br>
Optionsi:separated by a colonj<br>
<input size="40" type="text" name="options" value="<?=$Options?>"></input><br>
Initial (Default) value<br>
<input size="30" type="text" name="fault" value="<?=$Fault?>"></input><br>
<?php
if($H==1){
$Checked="checked";
}
else{
$Checked="";
}
?>
<input type="checkbox" name="h" value="1" <?=$Checked?>>Required
<br><br>
<input type="submit" name="ed" value=" Update "></form>
<?php
if (!$flag){
if($_POST["ed"]){

if(!$Cols){ $Cols = 0; }
if(!$Rows){ $Rows = 0; }
if(!$H){ $H = 0; }
$Item=str_replace(",","",$Item);
$Options=str_replace(",","",$Options);
$Fault=str_replace(",","",$Fault);
$lines=array("$sid","$Fid","$Item","$Type","$Cols","$Rows","$Options","$Fault","$H","1");
$lines=implode(",",$lines);
$lines=$lines."\n";
$Log=file("log/skin.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode(",",$Log[$i]);
if($line[0]==$sid){
$Flg++;
array_splice($Log,$i,1,$lines);			
}
}
if($Flg){
$fp=fopen("log/skin.cgi","w");
flock($fp, LOCK_EX);
foreach($Log as $line)fputs($fp,$line);	
fclose($fp); 
}
print "<a name=\"button\"></a>";
print "&nbsp;&nbsp;&nbsp;Saved<br><br>";
}
}
?>
<br><br>
<?php
$formurl= str_replace(basename(__FILE__),"",'http://'.$_SERVER["HTTP_HOST"].$_SERVER[PHP_SELF])."forms/form.php";
$Log=@file("log/form.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode(",",$Log[$i]);
$ID=$line[0];
$Form=$line[1];
$sprint = sprintf("%.20s", $Form);
$length = mb_strlen($sprint);
if( $length >= 20 ){
$sprint .="..";
}
?>
<table width='370'>
<td>Preview &gt; <a href="forms/form.php?fid=<?=$ID?>" target="_blank" STYLE="color: #6A9C09;text-decoration:underline;"><?=$sprint?></a></td>
<td align="right"><a href="l.php?fid=<?=$ID?>" STYLE="text-decoration:underline;">Edit</a> - <a href="design.php?fid=<?=$ID?>" STYLE="text-decoration:underline;">Design</a> - <a href="skin.php?fid=<?=$ID?>" STYLE="text-decoration:underline;">Settings</a></td>
</table>
<textarea rows=2 cols=70 wrap="off">
<a href="<?=$formurl?>?fid=<?=$ID?>"><?=$Form?></a>
</textarea>
<?php
}
?>
<?php
require("footer.php");
?>
Return current item: Form Mail Lite