Location: PHPKode > scripts > FormMail Lite > form/admin.php
<?php
require("header.php");
?>
<SCRIPT TYPE="text/javascript" SRC="admin.js"></SCRIPT>
<?php
if($_POST["regist"]){
if($_POST['list'] == '') {
$preview1 .= 'Please enter Form Name.<br>';
$flag = 1;
}

$err = '';
if($preview1 != '') {
$err .= $preview1;
$flag = 1;
}
}
?>
<?php
if ($flag){
echo $err;
}
?>
Form Name<br>
<form action="" method="POST">
<input size="30" type="text" name="list"></input>
<input type="submit" name="regist" value="Add">
</form><br>1. 
First, please add the Form Name.
<?php
if (!$flag){
if($_POST["regist"]){
$FID=1;
$Log=file("log/form.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode(",",$Log[$i]);
if($line[0]>=$FID)
$FID=$line[0]+1;
}
$list = $_POST['list'];
$list = strip_tags($list);
$list = str_replace(",", "", $list);
$list=str_replace("\n","",$list);
$list=str_replace("\r","",$list);
$lines=array("$FID","$list","","","","","","","","","","","1");
$lines=implode(",",$lines);
$lines=$lines."\n";
$fp=fopen("log/form.cgi","a");
fputs($fp,$lines);	
fclose($fp);
}
}
?>
<?php
if($_POST["ed"] != ""){
$ed = $_POST["ed"];
$gid = $_POST["gid"];
$glist = $_POST["glist"];
if($glist[$ed] == '') {
$preview .= 'Please enter Form Name.<br>';
$flg = 1;
}
$er = '';
if($preview != '') {
$er .= $preview;
$flg = 1;
}
}
?>
<?php
if ($flg){
echo $er;
}
?>
<?php
if (!$flg){
if($_POST["ed"] != ""){
$Log=file("log/form.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode(",",$Log[$i]);
if($line[0]==$gid[$ed]){
$solid=$line[2];
$left=$line[3];
$right=$line[4];
$font=$line[5];
$to=$line[6];
$subject=$line[7];
$text=$line[8];
$sign=$line[9];
$complete=$line[10];
$remail=$line[11];
break;
}
}
$glist[$ed] = strip_tags($glist[$ed]);
$glist[$ed] = str_replace(",", "", $glist[$ed]);
$glist[$ed] = str_replace("\n","",$glist[$ed]);
$glist[$ed] = str_replace("\r","",$glist[$ed]);
$lines=array("".$gid[$ed]."","$glist[$ed]","$solid","$left","$right","$font","$to","$subject","$text","$sign","$complete","$remail","1");
$lines=implode(",",$lines);
$lines=$lines."\n";
$Log=file("log/form.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode(",",$Log[$i]);
if($line[0]==$gid[$ed]){
$Flg++;
array_splice($Log,$i,1,$lines);			
}
}
if($Flg){
$fp=fopen("log/form.cgi","w");
flock($fp, LOCK_EX);
foreach($Log as $line)fputs($fp,$line);	
fclose($fp); 
}
}
}
?>
<?php
if($_POST["del"] != ""){
$del = $_POST["del"];
$gid = $_POST["gid"];
$Log=file("log/form.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode(",",$Log[$i]);
if($line[0]==$gid[$del]){
array_splice($Log,$i,1);
} 
}
$fp=fopen("log/form.cgi","w");
flock($fp, LOCK_EX);
foreach($Log as $line)fputs($fp,$line);	
fclose($fp);

$Log=file("log/skin.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode(",",$Log[$i]);
if($line[1]==$gid[$del]){
array_splice($Log,$i,1);
} 
}
$fp=fopen("log/skin.cgi","w");
flock($fp, LOCK_EX);
foreach($Log as $line)fputs($fp,$line);	
fclose($fp);
}
?>
<?php
$Lo=@file("log/form.cgi");
if($Lo){
?>
<br/><br/><br/>
<form action="" method="post" name="form_list">
<input type="hidden" name="ed" value="">
<input type="hidden" name="del" value="">
<table width='400' border='0' cellspacing='1' bgcolor='#BBBBBB'>
<?php
for($i=0;$i<sizeof($Lo);$i++){
$line=explode(",",$Lo[$i]);
?>
<input type='hidden' name='gid[]' value='<?=$line[0]?>'>
<input type='hidden' name='mlist[]' value=<?=$line[1]?>>

<tr><td bgcolor='#ffffff' nowrap width='20%'>&nbsp;<?=$line[1]?></td><td align='center' bgcolor='#ffffff' nowrap width='15%'><input type=text size=30 name='glist[]' value='<?=$line[1]?>'></td><td align='center' bgcolor='#ffffff' nowrap width='1%'>&nbsp;<a href="javascript:document.form_list.submit();" onclick="document.form_list.ed.value='<?=$i?>';" STYLE="color: blue;">Edit</a>&nbsp;</td>

<td align='center' bgcolor='#ffffff' nowrap width='1%'>&nbsp;<a href="javascript:document.form_list.submit();" onclick="document.form_list.del.value='<?=$i?>';" STYLE="color: blue;">Del</a>&nbsp;</td>
<?php
}
?>
</table>
</form>
<?php
}
?>
<?php
if($_POST["reg"]){

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[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[1]==$_POST['fid'])&&($line[3]==0)){
$preview .= 'E-mail is already registered.<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["reg"]){
$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);
}
?>
<br>2. 
After adding the Form Name, please add the parts while checking the <a href="#display" STYLE="text-decoration:underline;">display</a>.<br>
<?php
if ($flag){
?>
<?=$err?><br>
<?php
}
?>
<form action="#button" method="POST" name="FORM">
<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?>" disabled style="background-color:#BEFFBE;"></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?>" disabled style="background-color:#BEFFBE;"></input><br>
Optionsi:separated by a colonj<br>
<input size="40" type="text" name="options" value="<?=$Options?>" disabled style="background-color:#BEFFBE;"></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="reg" value="Add">
</form>
<?php
if (!$flag){
if($_POST["reg"]){
if(!$Cols){ $Cols = 0; }
if(!$Rows){ $Rows = 0; }
if(!$H){ $H = 0; }
$Item=str_replace(",","",$Item);
$Options=str_replace(",","",$Options);
$Fault=str_replace(",","",$Fault);
$ID=1;
$Log=file("log/skin.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode(",",$Log[$i]);
if($line[0]>=$ID)
$ID=$line[0]+1;
}
$lines=array("$ID","$Fid","$Item","$Type","$Cols","$Rows","$Options","$Fault","$H","1");
$lines=implode(",",$lines);
$lines=$lines."\n";
$fp=fopen("log/skin.cgi","a");
fputs($fp,$lines);	
fclose($fp);
print "<a name=\"button\"></a>";
print "&nbsp;&nbsp;&nbsp;Added";
}
}
?>
<br><br>
<a name="display"></a>
3. Once completed, check the <a href="skin.php?fid=1" STYLE="text-decoration:underline;">Settings</a> and include the URL in the your website.
<?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: FormMail Lite