Beispiel #1
0
function AddCustomFields()
{
    global $Email_Address, $Responder_ID;
    global $FirstName, $LastName, $DB_LinkID, $table_prefix;
    $infrespcustomfields = $table_prefix . 'InfResp_customfields';
    $CustomFieldsArray = GetFieldNames($infrespcustomfields);
    $CustomFieldsExist = FALSE;
    foreach ($CustomFieldsArray as $key => $value) {
        $blah = "cf_" . $value;
        $reqblah = trim($_REQUEST[$blah]);
        if (!empty($reqblah)) {
            $CustomFieldsArray[$value] = MakeSafe($reqblah);
            $CustomFieldsExist = TRUE;
        }
    }
    # Any custom fields?
    if ($CustomFieldsExist == TRUE) {
        #------------- Mandatory fields checking ------------------
        # if (empty($CustomFieldsArray['blah'])) { die('Error Message'); }
        #----------------------------------------------------------
        # --- Custom code ---
        $Fullname = "{$FirstName} {$LastName}";
        $CustomFieldsArray['full_name'] = $Fullname;
        # -------------------
        # Set static data
        $CustomFieldsArray['email_attached'] = $Email_Address;
        $CustomFieldsArray['resp_attached'] = $Responder_ID;
        unset($CustomFieldsArray['fieldID']);
        unset($CustomFieldsArray['user_attached']);
        # Delete any old data
        $query = "SELECT * FROM " . $infrespcustomfields . " WHERE email_attached = '{$Email_Address}' AND resp_attached = '{$Responder_ID}'";
        $result = mysql_query($query) or die("Invalid query: " . mysql_error());
        if (mysql_num_rows($result) > 0) {
            $query = "DELETE FROM " . $infrespcustomfields . " WHERE email_attached = '{$Email_Address}' AND resp_attached = '{$Responder_ID}'";
            $result = mysql_query($query) or die("Invalid query: " . mysql_error());
        }
        # Insert new data
        DB_Insert_Array($infrespcustomfields, $CustomFieldsArray);
    }
}
         print "</FORM>\n";
     } else {
         print "<br>\nNo custom data found.<br>\n";
     }
     # Print back button
     $return_action = "update";
     include 'templates/back_button.responders.php';
 } elseif ($action == "custom_stuff_csv") {
     $filename = time();
     header("Content-Disposition: attachment; filename={$filename}.csv");
     header("Content-Type: application/octet-stream");
     header("Pragma: no-cache");
     header("Expires: 0");
     $query = "SELECT * FROM " . $infrespcustomfields . " WHERE resp_attached = '{$Responder_ID}'";
     $DB_result = mysql_query($query) or die("Invalid query: " . mysql_error());
     $CustomFieldsArray = GetFieldNames($infrespcustomfields);
     $fieldstr = "";
     foreach ($CustomFieldsArray as $key => $value) {
         $fieldstr .= "{$value},";
     }
     $fieldstr = trim(trim($fieldstr), ",");
     print "{$fieldstr}\n";
     while ($DBarray = mysql_fetch_assoc($DB_result)) {
         $datastr = "";
         foreach ($CustomFieldsArray as $key => $value) {
             $datastr .= $DBarray[$value] . ",";
         }
         $datastr = trim(trim($datastr), ",");
         print "{$datastr}\n";
     }
 } elseif ($action == "do_POP3") {