$field_row['template_tag'] = 'AD_ID'; break; case 'user_id': $field_row['template_tag'] = 'USER_ID'; break; case 'order_id': $field_row['template_tag'] = 'ORDER_ID'; break; case 'banner_id': $field_row['template_tag'] = 'BID'; break; } } if ($field_row['template_tag'] == '') { // need to fix the template tag! $field_row['template_tag'] = generate_template_tag(1); // update form field $sql = "UPDATE form_fields SET `template_tag`='" . $field_row['template_tag'] . "' WHERE form_id=1 AND field_id='" . $_REQUEST['field_id'] . "'"; mysql_query($sql); } if ($_REQUEST['admin_only'] == '') { $_REQUEST['admin_only'] = 'N'; } if ($_REQUEST['linked'] == '') { $_REQUEST['linked'] = 'N'; } $sql = "REPLACE INTO form_lists (`column_id`, `template_tag`, `field_id`, `sort_order`, `field_type`, `form_id`, `admin`, `truncate_length`, `linked`, `clean_format`, `is_bold`, `no_wrap`, `is_sortable`) VALUES ('" . $_REQUEST['column_id'] . "', '" . $field_row['template_tag'] . "', '" . $field_row['field_id'] . "', '" . $_REQUEST['sort_order'] . "', '" . $field_row['field_type'] . "', '1', '" . $_REQUEST['admin_only'] . "', '" . $_REQUEST['truncate_length'] . "', '" . $_REQUEST['linked'] . "', '" . $_REQUEST['clean_format'] . "', '" . $_REQUEST['is_bold'] . "', '" . $_REQUEST['no_wrap'] . "', '" . $_REQUEST['is_sortable'] . "')"; if ($error == '') { $result = mysql_query($sql) or die(mysql_error() . $sql); //echo $sql; if (CACHE_ENABLED == 'YES') {
function generate_template_tag($form_id) { // generate a random template tag. This help to fix older versions of the JB where some fields did not have a template tag... // generate a tag. $template_tag = ''; while (strlen($template_tag) < 4) { $template_tag .= chr(rand(97, 122)); } $unique = false; $sql = "select field_id from form_fields where template_tag='{$template_tag}' and form_id='{$form_id}' "; $result = mysql_query($sql) or die($sql . mysql_error()); if (mysql_num_rows($result) == 0) { $unique = true; } // check if it is unique if ($unique) { return $template_tag; } else { return generate_template_tag($form_id); // try again } }