Hi!
The first database entry is found, is used.
In the code at the top (step 1.)), you can specify the database field.
1.) search in member.php:
if ($action == "uploadform") {
insert above:
if ($action == "autofill") {
//******* Start Config *******
$searchfield = "image_name"; //Which database field to be searched
//******* End Config *********
if ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) {
show_error_page($lang['no_permission']);
exit;
}
$txt_clickstream = "";
if ($cat_id && isset($cat_cache[$cat_id])) {
$txt_clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
}
$txt_clickstream .= $lang['user_upload'];
if(!empty($HTTP_POST_VARS['image_autofill'])){
$image_autofill = un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_autofill'])));
$image_autofill = addslashes($image_autofill);
$image_autofill = str_replace('*', '%', trim($image_autofill));
$additional_sql = "";
if (!empty($additional_image_fields)) {
foreach ($additional_image_fields as $key => $val) {
$additional_sql .= ", ".$key;
}
}
$sql = "SELECT image_id, cat_id, user_id, image_name, image_description, image_keywords, image_active".$additional_sql."
FROM ".IMAGES_TABLE."
WHERE image_active=1 AND cat_id = $cat_id AND $searchfield LIKE'$image_autofill'";
$image_row = $site_db->query_firstrow($sql);
$image_name = (isset($HTTP_POST_VARS['image_name'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_name']))) : $image_row['image_name'];
$image_description = (isset($HTTP_POST_VARS['image_description'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_description']))) : $image_row['image_description'];
$image_keywords = (isset($HTTP_POST_VARS['image_keywords'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_keywords']))) : $image_row['image_keywords'];
$site_template->register_vars(array(
"image_autofill" => ($image_row) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_autofill']))) : $lang['no_result'],
"cat_id" => $cat_id,
"cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name'], 2) : get_category_dropdown($cat_id),
"image_id" => $image_id,
"image_name" => format_text($image_name, 2),
"image_description" => format_text($image_description, 2),
"image_keywords" => format_text($image_keywords, 2),
"lang_auto_fill" => $lang['auto_fill'],
"lang_category" => $lang['category'],
"lang_user_upload" => $lang['user_upload'],
"lang_media_file" => $lang['media_file'],
"lang_thumb_file" => $lang['thumb_file'],
"lang_allowed_file_types" => $lang['allowed_mediatypes_desc'],
"allowed_media_types" => str_replace(",",", ",$config['allowed_mediatypes']),
"allowed_thumb_types" => "jpg, gif, png",
"lang_max_filesize" => $lang['max_filesize'],
"lang_max_imagewidth" => $lang['max_imagewidth'],
"lang_max_imageheight" => $lang['max_imageheight'],
"lang_image_name" => $lang['image_name'],
"lang_description" => $lang['description'],
"lang_keywords" => $lang['keywords_ext'],
"lang_allow_comments" => isset($lang['allow_comments']) ? $lang['allow_comments'] : "",
"lang_submit" => $lang['submit'],
"lang_reset" => $lang['reset'],
"lang_yes" => $lang['yes'],
"lang_no" => $lang['no'],
"lang_captcha" => $lang['captcha'],
"lang_captcha_desc" => $lang['captcha_desc'],
));
if (!empty($additional_image_fields)) {
$additional_field_array = array();
foreach ($additional_image_fields as $key => $val) {
if ($val[1] == "radio") {
$value = (isset($HTTP_POST_VARS[$key])) ? intval($HTTP_POST_VARS[$key]) : $image_row[$key];
if ($value == 1) {
$additional_field_array[$key.'_yes'] = " checked=\"checked\"";
$additional_field_array[$key.'_no'] = "";
}
else {
$additional_field_array[$key.'_yes'] = "";
$additional_field_array[$key.'_no'] = " checked=\"checked\"";
}
}
else {
$value = (isset($HTTP_POST_VARS[$key])) ? format_text(stripslashes(trim($HTTP_POST_VARS[$key]))) : $image_row[$key];
}
$additional_field_array[$key] = $value;
$additional_field_array['lang_'.$key] = $val[0];
}
if (!empty($additional_field_array)) {
$site_template->register_vars($additional_field_array);
}
}
$content = $site_template->parse_template("member_uploadform");
}
else{
$action = "uploadform";
}
}
1.1) search in section "$action == "uploadform"":
$site_template->register_vars(array(
"cat_id" => $cat_id,
and replace:
$site_template->register_vars(array(
"lang_auto_fill" => $lang['auto_fill'],
"cat_id" => $cat_id,
2.) search in your templates/member_uploadform.html:
<form method="post" action="{url_member}" enctype="multipart/form-data" onsubmit="uploadbutton.disabled=true;">
insert above:
<script type="text/javascript" language="JavaScript">
function loesche() {
window.document.autofill.image_autofill.value = '';
}
</script>
<form method="post" name="autofill" action="{url_member}" onsubmit="uploadbutton.disabled=true;">
<input type="hidden" name="action" value="autofill" >
{if cat_id}<input type="hidden" name="cat_id" value="{cat_id}" />{endif cat_id}
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td valign="top" class="head1">
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td class="row1"><b>{lang_auto_fill}</b></td>
<td class="row1"><input type="text" name="image_autofill" size="20" value="{image_autofill}" class="input" onfocus="loesche();"/><input type="submit" name="uploadbutton" value="{lang_submit}" class="button" /></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
3.) search in lang/your Lang/main.php "?>" and insert above:
(deutsch)
$lang['auto_fill'] = "Formular Automatisch Ausfüllen:<br><span class=\"smalltext\">Benutzen Sie * als Platzhalter.</span>";
$lang['no_result'] = "keinen Eintrag Gefunden";
(english)
$lang['auto_fill'] = "Upload Form Autofill:<br><span class=\"smalltext\">Use asterisks (*) as a wildcard for partial matches.</span>";
$lang['no_result'] = "no Entry";
mfg Andi