I'm having trouble getting the data submitted on the forum to save to a text file. I have the adding record saving to the db but would also like it to save to a maillog.txt. Any ideas on how to go about this? Here is the form code phprunner generated:
<?php
ini_set("display_errors","1");
ini_set("display_startup_errors","1");
set_magic_quotes_runtime(0);
include("include/dbcommon.php");
include("include/mailbox_insert_queue_variables.php");
// check if logged in
if(!@$_SESSION["UserID"] || !CheckSecurity(@$SESSION["".$strTableName."_OwnerID"],"Add"))
{
$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];
header("Location: login.php?message=expired");
return;
}
$filename="";
$status="";
$message="";
$usermessage="";
$error_happened=false;
$readavalues=false;
$showKeys = array();
$showValues = array();
$showRawValues = array();
$showFields = array();
$showDetailKeys = array();
$IsSaved = false;
$HaveData = true;
if(@$_REQUEST["editType"]=="inline")
$inlineedit=ADD_INLINE;
elseif(@$_REQUEST["editType"]=="onthefly")
$inlineedit=ADD_ONTHEFLY;
else
$inlineedit=ADD_SIMPLE;
$keys=array();
if($inlineedit==ADD_INLINE)
$templatefile = "mailbox_insert_queue_inline_add.htm";
else
$templatefile = "mailbox_insert_queue_add.htm";
$id=postvalue("id");
//connect database
$conn = db_connect();
// Before Process event
if(function_exists("BeforeProcessAdd"))
BeforeProcessAdd($conn);
include('libs/xtempl.php');
$xt = new Xtempl();
// insert new record if we have to
if(@$_POST["a"]=="added")
{
$afilename_values=array();
$avalues=array();
$files_move=array();
// processing receiver_guid - start
if($inlineedit!=ADD_INLINE)
{
$value = postvalue("value_receiver_guid");
$type=postvalue("type_receiver_guid");
if (in_assoc_array("type_receiver_guid",$_POST) || in_assoc_array("value_receiver_guid",$_POST) || in_assoc_array("value_receiver_guid",$_FILES))
{
$value=prepare_for_db("receiver_guid",$value,$type);
}
else
$value=false;
if(!($value===false))
{
$avalues["receiver_guid"]=$value;
}
}
// processibng receiver_guid - end
// processing sender_guid - start
if($inlineedit!=ADD_INLINE)
{
$value = postvalue("value_sender_guid");
$type=postvalue("type_sender_guid");
if (in_assoc_array("type_sender_guid",$_POST) || in_assoc_array("value_sender_guid",$_POST) || in_assoc_array("value_sender_guid",$_FILES))
{
$value=prepare_for_db("sender_guid",$value,$type);
}
else
$value=false;
if(!($value===false))
{
$avalues["sender_guid"]=$value;
}
}
// processibng sender_guid - end
// processing subject - start
if($inlineedit!=ADD_INLINE)
{
$value = postvalue("value_subject");
$type=postvalue("type_subject");
if (in_assoc_array("type_subject",$_POST) || in_assoc_array("value_subject",$_POST) || in_assoc_array("value_subject",$_FILES))
{
$value=prepare_for_db("subject",$value,$type);
}
else
$value=false;
if(!($value===false))
{
$avalues["subject"]=$value;
}
}
// processibng subject - end
// processing body - start
if($inlineedit!=ADD_INLINE)
{
$value = postvalue("value_body");
$type=postvalue("type_body");
if (in_assoc_array("type_body",$_POST) || in_assoc_array("value_body",$_POST) || in_assoc_array("value_body",$_FILES))
{
$value=prepare_for_db("body",$value,$type);
}
else
$value=false;
if(!($value===false))
{
$avalues["body"]=$value;
}
}
// processibng body - end
// processing stationary - start
if($inlineedit!=ADD_INLINE)
{
$value = postvalue("value_stationary");
$type=postvalue("type_stationary");
if (in_assoc_array("type_stationary",$_POST) || in_assoc_array("value_stationary",$_POST) || in_assoc_array("value_stationary",$_FILES))
{
$value=prepare_for_db("stationary",$value,$type);
}
else
$value=false;
if(!($value===false))
{
$avalues["stationary"]=$value;
}
}
// processibng stationary - end
// processing money - start
if($inlineedit!=ADD_INLINE)
{
$value = postvalue("value_money");
$type=postvalue("type_money");
if (in_assoc_array("type_money",$_POST) || in_assoc_array("value_money",$_POST) || in_assoc_array("value_money",$_FILES))
{
$value=prepare_for_db("money",$value,$type);
}
else
$value=false;
if(!($value===false))
{
$avalues["money"]=$value;
}
}
// processibng money - end
// processing item_id - start
if($inlineedit!=ADD_INLINE)
{
$value = postvalue("value_item_id");
$type=postvalue("type_item_id");
if (in_assoc_array("type_item_id",$_POST) || in_assoc_array("value_item_id",$_POST) || in_assoc_array("value_item_id",$_FILES))
{
$value=prepare_for_db("item_id",$value,$type);
}
else
$value=false;
if(!($value===false))
{
$avalues["item_id"]=$value;
}
}
// processibng item_id - end
// processing item_stack - start
if($inlineedit!=ADD_INLINE)
{
$value = postvalue("value_item_stack");
$type=postvalue("type_item_stack");
if (in_assoc_array("type_item_stack",$_POST) || in_assoc_array("value_item_stack",$_POST) || in_assoc_array("value_item_stack",$_FILES))
{
$value=prepare_for_db("item_stack",$value,$type);
}
else
$value=false;
if(!($value===false))
{
$avalues["item_stack"]=$value;
}
}
// processibng item_stack - end
if($inlineedit==ADD_ONTHEFLY || true)
{
}
// add filenames to values
foreach($afilename_values as $akey=>$value)
$avalues[$akey]=$value;
// make SQL string
$strSQL = "insert into ".AddTableWrappers($strOriginalTableName)." ";
$strFields="(";
$strValues="(";
// before Add event
$retval = true;
if(function_exists("BeforeAdd"))
$retval=BeforeAdd($avalues,$usermessage,$inlineedit);
if($retval)
{
foreach($avalues as $akey=>$value)
{
$strFields.=AddFieldWrappers($akey).", ";
$strValues.=add_db_quotes($akey,$value).", ";
}
if(substr($strFields,-2)==", ")
$strFields=substr($strFields,0,strlen($strFields)-2);
if(substr($strValues,-2)==", ")
$strValues=substr($strValues,0,strlen($strValues)-2);
$strSQL.=$strFields.") values ".$strValues.")";
LogInfo($strSQL);
set_error_handler("add_error_handler");
db_exec($strSQL,$conn);
set_error_handler("error_handler");
// move files
if(!$error_happened)
{
foreach ($files_move as $file)
{
move_uploaded_file($file[0],$file[1]);
if(strtoupper(substr(PHP_OS,0,3))!="WIN")
@chmod($file[1],0777);
}
if ( $inlineedit==ADD_INLINE )
{
$status="ADDED";
$message=""."Record was added"."";
$IsSaved = true;
}
else
$message="<div class=message><<< "."Record was added"." >>></div>";
if($usermessage!="")
$message = $usermessage;
if($inlineedit==ADD_INLINE || $inlineedit==ADD_ONTHEFLY || function_exists("AfterAdd"))
{
$failed_inline_add = false;
if(array_key_exists("sender_guid",$avalues))
$keys["sender_guid"]=$avalues["sender_guid"];
else
$failed_inline_add = true;
if(array_key_exists("receiver_guid",$avalues))
$keys["receiver_guid"]=$avalues["receiver_guid"];
else
$failed_inline_add = true;
if(array_key_exists("subject",$avalues))
$keys["subject"]=$avalues["subject"];
else
$failed_inline_add = true;
if(array_key_exists("body",$avalues))
$keys["body"]=$avalues["body"];
else
$failed_inline_add = true;
if(array_key_exists("stationary",$avalues))
$keys["stationary"]=$avalues["stationary"];
else
$failed_inline_add = true;
if(array_key_exists("money",$avalues))
$keys["money"]=$avalues["money"];
else
$failed_inline_add = true;
if(array_key_exists("item_id",$avalues))
$keys["item_id"]=$avalues["item_id"];
else
$failed_inline_add = true;
if(array_key_exists("item_stack",$avalues))
$keys["item_stack"]=$avalues["item_stack"];
else
$failed_inline_add = true;
}
// after edit event
if(function_exists("AfterAdd"))
{
foreach($keys as $idx=>$val)
$avalues[$idx]=$val;
AfterAdd($avalues,$keys,$inlineedit);
}
}
}
else
{
$message = $usermessage;
$status="DECLINED";
$readavalues=true;
}
}
$defvalues=array();
// copy record
if(array_key_exists("copyid1",$_REQUEST) || array_key_exists("editid1",$_REQUEST))
{
$copykeys=array();
if(array_key_exists("copyid1",$_REQUEST))
{
$copykeys["sender_guid"]=postvalue("copyid1");
$copykeys["receiver_guid"]=postvalue("copyid2");
$copykeys["subject"]=postvalue("copyid3");
$copykeys["body"]=postvalue("copyid4");
$copykeys["stationary"]=postvalue("copyid5");
$copykeys["money"]=postvalue("copyid6");
$copykeys["item_id"]=postvalue("copyid7");
$copykeys["item_stack"]=postvalue("copyid8");
}
else
{
$copykeys["sender_guid"]=postvalue("editid1");
$copykeys["receiver_guid"]=postvalue("editid2");
$copykeys["subject"]=postvalue("editid3");
$copykeys["body"]=postvalue("editid4");
$copykeys["stationary"]=postvalue("editid5");
$copykeys["money"]=postvalue("editid6");
$copykeys["item_id"]=postvalue("editid7");
$copykeys["item_stack"]=postvalue("editid8");
}
$strWhere=KeyWhere($copykeys);
$strSQL = gSQLWhere($strWhere);
LogInfo($strSQL);
$rs=db_query($strSQL,$conn);
$defvalues=db_fetch_array($rs);
// clear key fields
$defvalues["sender_guid"]="";
$defvalues["receiver_guid"]="";
$defvalues["subject"]="";
$defvalues["body"]="";
$defvalues["stationary"]="";
$defvalues["money"]="";
$defvalues["item_id"]="";
$defvalues["item_stack"]="";
//call CopyOnLoad event
if(function_exists("CopyOnLoad"))
CopyOnLoad($defvalues,$strWhere);
}
else
{
$defvalues["stationary"]=61;
$defvalues["money"]=0;
$defvalues["item_id"]=0;
$defvalues["item_stack"]=0;
}
if($inlineedit==ADD_ONTHEFLY || true)
{
}
if($readavalues)
{
$defvalues["sender_guid"]=@$avalues["sender_guid"];
$defvalues["receiver_guid"]=@$avalues["receiver_guid"];
$defvalues["subject"]=@$avalues["subject"];
$defvalues["body"]=@$avalues["body"];
$defvalues["stationary"]=@$avalues["stationary"];
$defvalues["money"]=@$avalues["money"];
$defvalues["item_id"]=@$avalues["item_id"];
$defvalues["item_stack"]=@$avalues["itemstack"];
}
/*
foreach($defvalues as $key=>$value)
$smarty->assign("value".GoodFieldName($key),$value);
*/
$linkdata="";
$includes="";
$arr_includes=array();
$bodyonload="";
if ( $inlineedit!=ADD_INLINE )
{
// include files
// validation stuff
$onsubmit="";
$needvalidate=false;
if($inlineedit!=ADD_ONTHEFLY)
$includes.="<script language=\"JavaScript\" src=\"include/validate.js\"></script>\r\n";
if($inlineedit!=ADD_ONTHEFLY)
{
$includes.="<script language=\"JavaScript\">\r\n";
$includes.="var TEXT_FIELDS_REQUIRED='".addslashes("The Following fields are Required")."';\r\n";
$includes.="var TEXT_FIELDS_ZIPCODES='".addslashes("The Following fields must be valid Zipcodes")."';\r\n";
$includes.="var TEXT_FIELDS_EMAILS='".addslashes("The Following fields must be valid Emails")."';\r\n";
$includes.="var TEXT_FIELDS_NUMBERS='".addslashes("The Following fields must be Numbers")."';\r\n";
$includes.="var TEXT_FIELDS_CURRENCY='".addslashes("The Following fields must be currency")."';\r\n";
$includes.="var TEXT_FIELDS_PHONE='".addslashes("The Following fields must be Phone Numbers")."';\r\n";
$includes.="var TEXT_FIELDS_PASSWORD1='".addslashes("The Following fields must be valid Passwords")."';\r\n";
$includes.="var TEXT_FIELDS_PASSWORD2='".addslashes("should be at least 4 characters long")."';\r\n";
$includes.="var TEXT_FIELDS_PASSWORD3='".addslashes("Cannot be 'password'")."';\r\n";
$includes.="var TEXT_FIELDS_STATE='".addslashes("The Following fields must be State Names")."';\r\n";
$includes.="var TEXT_FIELDS_SSN='".addslashes("The Following fields must be Social Security Numbers")."';\r\n";
$includes.="var TEXT_FIELDS_DATE='".addslashes("The Following fields must be valid dates")."';\r\n";
$includes.="var TEXT_FIELDS_TIME='".addslashes("The Following fields must be valid time in 24-hours format")."';\r\n";
$includes.="var TEXT_FIELDS_CC='".addslashes("The Following fields must be valid Credit Card Numbers")."';\r\n";
$includes.="var TEXT_FIELDS_SSN='".addslashes("The Following fields must be Social Security Numbers")."';\r\n";
$includes.="</script>\r\n";
}
else
{
$includes.="var TEXT_INLINE_FIELD_REQUIRED='".jsreplace("Required field")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_ZIPCODE='".jsreplace("Field should be a valid zipcode")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_EMAIL='".jsreplace("Field should be a valid email address")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_NUMBER='".jsreplace("Field should be a valid number")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_CURRENCY='".jsreplace("Field should be a valid currency")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_PHONE='".jsreplace("Field should be a valid phone number")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_PASSWORD1='".jsreplace("Field can not be 'password'")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_PASSWORD2='".jsreplace("Field should be at least 4 characters long")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_STATE='".jsreplace("Field should be a valid US state name")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_SSN='".jsreplace("Field should be a valid Social Security Number")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_DATE='".jsreplace("Field should be a valid date")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_TIME='".jsreplace("Field should be a valid time in 24-hour format")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_CC='".jsreplace("Field should be a valid credit card number")."';\r\n";
$includes.="var TEXT_INLINE_FIELD_SSN='".jsreplace("Field should be a valid Social Security Number")."';\r\n";
}
$validatetype="";
$validatetype.="IsRequired";
if($validatetype)
{
$needvalidate=true;
if($inlineedit==ADD_ONTHEFLY)
$linkdata.="define_fly('value_senderguid".$id."','".$validatetype."');";
else
// $bodyonload.="define('value_sender_guid','".$validatetype."','');";
$bodyonload.="define('value_sender_guid','".$validatetype."','".jsreplace("")."');";
}
$validatetype="";
$validatetype.="IsRequired";
if($validatetype)
{
$needvalidate=true;
if($inlineedit==ADD_ONTHEFLY)
$linkdata.="define_fly('value_receiverguid".$id."','".$validatetype."');";
else
// $bodyonload.="define('value_receiver_guid','".$validatetype."','Receiver Guid');";
$bodyonload.="define('value_receiver_guid','".$validatetype."','".jsreplace("Receiver Guid")."');";
}
$validatetype="";
$validatetype.="IsRequired";
if($validatetype)
{
$needvalidate=true;
if($inlineedit==ADD_ONTHEFLY)
$linkdata.="define_fly('valuebody".$id."','".$validatetype."');";
else
// $bodyonload.="define('value_body','".$validatetype."','Body');";
$bodyonload.="define('value_body','".$validatetype."','".jsreplace("Body")."');";
}
$validatetype="";
if($validatetype)
{
$needvalidate=true;
if($inlineedit==ADD_ONTHEFLY)
$linkdata.="define_fly('valuestationary".$id."','".$validatetype."');";
else
// $bodyonload.="define('value_stationary','".$validatetype."','Stationary');";
$bodyonload.="define('value_stationary','".$validatetype."','".jsreplace("Stationary")."');";
}
$validatetype="IsNumeric";
$validatetype.="IsRequired";
if($validatetype)
{
$needvalidate=true;
if($inlineedit==ADD_ONTHEFLY)
$linkdata.="define_fly('valuemoney".$id."','".$validatetype."');";
else
// $bodyonload.="define('value_money','".$validatetype."','Money');";
$bodyonload.="define('value_money','".$validatetype."','".jsreplace("Money")."');";
}
$validatetype="";
$validatetype.="IsRequired";
if($validatetype)
{
$needvalidate=true;
if($inlineedit==ADD_ONTHEFLY)
$linkdata.="define_fly('value_itemid".$id."','".$validatetype."');";
else
// $bodyonload.="define('value_item_id','".$validatetype."','Item Id');";
$bodyonload.="define('value_item_id','".$validatetype."','".jsreplace("Item Id")."');";
}
$validatetype="";
if($validatetype)
{
$needvalidate=true;
if($inlineedit==ADD_ONTHEFLY)
$linkdata.="define_fly('value_itemstack".$id."','".$validatetype."');";
else
// $bodyonload.="define('value_item_stack','".$validatetype."','Item Stack');";
$bodyonload.="define('value_item_stack','".$validatetype."','".jsreplace("Item Stack")."');";
}
if($needvalidate)
{
if($inlineedit==ADD_ONTHEFLY)
$onsubmit="return validate_fly(this);";
else
$onsubmit="return validate();";
// $bodyonload="onload=\"".$bodyonload."\"";
}
if($inlineedit!=ADD_ONTHEFLY)
{
$includes.="<script language=\"JavaScript\" src=\"include/jquery.js\"></script>\r\n";
$includes.="<script language=\"JavaScript\" src=\"include/onthefly.js\"></script>\r\n";
if ($useAJAX)
$includes.="<script language=\"JavaScript\" src=\"include/ajaxsuggest.js\"></script>\r\n";
$includes.="<script language=\"JavaScript\" src=\"include/jsfunctions.js\"></script>\r\n";
}
if($inlineedit!=ADD_ONTHEFLY)
{
$includes.="<script language=\"JavaScript\">\r\n";
}
$includes.="var locale_dateformat = ".$locale_info["LOCALE_IDATE"].";\r\n".
"var locale_datedelimiter = \"".$locale_info["LOCALE_SDATE"]."\";\r\n".
"var bLoading=false;\r\n".
"var TEXT_PLEASE_SELECT='".addslashes("Please select")."';\r\n";
if ($useAJAX) {
$includes.="var SUGGEST_TABLE='mailbox_insert_queue_searchsuggest.php';\r\n";
}
if($inlineedit!=ADD_ONTHEFLY)
{
$includes.="</script>\r\n";
if ($useAJAX)
$includes.="<div id=\"search_suggest\"></div>\r\n";
}
$xt->assign("sender_guid_fieldblock",true);
$xt->assign("receiver_guid_fieldblock",true);
$xt->assign("subject_fieldblock",true);
$xt->assign("body_fieldblock",true);
$xt->assign("stationary_fieldblock",true);
$xt->assign("money_fieldblock",true);
$xt->assign("item_id_fieldblock",true);
$xt->assign("item_stack_fieldblock",true);
$body=array();
$formname="editform";
if($inlineedit!=ADD_ONTHEFLY)
{
if($onsubmit)
$onsubmit="onsubmit=\"".$onsubmit."\"";
$body["begin"]=$includes.
"<form name=\"editform\" encType=\"multipart/form-data\" method=\"post\" action=\"mailbox_insert_queue_add.php\" ".$onsubmit.">".
"<input type=hidden name=\"a\" value=\"added\">";
$xt->assign("backbutton_attrs","onclick=\"window.location.href='mailbox_insert_queue_list.php?a=return'\"");
$xt->assign("back_button",true);
}
else
{
$formname="editform".$id;
$body["begin"]="<form name=\"editform".$id."\" encType=\"multipart/form-data\" method=\"post\" action=\"mailbox_insert_queue_add.php\" ".$onsubmit." target=\"flyframe".$id."\">".
"<input type=hidden name=\"a\" value=\"added\">".
"<input type=hidden name=\"editType\" value=\"onthefly\">".
"<input type=hidden name=\"table\" value=\"".postvalue("table")."\">".
"<input type=hidden name=\"field\" value=\"".postvalue("field")."\">".
"<input type=hidden name=\"category\" value=\"".postvalue("category")."\">".
"<input type=hidden name=\"id\" value=\"".$id."\">";
$xt->assign("cancelbutton_attrs","onclick=\"RemoveFlyDiv('".$id."');\"");
// $xt->assign("cancelbutton_attrs","onclick=\"RemoveFlyDiv('".substr($id,3)."');\"");
$xt->assign("cancel_button",true);
}
$xt->assign("save_button",true);
$xt->assign("reset_button",true);
}
if($message)
{
$xt->assign("message_block",true);
$xt->assign("message",$message);
}
//$xt->assign("status",$status);
$readonlyfields=array();
// show readonly fields
$readonlyfields["stationary"] = htmlspecialchars(GetData($defvalues,"stationary", "Custom"));
$readonlyfields["item_stack"] = htmlspecialchars(GetData($defvalues,"item_stack", ""));
$record_id= postvalue("recordID");
if ($useAJAX)
{
if($inlineedit==ADD_ONTHEFLY)
$record_id=$id;
if($inlineedit!=ADD_INLINE)
{
$output = loadSelectContent("sender_guid",@$defvalues["receiver_guid"],@$defvalues["sender_guid"]);
$txt = "";
foreach( $output as $value )
{
$txt .= jsreplace($value)."\\n";
}
$linkdata .= "preloadSelectContent('".$txt."', 'value_sender_guid', '".jsreplace(@$defvalues["sender_guid"])."','".$record_id."');\r\n";
}
if ( $inlineedit==ADD_INLINE )
{
$linkdata=str_replace(array("&","<",">"),array("&","<",">"),$linkdata);
}
else
{
$linkdata.="SetToFirstControl('".$formname."');";
if($inlineedit==ADD_SIMPLE)
{
$linkdata = "<script type=\"text/javascript\">\r\n".
"$(document).ready(function(){ \r\n".
$linkdata.
"});</script>";
}
else
{
$linkdata=$includes."\r\n".$linkdata;
$includes="var s;";
foreach($arr_includes as $file)
{
$includes.="s = document.createElement('script');s.src = '".$file."';\r\n".
"document.getElementsByTagName('HEAD')[0].appendChild(s);\r\n";
}
$linkdata=$includes."\r\n".$linkdata;
if(!@$_POST["a"]=="added")
{
$linkdata = str_replace(array("\\","\r","\n"),array("\\\\","\\r","\\n"),$linkdata);
echo $linkdata;
echo "\n";
}
else if(@$_POST["a"]=="added" && ($error_happened || $status=="DECLINED"))
{
echo "<textarea id=\"data\">decli";
echo htmlspecialchars($linkdata);
echo "</textarea>";
}
}
}
}
else
{
// sender_guid - receiver_guid
$linkdata.="<script language=\"Javascript\">";
$linkdata.="bLoading = true;";
$linkdata.="SetSelection('value_receiver_guid', 'value_sender_guid', '".jsreplace(@$defvalues["receiver_guid"])."', '".jsreplace(@$defvalues["sender_guid"])."', arr_sender_guid);";
$linkdata.="bLoading = false;";
$linkdata.="</script>";
}
if($inlineedit!=ADD_ONTHEFLY)
{
$body["end"]="</form>".$linkdata.
"<script>".$bodyonload."</script>";
$xt->assign("body",$body);
$xt->assign("flybody",true);
}
else
{
$xt->assign("flybody",$body);
$xt->assign("body",true);
}
if(@$_POST["a"]=="added" && $inlineedit==ADD_ONTHEFLY && !$error_happened && $status!="DECLINED")
{
$LookupSQL="";
if($LookupSQL)
$LookupSQL.=" from ".AddTableWrappers($strOriginalTableName);
$data=0;
if(count($keys) && $LookupSQL)
{
$where=KeyWhere($keys);
$LookupSQL.=" where ".$where;
$rs=db_query($LookupSQL,$conn);
$data=db_fetch_numarray($rs);
}
if(!$data)
{
$data=array(@$avalues[$linkfield],@$avalues[$dispfield]);
}
echo "<textarea id=\"data\">";
echo "added";
print_inline_array($data);
echo "</textarea>";
exit();
}
/////////////////////////////////////////////////////////////
// prepare Edit Controls
/////////////////////////////////////////////////////////////
$control_sender_guid=array();
$control_sender_guid["func"]="xt_buildeditcontrol";
$control_sender_guid["params"] = array();
$control_sender_guid["params"]["field"]="sender_guid";
$control_sender_guid["params"]["value"]=@$defvalues["sender_guid"];
$control_sender_guid["params"]["id"]=$record_id;
if($inlineedit==ADD_INLINE)
$control_sender_guid["params"]["mode"]="inline_add";
else
$control_sender_guid["params"]["mode"]="add";
$xt->assignbyref("sender_guid_editcontrol",$control_sender_guid);
$control_receiver_guid=array();
$control_receiver_guid["func"]="xt_buildeditcontrol";
$control_receiver_guid["params"] = array();
$control_receiver_guid["params"]["field"]="receiver_guid";
$control_receiver_guid["params"]["value"]=@$defvalues["receiver_guid"];
$control_receiver_guid["params"]["id"]=$record_id;
if($inlineedit==ADD_INLINE)
$control_receiver_guid["params"]["mode"]="inline_add";
else
$control_receiver_guid["params"]["mode"]="add";
$xt->assignbyref("receiver_guid_editcontrol",$control_receiver_guid);
$control_subject=array();
$control_subject["func"]="xt_buildeditcontrol";
$control_subject["params"] = array();
$control_subject["params"]["field"]="subject";
$control_subject["params"]["value"]=@$defvalues["subject"];
$control_subject["params"]["id"]=$record_id;
if($inlineedit==ADD_INLINE)
$control_subject["params"]["mode"]="inline_add";
else
$control_subject["params"]["mode"]="add";
$xt->assignbyref("subject_editcontrol",$control_subject);
$control_body=array();
$control_body["func"]="xt_buildeditcontrol";
$control_body["params"] = array();
$control_body["params"]["field"]="body";
$control_body["params"]["value"]=@$defvalues["body"];
$control_body["params"]["id"]=$record_id;
if($inlineedit==ADD_INLINE)
$control_body["params"]["mode"]="inline_add";
else
$control_body["params"]["mode"]="add";
$xt->assignbyref("body_editcontrol",$control_body);
$control_stationary=array();
$control_stationary["func"]="xt_buildeditcontrol";
$control_stationary["params"] = array();
$control_stationary["params"]["field"]="stationary";
$control_stationary["params"]["value"]=@$defvalues["stationary"];
$control_stationary["params"]["id"]=$record_id;
if($inlineedit==ADD_INLINE)
$control_stationary["params"]["mode"]="inline_add";
else
$control_stationary["params"]["mode"]="add";
$xt->assignbyref("stationary_editcontrol",$control_stationary);
$control_money=array();
$control_money["func"]="xt_buildeditcontrol";
$control_money["params"] = array();
$control_money["params"]["field"]="money";
$control_money["params"]["value"]=@$defvalues["money"];
$control_money["params"]["id"]=$record_id;
if($inlineedit==ADD_INLINE)
$control_money["params"]["mode"]="inline_add";
else
$control_money["params"]["mode"]="add";
$xt->assignbyref("money_editcontrol",$control_money);
$control_item_id=array();
$control_item_id["func"]="xt_buildeditcontrol";
$control_item_id["params"] = array();
$control_item_id["params"]["field"]="item_id";
$control_item_id["params"]["value"]=@$defvalues["item_id"];
$control_item_id["params"]["id"]=$record_id;
if($inlineedit==ADD_INLINE)
$control_item_id["params"]["mode"]="inline_add";
else
$control_item_id["params"]["mode"]="add";
$xt->assignbyref("item_id_editcontrol",$control_item_id);
$control_item_stack=array();
$control_item_stack["func"]="xt_buildeditcontrol";
$control_item_stack["params"] = array();
$control_item_stack["params"]["field"]="item_stack";
$control_item_stack["params"]["value"]=@$defvalues["item_stack"];
$control_item_stack["params"]["id"]=$record_id;
if($inlineedit==ADD_INLINE)
$control_item_stack["params"]["mode"]="inline_add";
else
$control_item_stack["params"]["mode"]="add";
$xt->assignbyref("item_stack_editcontrol",$control_item_stack);
$xt->assign("style_block",true);
if(function_exists("BeforeShowAdd"))
BeforeShowAdd($xt,$templatefile);
if($inlineedit==ADD_ONTHEFLY)
{
$xt->load_template($templatefile);
$xt->display_loaded("style_block");
$xt->display_loaded("flybody");
}
else
$xt->display($templatefile);
function add_error_handler($errno, $errstr, $errfile, $errline)
{
global $readavalues, $message, $status, $inlineedit, $error_happened;
if ( $inlineedit!=ADD_SIMPLE )
$message=""."Record was NOT added".". ".$errstr;
else
$message="<div class=message><<< "."Record was NOT added"." >>>
".$errstr."</div>";
$readavalues=true;
$error_happened=true;
}
?>
This I'm adding to the before data is sent in events
global $_values;
$arr[]="".str_replace("%,%", ",", $_values['display_value_receiver_guid']).", ".str_replace("%,%", ",", $_values['value_sender_guid']).", ".str_replace("%,%", ",", $_values['value_subject']).", ".str_replace("%,%", ",", $_values['value_body']).", ".str_replace("%,%", ",", $_values['value_stationary']).", ".str_replace("%,%", ",", $_values['value_money']).", ".str_replace("%,%", ",", $_values['value_item_id']).", ".str_replace("%,%", ",", $_values['value_item_stack'])."
\n";
$file = "maillog.txt";
$dirs = explode("/",$file);
array_pop($dirs);
$cur_dir =".";
foreach($dirs as $dir){
$cur_dir = $cur_dir."/".$dir;
if (!@opendir($cur_dir)) { mkdir($cur_dir, 0777);}}
$fh = fopen($file, 'a+');
flock($fh,LOCK_EX);
foreach ($arr as $a) {fputs($fh,$a);}
fflush($fh);
flock($fh,LOCK_UN);
fclose($fh);
Any ideas? Nothing Seems to save to the file but ,'s (I'm new to php)
Thanks!