Location: PHPKode > scripts > php-ftpmonitor > delegate.php
<?php

if(isset($_REQUEST['fname']) && isset($_REQUEST['furl']) && isset($_REQUEST['funame']) && isset($_REQUEST['fpass']) && isset($_REQUEST['fport']) && isset($_REQUEST['fcomment'])){
			$link = mysql_connect($db_server, $db_user, $db_pass)
   			or die("Could not connect to mysql server ".mysql_error());
			mysql_select_db($ftpmonitor_db) or die("Could not select database");
			$fid = isset($_REQUEST['record_id'])? $_REQUEST['record_id'] : "";
			$fname = $_REQUEST['fname'];
			$furl = $_REQUEST['furl'];
			$funame = $_REQUEST['funame'];
			$fpass = $_REQUEST['fpass'];
			$fport = $_REQUEST['fport'];
			$fcomment = $_REQUEST['fcomment'];
			$direct = isset($_REQUEST['direct'])? $_REQUEST['direct']:0;
			
			if(is_numeric($fid)){
					$query = "UPDATE $ftpmonitor_tbl SET ftp_name='$fname', ftp_url='$furl', ftp_username='$funame', ";
					$query.= "ftp_password='$fpass', ftp_port='$fport', ";
					$query.= "ftp_comment='$fcomment' WHERE ftpid='$fid'";
					$rs = mysql_query($query) or die("Cound Not Update selected server because:<br>".mysql_error());
					if(mysql_affected_rows()==1){
							header("location:index.php?section=ls&m=1&sname=$fname");					
							}
					$doaction = 'edit';
					$section = 'as';
					$update_status = 1;
					}
			else {
					$query ="INSERT INTO $ftpmonitor_tbl (ftp_name,ftp_url,ftp_username,ftp_password,ftp_port,ftp_comment) ";
					$query.="VALUES ('$fname','$furl','$funame','$fpass','$fport','$fcomment')";
					$rs = mysql_query($query) ;
					if(mysql_affected_rows()==1 && $direct==2){
							header("location:index.php?section=ls&m=2&sname=$fname");
							}
					$section = 'as';		
					$db_error = mysql_error($link);
					}
			
	
		}
		
if(isset($_REQUEST['section']) && array_key_exists($_REQUEST['section'],$header_array)){
	$section = $_REQUEST['section'];
	
	}
	
elseif(isset($_REQUEST['doaction']) && in_array($_REQUEST['doaction'],$action_array)) {
		$doaction = $_REQUEST['doaction'];
		switch($doaction){
			case "edit":
			$section = 'as';
			break;		
			
			default:	
			$section = 'ls';
			}
		}
elseif(isset($_REQUEST['ae_submit']) && in_array($_REQUEST['ae_submit'],$ae_submit_array)){
			$section = 'as';		
			}
elseif(!isset($section)){
	$section = $default_section;		
}
if(isset($_REQUEST['do'])){
			$where_clause="WHERE ";
			$section = 'ls';
			$s_string ='';
			
			while (list($key,$val) = each($_REQUEST)) { 
				$field_len = strlen($val);
				if($key!='page' && $key!='section'){
					$s_string.="&$key=$val";
					}
				if(in_array($key,$db_s_field) && $field_len > 0){
					switch($key){
						case 'ftp_port':			
						$where_clause.="$key = '$val' and ";
						break;
						default:
						$where_clause.="$key LIKE '%$val%' and ";	
						}
					}	
				}
			}
$header_image = $header_array[$section];
?>
Return current item: php-ftpmonitor