PDA

View Full Version : New listing_add.php which restricts posts to N



awddesign
02-16-2004, 03:17 AM
Hi

I have moved this here from

All credits to http://www.robertwisbey.com

http://www.open-realty.org/phpBB2/viewtopic.php?p=9344#9344

code//

I created a new row called allocation in the table default_UserDB with attibute of INT(11).

The following script replaces add_listing.php

Code:
<?php

global $action, $id, $lang, $conn, $config;
include("../include/common.php");
include("notifynewlisting.php");
loginCheck('registered_user');
include("$config[template_path]/admin_top.html");

//informs current total listing count
$sql = "SELECT ID FROM " . $config[table_prefix] . "listingsDB WHERE user_ID = $userID";
$recordSet = $conn->Execute($sql);
if ($recordSet === false)
{
log_error($sql);
}
while (!$recordSet->EOF)
{
$ID = $recordSet->fields[ID];
$recordSet->MoveNext();
}
$num_listings = $recordSet->RecordCount();

$sql2 = "SELECT allocation FROM " . $config[table_prefix] . "UserDB WHERE ID = $userID";
$recordSet2 = $conn->Execute($sql2);
if ($recordSet2 === false)
{
log_error($sql2);
}
while (!$recordSet2->EOF)
{
$allocation = $recordSet2->fields[allocation];
$recordSet2->MoveNext();
}
//$num_listings = $recordSet->RecordCount();

//$allocation = "SELECT allocation FROM " . $config[table_prefix] . "UserDB WHERE user_ID = $userID";

echo "You have currently added a total of $num_listings listings. Your maximum allocation is $allocation.";

//this sets the maximum number of allowable properties
//message is given if user has reached limit

if ($num_listings>=$allocation)
{
echo "<br>Sorry you have reached your maximum alloaction of properties.";
}

//if user has not reached their limit then the following form appears
else
{


if ($action == "create_new_listing")
{
// creates a new listing
if ($title == "")
{
echo "<p>$lang[admin_new_listing_enter_a_title]</p>";
echo "<FORM><INPUT TYPE=\"BUTTON\" VALUE=\"$lang[back_button_text]\" onClick=\"history.back()\"></FORM>";
} // end if

else
{
global $HTTP_POST_VARS, $pass_the_form, $userID;
$pass_the_form = validateForm(listingsFormElements);
if ($pass_the_form == "No")
{
// if we're not going to pass it, tell that they forgot to fill in one of the fields
echo "<p>$lang[required_fields_not_filled]</p>";
echo "<FORM><INPUT TYPE=\"BUTTON\" VALUE=\"$lang[back_button_text]\" onClick=\"history.back()\"></FORM>";
}

if ($pass_the_form == "Yes")
{
$title = make_db_safe($title);
$notes = make_db_safe($notes);
$mlsimport = make_db_safe($mlsimport);
// what the program should do if the form is valid

// generate a random number to enter in as the password (initially)
// we'll need to know the actual listing id to help with retrieving the listing.
// We'll be putting in a random number that we know the value of, we can easily
// retrieve the listing id in a few moments

$random_number = rand(1,10000);
// check to see if moderation is turned on...
if ($config[moderate_listings] == "no")
{
$set_active = "yes";
}
else
{
$set_active = "no";
}

// create the account with the random number as the password

$expiration_date = mktime (0,0,0,date("m") ,date("d")+$config[days_until_listings_expire],date("Y"));

$sql = "INSERT INTO " . $config[table_prefix] . "listingsDB (title, notes, user_ID, active, mlsimport, creation_date, last_modified, expiration) VALUES ($title, '$random_number', '$userID', '$set_active', $mlsimport, ".$conn->DBDate(time()).",".$conn->DBTimeStamp(time()).",".$conn->DBDate($expiration_date).")";

$recordSet = $conn->Execute($sql);
if ($recordSet === false)
{
log_error($sql);
}
// then we need to retrieve the new listing id
$sql = "SELECT id FROM " . $config[table_prefix] . "listingsDB WHERE notes = '$random_number'";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$recordSet = $conn->Execute($sql);
if ($recordSet === false)
{
log_error($sql);
}
while (!$recordSet->EOF)
{
$new_listing_id = $recordSet->fields[id]; // this is the new listing's ID number
$recordSet->MoveNext();
} // end while

// now it's time to replace the password
$sql = "UPDATE " . $config[table_prefix] . "listingsDB SET notes = $notes WHERE ID = '$new_listing_id'";
$recordSet = $conn->Execute($sql);
if ($recordSet === false)
{
log_error($sql);
}
// now that that's taken care of, it's time to insert all the rest
// of the variables into the database

$message = updateListingsData($new_listing_id, $userID);
if ($message == "success")
{
echo "<p>$lang[admin_new_listing_created], $user_name</p>";

if ($config[moderate_listings] == "yes")
{
// if moderation is turned on...
echo "<p>$lang[admin_new_listing_moderated]</p>";
}
echo "<p><a href=\"edit_my_listings.php?edit=$new_listing_id\">$lang[you_may_now_edit_your_listing]</p>";
log_action ("$lang[log_created_listing] $new_listing_id");
if ($config[email_notification_of_new_listings] == "yes")
{
// if the site admin should be notified when a new listing is added
global $config, $lang;
$message = $_SERVER[REMOTE_ADDR]. " -- ".date("F j, Y, g:i:s a")."\r\n\r\n$lang[admin_new_listing]:\r\n$config[baseurl]/admin/listings_edit.php?edit=$new_listing_id\r\n";
$header = "From: ".$config['admin_email']." <".$config['admin_email'].">\r\n";
$header .= "X-Sender: $config[admin_email]\r\n";
$header .= "Return-Path: $config[admin_email]\r\n";

mail("$config[admin_email]", "$lang[admin_new_listing]", $message, $header);
} // end if
notifyNewListing($new_listing_id);
} // end if
else
{
echo "<p>$lang[alert_site_admin]</p>";
} // end else
} // end $pass_the_form == "Yes"

} // end else


} // end if $action == "create_new_listing"
else
{
?>

<form action="<?php echo $php_self ?>" method="post">
<input type="hidden" name="action" value="create_new_listing">
<table border="<?php echo $style[form_border] ?>" cellspacing="<?php echo $style[form_cellspacing] ?>" cellpadding="<?php echo $style[form_cellpadding] ?>" width="<?php echo $style[admin_table_width] ?>" class="form_main">

<tr><td colspan="2" class="row_main"><h3><?php echo $lang[admin_menu_add_a_listing] ?></h3></td></tr>
<tr>
<td align="right" class="row_main"><b><?php echo $lang[admin_listings_editor_title] ?> <span class="required">*</span></b></td>
<td align="left" class="row_main"> <input type="text" name="title"></td>
</tr>
<tr>
<td align="right" class="row_main"><b><?php echo $lang[admin_listings_editor_notes] ?></b><br><div class="small">(<?php echo $lang[admin_listings_editor_notes_note] ?>)</div></td>
<td align="left" class="row_main"><textarea name="notes" cols="40" rows="6"></textarea></td>
</tr>

<?php
global $conn;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$sql = "SELECT id, field_type, field_name, field_caption, default_text, field_elements, rank, required from " . $config[table_prefix] . "listingsFormElements ORDER BY rank, field_name";
$recordSet = $conn->Execute($sql);
if ($recordSet === false)
{
log_error($sql);
}
while (!$recordSet->EOF)
{
$id = $recordSet->fields[ID];
$field_type = $recordSet->fields[field_type];
$field_name = $recordSet->fields[field_name];
$field_caption = $recordSet->fields[field_caption];
$default_text = $recordSet->fields[default_text];
$field_elements = $recordSet->fields[field_elements];
$rank = $recordSet->fields[rank];
$required = $recordSet->fields[required];

$field_type = make_db_unsafe($field_type);
$field_name = make_db_unsafe($field_name);
$field_caption = make_db_unsafe($field_caption);
$default_text = make_db_unsafe($default_text);
$field_elements = make_db_unsafe($field_elements);
$required = make_db_unsafe($required);

renderFormElement($field_type, $field_name, $field_caption, $default_text, $field_elements, $required);

$recordSet->MoveNext();
} // end while
renderFormElement("submit","","Submit", "", "", "");

?>


</form>
<tr><td colspan="2" align="center" class="row_main"><?php echo $lang[required_form_text] ?></td></tr>
</table>



<?php
}// end if

}



include("$config[template_path]/admin_bottom.html");
$conn->Close(); // close the db connection
?>


Then use MyPHP admin to change allocation value in the table default_UserDB of a certain user, to a value of your desire.

Login as the user you have modified the allocation value of, and add a property.

Cheers,

Rob.
http://www.robertwisbey.com
code// end


I have tested it on awdrentals 1.4+mods and awd cars1.4+mods
and it works a dream

thanks bobby

Al

Cybrac
05-02-2004, 03:47 PM
I took it a step more and i added a field in the /admin/user_edit.php file so that you can input a number and change the number of listing with out have to change it man. in the database.

I have moderator turned on so that you have it so that the listing need to be approved first and you have a client that you trust you can go in and make so that their listing don't have to be moderator.

I also set it up that if you put "unlimited" into the the number of listing add_listing will let your user list as many as they want. Another thing you may want to do is go into the database that have the number of listing in it and set it default to one or how many you want the default user to have.

I might also of added some "variables/text" in the english lang. file

If you try this and it does not work right post it here and will see what else need to be add or it you figure it out post here.

Jason


The add_listing.php


<?php
global $action, $id, $lang, $conn, $config;
include&#40;"../include/common.php"&#41;;
include&#40;"notifynewlisting.php"&#41;;
loginCheck&#40;'registered_user'&#41;;
include&#40;"$config&#91;template_path&#93;/admin_top.html"&#41;;

//informs current total listing count
$sql = "SELECT ID FROM " . $config&#91;table_prefix&#93; . "listingsDB WHERE user_ID = $userID";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41;
&#123;
log_error&#40;$sql&#41;;
&#125;
while &#40;!$recordSet->EOF&#41;
&#123;
$ID = $recordSet->fields&#91;ID&#93;;
$recordSet->MoveNext&#40;&#41;;
&#125;
$num_listings = $recordSet->RecordCount&#40;&#41;;

$sql2 = "SELECT allocation FROM " . $config&#91;table_prefix&#93; . "UserDB WHERE ID = $userID";
$recordSet2 = $conn->Execute&#40;$sql2&#41;;
if &#40;$recordSet2 === false&#41;
&#123;
log_error&#40;$sql2&#41;;
&#125;
while &#40;!$recordSet2->EOF&#41;
&#123;
$allocation = $recordSet2->fields&#91;allocation&#93;;
$recordSet2->MoveNext&#40;&#41;;
&#125;
//$num_listings = $recordSet->RecordCount&#40;&#41;;

//$allocation = "SELECT allocation FROM " . $config&#91;table_prefix&#93; . "UserDB WHERE user_ID = $userID";

echo "You have currently added a total of $num_listings listings. Your maximum allocation is $allocation.";

//this sets the maximum number of allowable properties
//message is given if user has reached limit

if &#40;$num_listings>=$allocation and $allocation != "unlimited"&#41;
&#123;
echo "<br>Sorry you have reached your maximum alloaction of properties.";
&#125;
//if user has not reached their limit then the following form appears
else
&#123;


if &#40;$action == "create_new_listing"&#41;
&#123;
// creates a new listing
if &#40;$title == ""&#41;
&#123;
echo "<p>$lang&#91;admin_new_listing_enter_a_title&#93;</p>";
echo "<FORM><INPUT TYPE=\"BUTTON\" VALUE=\"$lang&#91;back_button_text&#93;\" onClick=\"history.back&#40;&#41;\"></FORM>";
&#125; // end if

else
&#123;
global $HTTP_POST_VARS, $pass_the_form, $userID;
$pass_the_form = validateForm&#40;listingsFormElements&#41;;
if &#40;$pass_the_form == "No"&#41;
&#123;
// if we're not going to pass it, tell that they forgot to fill in one of the fields
echo "<p>$lang&#91;required_fields_not_filled&#93;</p>";
echo "<FORM><INPUT TYPE=\"BUTTON\" VALUE=\"$lang&#91;back_button_text&#93;\" onClick=\"history.back&#40;&#41;\"></FORM>";
&#125;

if &#40;$pass_the_form == "Yes"&#41;
&#123;
$title = make_db_safe&#40;$title&#41;;
$notes = make_db_safe&#40;$notes&#41;;
$mlsimport = make_db_safe&#40;$mlsimport&#41;;
// what the program should do if the form is valid

// generate a random number to enter in as the password &#40;initially&#41;
// we'll need to know the actual listing id to help with retrieving the listing.
// We'll be putting in a random number that we know the value of, we can easily
// retrieve the listing id in a few moments

$random_number = rand&#40;1,10000&#41;;
// seeing if user can list items with out being moderated

$sql3 = "SELECT canModerate_Listings_Show FROM " . $config&#91;table_prefix&#93; . "UserDB WHERE ID = $userID";
$recordSet3 = $conn->Execute&#40;$sql3&#41;;
if &#40;$recordSet3 === false&#41;
&#123;
log_error&#40;$sql3&#41;;
&#125;
while &#40;!$recordSet3->EOF&#41;
&#123;
$canModerate_Listings_Show = $recordSet3->fields&#91;canModerate_Listings_Show&#93;;
$recordSet3->MoveNext&#40;&#41;;
&#125;

// check to see if moderation is turned on...
if &#40;$config&#91;moderate_listings&#93; == "no"&#41;
&#123;
$set_active = "yes";
&#125;
else
&#123;
if &#40;$canModerate_Listings_Show == "yes"&#41;
&#123;
$set_active = "yes";
&#125;
else
&#123;
$set_active = "no";
&#125; &#125;

// create the account with the random number as the password

$expiration_date = mktime &#40;0,0,0,date&#40;"m"&#41; ,date&#40;"d"&#41;+$config&#91;days_until_listings_expire&#93;,date&#40;"Y"&#41;&#41;;

$sql = "INSERT INTO " . $config&#91;table_prefix&#93; . "listingsDB &#40;title, notes, user_ID, active, mlsimport, creation_date, last_modified, expiration&#41; VALUES &#40;$title, '$random_number', '$userID', '$set_active', $mlsimport, ".$conn->DBDate&#40;time&#40;&#41;&#41;.",".$conn->DBTimeStamp&#40;time&#40;&#41;&#41;.",".$conn->DBDate&#40;$expiration_date&#41;."&#41;";

$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41;
&#123;
log_error&#40;$sql&#41;;
&#125;
// then we need to retrieve the new listing id
$sql = "SELECT id FROM " . $config&#91;table_prefix&#93; . "listingsDB WHERE notes = '$random_number'";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41;
&#123;
log_error&#40;$sql&#41;;
&#125;
while &#40;!$recordSet->EOF&#41;
&#123;
$new_listing_id = $recordSet->fields&#91;id&#93;; // this is the new listing's ID number
$recordSet->MoveNext&#40;&#41;;
&#125; // end while

// now it's time to replace the password
$sql = "UPDATE " . $config&#91;table_prefix&#93; . "listingsDB SET notes = $notes WHERE ID = '$new_listing_id'";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41;
&#123;
log_error&#40;$sql&#41;;
&#125;
// now that that's taken care of, it's time to insert all the rest
// of the variables into the database

$message = updateListingsData&#40;$new_listing_id, $userID&#41;;
if &#40;$message == "success"&#41;
&#123;
echo "<p>$lang&#91;admin_new_listing_created&#93;, $user_name</p>";

if &#40;$config&#91;moderate_listings&#93; == "yes"&#41;
&#123;
// if moderation is turned on...
echo "<p>$lang&#91;admin_new_listing_moderated&#93;</p>";
&#125;
echo "<p><a href=\"edit_my_listings.php?edit=$new_listing_id\">$lang&#91;you_may_now_edit_your_listing&#93;</p>";
log_action &#40;"$lang&#91;log_created_listing&#93; $new_listing_id"&#41;;
if &#40;$config&#91;email_notification_of_new_listings&#93; == "yes"&#41;
&#123;
// if the site admin should be notified when a new listing is added
global $config, $lang;
$message = $_SERVER&#91;REMOTE_ADDR&#93;. " -- ".date&#40;"F j, Y, g&#58;i&#58;s a"&#41;."\r\n\r\n$lang&#91;admin_new_listing&#93;&#58;\r\n$config&#91;baseu rl&#93;/admin/listings_edit.php?edit=$new_listing_id\r\n";
$header = "From&#58; ".$config&#91;'admin_email'&#93;." <".$config&#91;'admin_email'&#93;.">\r\n";
$header .= "X-Sender&#58; $config&#91;admin_email&#93;\r\n";
$header .= "Return-Path&#58; $config&#91;admin_email&#93;\r\n";

mail&#40;"$config&#91;admin_email&#93;", "$lang&#91;admin_new_listing&#93;", $message, $header&#41;;
&#125; // end if
notifyNewListing&#40;$new_listing_id&#41;;
&#125; // end if
else
&#123;
echo "<p>$lang&#91;alert_site_admin&#93;</p>";
&#125; // end else
&#125; // end $pass_the_form == "Yes"

&#125; // end else


&#125; // end if $action == "create_new_listing"
else
&#123;
?>

<form action="<?php echo $php_self ?>" method="post">
<input type="hidden" name="action" value="create_new_listing">
<table border="<?php echo $style&#91;form_border&#93; ?>" cellspacing="<?php echo $style&#91;form_cellspacing&#93; ?>" cellpadding="<?php echo $style&#91;form_cellpadding&#93; ?>" width="<?php echo $style&#91;admin_table_width&#93; ?>" class="form_main">

<tr><td colspan="2" class="row_main"><h3><?php echo $lang&#91;admin_menu_add_a_listing&#93; ?></h3></td></tr>
<tr>
<td align="right" class="row_main"><b><?php echo $lang&#91;admin_listings_editor_title&#93; ?> <span class="required">*</span></b></td>
<td align="left" class="row_main"> <input type="text" name="title"></td>
</tr>
<tr>
<td align="right" class="row_main"><b><?php echo $lang&#91;admin_listings_editor_notes&#93; ?></b><br><div class="small">&#40;<?php echo $lang&#91;admin_listings_editor_notes_note&#93; ?>&#41;</div></td>
<td align="left" class="row_main"><textarea name="notes" cols="40" rows="6"></textarea></td>
</tr>

<?php
global $conn;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$sql = "SELECT id, field_type, field_name, field_caption, default_text, field_elements, rank, required from " . $config&#91;table_prefix&#93; . "listingsFormElements ORDER BY rank, field_name";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41;
&#123;
log_error&#40;$sql&#41;;
&#125;
while &#40;!$recordSet->EOF&#41;
&#123;
$id = $recordSet->fields&#91;ID&#93;;
$field_type = $recordSet->fields&#91;field_type&#93;;
$field_name = $recordSet->fields&#91;field_name&#93;;
$field_caption = $recordSet->fields&#91;field_caption&#93;;
$default_text = $recordSet->fields&#91;default_text&#93;;
$field_elements = $recordSet->fields&#91;field_elements&#93;;
$rank = $recordSet->fields&#91;rank&#93;;
$required = $recordSet->fields&#91;required&#93;;

$field_type = make_db_unsafe&#40;$field_type&#41;;
$field_name = make_db_unsafe&#40;$field_name&#41;;
$field_caption = make_db_unsafe&#40;$field_caption&#41;;
$default_text = make_db_unsafe&#40;$default_text&#41;;
$field_elements = make_db_unsafe&#40;$field_elements&#41;;
$required = make_db_unsafe&#40;$required&#41;;

renderFormElement&#40;$field_type, $field_name, $field_caption, $default_text, $field_elements, $required&#41;;

$recordSet->MoveNext&#40;&#41;;
&#125; // end while
renderFormElement&#40;"submit","","Submit", "", "", ""&#41;;

?>


</form>
<tr><td colspan="2" align="center" class="row_main"><?php echo $lang&#91;required_form_text&#93; ?></td></tr>
</table>



<?php
&#125;// end if

&#125;



include&#40;"$config&#91;template_path&#93;/admin_bottom.html"&#41;;
$conn->Close&#40;&#41;; // close the db connection
?>

And i also changed User_edit.php


<?php


include&#40;"../include/common.php"&#41;;
loginCheck&#40;'Admin'&#41;;

global $action, $id, $cur_page, $edit, $lang, $conn, $config;

include&#40;"$config&#91;template_path&#93;/admin_top.html"&#41;;


if &#40;$delete != ""&#41;
&#123;
global $conn;
$sql_delete = make_db_safe&#40;$delete&#41;;

// delete the user
$sql = "DELETE FROM " . $config&#91;table_prefix&#93; . "UserDB WHERE ID = $sql_delete";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;

// delete all the elements associated with the user
$sql = "DELETE FROM " . $config&#91;table_prefix&#93; . "UserDBElements WHERE user_id = $sql_delete";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;

// delete all the listings associated with a user
$sql = "DELETE FROM " . $config&#91;table_prefix&#93; . "listingsDB WHERE &#40;user_ID = $sql_delete&#41;";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;

// delete all the elements associated with a user
$sql = "DELETE FROM " . $config&#91;table_prefix&#93; . "listingsDBElements WHERE &#40;user_id = $sql_delete&#41;";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;

// delete all the favorites associated with a user
$sql = "DELETE FROM " . $config&#91;table_prefix&#93; . "userFavoriteListings WHERE &#40;user_id = $sql_delete&#41;";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;

// delete all the saved searches associated with a user
$sql = "DELETE FROM " . $config&#91;table_prefix&#93; . "userSavedSearches WHERE &#40;user_id = $sql_delete&#41;";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;

// now get all the images associated with a user's listings
$sql = "SELECT file_name, thumb_file_name FROM " . $config&#91;table_prefix&#93; . "listingsImages WHERE &#40;user_id = $sql_delete&#41;";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;

// so, you've got 'em... it's time to unlink those bad boys...
while &#40;!$recordSet->EOF&#41;
&#123;
$thumb_file_name = make_db_unsafe &#40;$recordSet->fields&#91;thumb_file_name&#93;&#41;;
$file_name = make_db_unsafe &#40;$recordSet->fields&#91;file_name&#93;&#41;;
// get rid of those darned things...
if &#40;!unlink&#40;"$config&#91;listings_upload_path&#93;/$file_name"&#41;&#41; die&#40;"$lang&#91;alert_site_admin&#93;"&#41;;
if &#40;$file_name != $thumb_file_name&#41;
&#123;
if &#40;!unlink&#40;"$config&#91;listings_upload_path&#93;/$thumb_file_name"&#41;&#41; die&#40;"$lang&#91;alert_site_admin&#93;"&#41;;
&#125;
$recordSet->MoveNext&#40;&#41;;
&#125;

// it's time to do the same for all the images associated with the user himself
$sql = "SELECT file_name, thumb_file_name FROM " . $config&#91;table_prefix&#93; . "userImages WHERE &#40;user_id = $sql_delete&#41;";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;

while &#40;!$recordSet->EOF&#41;
&#123;
$thumb_file_name = make_db_unsafe &#40;$recordSet->fields&#91;thumb_file_name&#93;&#41;;
$file_name = make_db_unsafe &#40;$recordSet->fields&#91;file_name&#93;&#41;;
// get rid of those darned things...
if &#40;!unlink&#40;"$config&#91;user_upload_path&#93;/$file_name"&#41;&#41; die&#40;"$lang&#91;alert_site_admin&#93;"&#41;;
if &#40;$file_name != $thumb_file_name&#41;
&#123;
if &#40;!unlink&#40;"$config&#91;user_upload_path&#93;/$thumb_file_name"&#41;&#41; die&#40;"$lang&#91;alert_site_admin&#93;"&#41;;
&#125;
$recordSet->MoveNext&#40;&#41;;
&#125;
// delete all the saved images associated with a user from userImages
$sql = "DELETE FROM " . $config&#91;table_prefix&#93; . "userImages WHERE &#40;user_id = $sql_delete&#41;";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;
// that's it... we're done. &#40;More complicated than one might think, eh?&#41;

log_action &#40;"$lang&#91;log_deleted_user&#93;&#58; $delete"&#41;;
echo "<p>$lang&#91;user_editor_user_number&#93; '$delete' $lang&#91;has_been_deleted&#93;</p>";

&#125;

if &#40;$action == "update_user"&#41;
&#123;
if &#40;$user_email == ""&#41;
&#123;
echo "<p>$lang&#91;user_editor_need_email_address&#93;</p>";
echo "<FORM><INPUT TYPE=\"BUTTON\" VALUE=\"$lang&#91;back_button_text&#93;\" onClick=\"history.back&#40;&#41;\"></FORM>";
&#125; // end else

if &#40;$user_allocation == ""&#41;
&#123;
echo "<p>$lang&#91;user_editor_need_alloction&#93;</p>";
echo "<FORM><INPUT TYPE=\"BUTTON\" VALUE=\"$lang&#91;back_button_text&#93;\" onClick=\"history.back&#40;&#41;\"></FORM>";
&#125; // end else
else
&#123;
global $pass_the_form;
if &#40;$edit_isAgent == "yes"&#41;
$pass_the_form = validateForm&#40;agentFormElements&#41;;
else
$pass_the_form = validateForm&#40;memberFormElements&#41;;

if &#40;$pass_the_form == "No"&#41;
&#123;
// if we're not going to pass it, tell that they forgot to fill in one of the fields
echo "<p>$lang&#91;required_fields_not_filled&#93;</p>";
&#125;

if &#40;$pass_the_form == "Yes"&#41;
&#123;
$sql_edit = make_db_safe&#40;$edit&#41;;
$sql_user_email = make_db_safe&#40;$user_email&#41;;
$sql_user_allocation = make_db_safe&#40;$user_allocation&#41;;
if &#40;$edit_user_pass != ""&#41;
&#123;
$md5_user_pass = md5&#40;$edit_user_pass&#41;;
$sql_user_pass = make_db_safe&#40;$md5_user_pass&#41;;
$sql = "UPDATE " . $config&#91;table_prefix&#93; . "UserDB SET emailAddress = $sql_user_email, user_password = $sql_user_pass, last_modified = ".$conn->DBTimeStamp&#40;time&#40;&#41;&#41;." WHERE ID = $sql_edit";
$sql2 = "UPDATE " . $config&#91;table_prefix&#93; . "UserDB SET allocation = $sql_user_allocation, user_password = $sql_user_pass, last_modified = ".$conn->DBTimeStamp&#40;time&#40;&#41;&#41;." WHERE ID = $sql_edit";

&#125;
else
&#123;
$sql = "UPDATE " . $config&#91;table_prefix&#93; . "UserDB SET emailAddress = $sql_user_email, last_modified = ".$conn->DBTimeStamp&#40;time&#40;&#41;&#41;." WHERE ID = $sql_edit";
$sql2 = "UPDATE " . $config&#91;table_prefix&#93; . "UserDB SET allocation = $sql_user_allocation, last_modified = ".$conn->DBTimeStamp&#40;time&#40;&#41;&#41;." WHERE ID = $sql_edit";

&#125;
$recordSet = $conn->Execute&#40;$sql&#41;;
$recordSet = $conn->Execute&#40;$sql2&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;
if &#40;$admin_privs == "yes"&#41;
&#123;
$sql_edit_active = make_db_safe&#40;$edit_active&#41;;
$sql_edit_isAgent = make_db_safe&#40;$edit_isAgent&#41;;
$sql_edit_isAdmin = make_db_safe&#40;$edit_isAdmin&#41;;
$sql_edit_canEditForms = make_db_safe&#40;$edit_canEditForms&#41;;
$sql_edit_canFeatureListings = make_db_safe&#40;$edit_canFeatureListings&#41;;
$sql_edit_canViewLogs = make_db_safe&#40;$edit_canViewLogs&#41;;
$sql_edit_canModerate = make_db_safe&#40;$edit_canModerate&#41;;
$sql_edit_canModerate_Listings_Show = make_db_safe&#40;$edit_canModerate_Listings_Show&#41;;
$sql = "UPDATE " . $config&#91;table_prefix&#93; . "UserDB SET isAdmin = $sql_edit_isAdmin,";
$sql .= "active = $sql_edit_active,";
$sql .= "isAgent = $sql_edit_isAgent,";
$sql .= "canEditForms = $sql_edit_canEditForms,";
$sql .= "canFeatureListings = $sql_edit_canFeatureListings,";
$sql .= "canViewLogs = $sql_edit_canViewLogs,";
$sql .= "canModerate = $sql_edit_canModerate";
$sql .= "canModerate_Listings_Show = $sql_edit_canModerate_Listings_Show";
$sql .= "WHERE ID = $sql_edit";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;
&#125; // end &#40;$admin_privs == "yes"&#41;

$message = updateUserData&#40;$userID&#41;;
if &#40;$message == "success"&#41;
&#123;
log_action &#40;"$lang&#91;log_updated_user&#93;&#58; $edit"&#41;;
echo "<p>$lang&#91;user_editor_user_number&#93; $edit $lang&#91;has_been_updated&#93; </p>";
&#125; // end if
else
&#123;
echo "<p>$lang&#91;alert_site_admin&#93;</p>";
&#125; // end else
&#125; // end if $pass_the_form == "Yes"

&#125; // end else


&#125; // end if $action == "update_user"

if &#40;$edit == ""&#41;
&#123;
echo "<h3>$lang&#91;user_editor_edit_users&#93;</h3>";
// find the number of users
$sql="SELECT * FROM " . $config&#91;table_prefix&#93; . "UserDB WHERE isAgent = '$edit_isAgent' ORDER BY id";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;
$num_rows = $recordSet->RecordCount&#40;&#41;;

next_prev&#40;$num_rows, $cur_page, "edit_isAgent=$edit_isAgent&amp;"&#41;; // put in the next/previous stuff

// build the string to select a certain number of users per page
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$limit_str = $cur_page * $config&#91;listings_per_page&#93;;
$recordSet = $conn->SelectLimit&#40;$sql, $config&#91;listings_per_page&#93;, $limit_str &#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;

$count = 0;
echo "<br><br>";
while &#40;!$recordSet->EOF&#41;
&#123;

// alternate the colors
if &#40;$count == 0&#41;
&#123;
$count = $count +1;
&#125;
else
&#123;
$count = 0;
&#125;

//strip slashes so input appears correctly
$edit_ID = $recordSet->fields&#91;ID&#93;;
$edit_user_name = make_db_unsafe &#40;$recordSet->fields&#91;user_name&#93;&#41;;
$edit_emailAddress = make_db_unsafe &#40;$recordSet->fields&#91;emailAddress&#93;&#41;;
$edit_Comments = make_db_unsafe &#40;$recordSet->fields&#91;Comments&#93;&#41;;
$edit_active = $recordSet->fields&#91;active&#93;;
$edit_isAgent = $recordSet->fields&#91;isAgent&#93;;
$edit_isAdmin = $recordSet->fields&#91;isAdmin&#93;;
$edit_canEditForms = $recordSet->fields&#91;canEditForms&#93;;
$edit_canFeatureListings = $recordSet->fields&#91;canFeatureListings&#93;;
$edit_canViewLogs = $recordSet->fields&#91;canViewLogs&#93;;
$edit_canModerate = $recordSet->fields&#91;canModerate&#93;;
$edit_canModerate_Listings_Show = $recordSet->fields&#91;canModerate_Listings_Show&#93;;
$edit_allocation = make_db_unsafe &#40;$recordSet->fields&#91;allocation&#93;&#41;;
?>
<table border="<? echo $style&#91;admin_listing_border&#93; ?>" cellspacing="<? echo $style&#91;admin_listing_cellspacing&#93; ?>" cellpadding="<? echo $style&#91;admin_listing_cellpadding&#93; ?>" width="<? echo $style&#91;admin_table_width&#93; ?>" class="form_main">
<?
echo "<tr><td align=\"right\" width=\"200\" class=\"row1_$count\"><span class=\"adminListingLeft_$count\"><B>$lang&#91;user_editor_user_number&#93;&#58; $edit_ID</b></span></td><td align=\"center\" class=\"row2_$count\" width=\"310\"> <B> <a href=\"$PHP_SELF?edit=$edit_ID&amp;edit_isAgent=$edit_isAgent \">$lang&#91;user_editor_modify_user&#93; </a></b></td><td width=\"120\" align=\"middle\" class=\"row2_$count\"><a href=\"$PHP_SELF?delete=$edit_ID&amp;edit_isAgent=$edit_isAge nt\" onClick=\"return confirmDelete&#40;&#41;\">$lang&#91;user_editor_delete_user&#93;</a></td></tr>";
echo "<tr><td align=\"center\" valign=\"middle\" class=\"row3_$count\">$edit_user_name";
echo "</td><td class=\"row3_$count\">$edit_Comments</td>";
echo "<td class=\"row3_$count\" width=\"200\">$lang&#91;user_editor_active&#93;&#58; $edit_active<br>$lang&#91;user_editor_isAgent&#93;&#58; $edit_isAgent<br>$lang&#91;user_editor_isAdmin&#93;&#58; $edit_isAdmin";
echo "<br>$lang&#91;user_editor_form_edit&#93;&#58; $edit_canEditForms";
echo "<br>$lang&#91;user_editor_feature_listings&#93;&#58; $edit_canFeatureListings";
echo "<br>$lang&#91;user_editor_view_logs&#93;&#58; $edit_canViewLogs";


echo "</td></tr></table><br><br>\r\n\r\n";
$recordSet->MoveNext&#40;&#41;;
&#125; // end while



&#125; // end if edit == ""
else
&#123;
// first, grab the user's main info
global $conn;

?>
<table border="<? echo $style&#91;form_border&#93; ?>" cellspacing="<? echo $style&#91;form_cellspacing&#93; ?>" cellpadding="<? echo $style&#91;form_cellpadding&#93; ?>" width="<? echo $style&#91;admin_table_width&#93; ?>" class="form_main">

<?
echo "<td colspan=\"2\" class=\"row_main\"><h3>$lang&#91;user_editor_modify_user&#93;</h3></td></tr>";
?>
<tr>
<td width="<? echo $style&#91;image_column_width&#93; ?>" valign="top" align="center" class="row_main">
<b><? echo $lang&#91;images&#93; ?></b>
<br>
<hr width="75%">
<a href="edit_user_images.php?edit=<? echo $edit ?>"><? echo $lang&#91;edit_images&#93; ?></a><br><br>
<?

$sql = "SELECT caption, file_name, thumb_file_name FROM " . $config&#91;table_prefix&#93; . "userImages WHERE user_id = '$edit'";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;

$num_images = $recordSet->RecordCount&#40;&#41;;

while &#40;!$recordSet->EOF&#41;
&#123;
$caption = make_db_unsafe &#40;$recordSet->fields&#91;caption&#93;&#41;;
$thumb_file_name = make_db_unsafe &#40;$recordSet->fields&#91;thumb_file_name&#93;&#41;;
$file_name = make_db_unsafe &#40;$recordSet->fields&#91;file_name&#93;&#41;;

// gotta grab the image size
$imagedata = GetImageSize&#40;"$config&#91;user_upload_path&#93;/$thumb_file_name"&#41;;
$imagewidth = $imagedata&#91;0&#93;;
$imageheight = $imagedata&#91;1&#93;;
$shrinkage = $config&#91;thumbnail_width&#93;/$imagewidth;
$displaywidth = $imagewidth * $shrinkage;
$displayheight = $imageheight * $shrinkage;

echo "<a href=\"$config&#91;user_view_images_path&#93;/$file_name\" target=\"_thumb\"> ";

echo "<img src=\"$config&#91;user_view_images_path&#93;/$thumb_file_name\" height=\"$displayheight\" width=\"$displaywidth\"></a><br> ";
echo "<b>$caption</b><br><br>";
$recordSet->MoveNext&#40;&#41;;
&#125; // end while
?>
</td>
<td valign="top" class="row_main">




<?
$sql = "SELECT * FROM " . $config&#91;table_prefix&#93; . "UserDB WHERE ID = '$edit'";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;
while &#40;!$recordSet->EOF&#41;
&#123;
// collect up the main DB's various fields
$edit_user_name = make_db_unsafe &#40;$recordSet->fields&#91;user_name&#93;&#41;;
$edit_emailAddress = make_db_unsafe &#40;$recordSet->fields&#91;emailAddress&#93;&#41;;
$edit_comments = make_db_unsafe &#40;$recordSet->fields&#91;Comments&#93;&#41;;
$edit_password = make_db_unsafe &#40;$recordSet->fields&#91;user_password&#93;&#41;;
$edit_active = $recordSet->fields&#91;active&#93;;
$edit_isAgent = $recordSet->fields&#91;isAgent&#93;;
$edit_isAdmin = $recordSet->fields&#91;isAdmin&#93;;
$edit_canEditForms = $recordSet->fields&#91;canEditForms&#93;;
$edit_canViewLogs = $recordSet->fields&#91;canViewLogs&#93;;
$edit_canModerate = $recordSet->fields&#91;canModerate&#93;;
$edit_canModerate_Listings_Show = $recordSet->fields&#91;canModerate_Listings_Show&#93;;
$edit_canFeatureListings = $recordSet->fields&#91;canFeatureListings&#93;;
$last_modified = $recordSet->UserTimeStamp&#40;$recordSet->fields&#91;last_modified&#93;,'D M j G&#58;i&#58;s T Y'&#41;;
$edit_allocation = make_db_unsafe &#40;$recordSet->fields&#91;allocation&#93;&#41;;
$recordSet->MoveNext&#40;&#41;;
&#125; // end while

// now, display all that stuff
echo "<form name=\"updateUser\" action=\"$PHP_SELF\" method=\"post\">";
echo "<input type=\"hidden\" name=\"action\" value=\"update_user\">";
echo "<input type=\"hidden\" name=\"edit\" value=\"$edit\">";
echo "<table border=\"$style&#91;form_border&#93;\" cellspacing=\"$style&#91;form_cellspacing&#93;\" cellpadding=\"$style&#91;form_cellpadding&#93;\">";
echo "<tr><td align=right><b>$lang&#91;user_name&#93;&#58;</b></td><td align=left>$edit_user_name</td></tr>";
echo "<tr><td align=\"right\" class=\"row_main\"><b>$lang&#91;last_modifed&#93;&#58;</b></td><td align=\"left\">$last_modified</td></tr>";
echo "<tr><td align=right><b>$lang&#91;user_password&#93;&#58; <font color=\"red\">*</font></b></td><td align=left> <input type=\"text\" name=\"edit_user_pass\" value=\"\"> <div class=\"small\">&#40;$lang&#91;leave_blank_if_you_do_not_want_to_change &#93;&#41;</div></td></tr>";
echo "<tr><td align=right><b>$lang&#91;user_email&#93;&#58; <font color=\"red\">*</font></b></td><td align=left> <input type=\"text\" name=\"user_email\" value=\"$edit_emailAddress\"> ";
echo "<tr><td align=right><b>$lang&#91;user_allocation&#93;&#58; <font color=\"red\">*</font></b></td><td align=left> <input type=\"text\" name=\"user_allocation\" value=\"$edit_allocation\"> ";

if &#40;$admin_privs == "yes"&#41;
&#123;
// if the user is an admin, they can set additional properties about a given user

// is the user active?
echo "<tr><td align=right><b>$lang&#91;user_editor_active&#93;&#58; </b></td>";
echo "<td align=left><select name=\"edit_active\" size=\"1\"><option value=\"$edit_active\">$edit_active<option value=\"\">-----<option value=\"yes\">yes<option value=\"no\">no</select></td></tr>";

// is the user an agent?
echo "<tr><td align=right><b>$lang&#91;user_editor_isAgent&#93;&#58; </b></td>";
echo "<td align=left>$edit_isAgent</td></tr>";
echo "<input type=\"hidden\" name=\"edit_isAgent\" value=\"" . $edit_isAgent . "\">";


// is the user an administrator?
echo "<tr><td align=right><b>$lang&#91;user_editor_isAdmin&#93;&#58; </b></td>";
echo "<td align=left><select name=\"edit_isAdmin\" size=\"1\"><option value=\"$edit_canEditForms\">$edit_isAdmin<option value=\"\">-----<option value=\"yes\">yes<option value=\"no\">no</select></td></tr>";

// can they edit forms?
echo "<tr><td align=right><b>$lang&#91;user_editor_can_edit_forms&#93;&#58; </b></td>";
echo "<td align=left><select name=\"edit_canEditForms\" size=\"1\"><option value=\"$edit_canEditForms\">$edit_canEditForms<option value=\"\">-----<option value=\"yes\">yes<option value=\"no\">no</select></td></tr>";

// can they view logs?
echo "<tr><td align=right><b>$lang&#91;user_editor_view_logs&#93;&#58; </b></td>";
echo "<td align=left><select name=\"edit_canViewLogs\" size=\"1\"><option value=\"$edit_canViewLogs\">$edit_canViewLogs<option value=\"\">-----<option value=\"yes\">yes<option value=\"no\">no</select></td></tr>";

// can they moderate incoming listings?
echo "<tr><td align=right><b>$lang&#91;user_editor_moderator&#93;&#58; </b></td>";
echo "<td align=left><select name=\"edit_canModerate\" size=\"1\"><option value=\"$edit_canModerate\">$edit_canModerate<option value=\"\">-----<option value=\"yes\">yes<option value=\"no\">no</select></td></tr>";

// do their listing need to moderate?
echo "<tr><td align=right><b>$lang&#91;Moderate_Listings_Show&#93;&#58; </b></td>";
echo "<td align=left><select name=\"edit_canModerate_Listings_Show\" size=\"1\"><option value=\"$edit_canModerate_Listings_Show\">$edit_canModerate_Listings_Show<option value=\"\">-----<option value=\"yes\">yes<option value=\"no\">no</select></td></tr>";


// can they feature listings?
echo "<tr><td align=right><b>$lang&#91;user_editor_feature_listings&#93;&#58; </b></td>";
echo "<td align=left><select name=\"edit_canFeatureListings\" size=\"1\"><option value=\"$edit_canFeatureListings\">$edit_canFeatureListings<option value=\"\">-----<option value=\"yes\">yes<option value=\"no\">no</select></td></tr>";

&#125;

// now grab miscellenous debris
if &#40;$edit_isAgent == "yes"&#41;
&#123;
$sql = "SELECT f.field_name, db.field_value, f.field_type, f.rank, f.field_caption, f.default_text, f.required, f.field_elements FROM " . $config&#91;table_prefix&#93; . "agentFormElements f left join " . $config&#91;table_prefix&#93; . "UserDBElements db on db.field_name = f.field_name and db.user_id = '$edit' ORDER BY f.rank";
//$sql = "SELECT " . $config&#91;table_prefix&#93; . "UserDBElements.field_name, " . $config&#91;table_prefix&#93; . "UserDBElements.field_value, " . $config&#91;table_prefix&#93; . "agentFormElements.field_type, " . $config&#91;table_prefix&#93; . "agentFormElements.rank, " . $config&#91;table_prefix&#93; . "agentFormElements.field_caption, " . $config&#91;table_prefix&#93; . "agentFormElements.default_text, " . $config&#91;table_prefix&#93; . "agentFormElements.required, " . $config&#91;table_prefix&#93; . "agentFormElements.field_elements FROM " . $config&#91;table_prefix&#93; . "UserDBElements, " . $config&#91;table_prefix&#93; . "agentFormElements WHERE &#40;&#40;" . $config&#91;table_prefix&#93; . "UserDBElements.user_id = '$edit'&#41; AND &#40;" . $config&#91;table_prefix&#93; . "UserDBElements.field_name = " . $config&#91;table_prefix&#93; . "agentFormElements.field_name&#41;&#41; ORDER BY " . $config&#91;table_prefix&#93; . "agentFormElements.rank";
&#125;
else
&#123;
$sql = "SELECT f.field_name, db.field_value, f.field_type, f.rank, f.field_caption, f.default_text, f.required, f.field_elements FROM " . $config&#91;table_prefix&#93; . "memberFormElements f left join " . $config&#91;table_prefix&#93; . "UserDBElements db on db.field_name = f.field_name and db.user_id = '$edit' ORDER BY f.rank";
//$sql = "SELECT " . $config&#91;table_prefix&#93; . "UserDBElements.field_name, " . $config&#91;table_prefix&#93; . "UserDBElements.field_value, " . $config&#91;table_prefix&#93; . "memberFormElements.field_type, " . $config&#91;table_prefix&#93; . "memberFormElements.rank, " . $config&#91;table_prefix&#93; . "memberFormElements.field_caption, " . $config&#91;table_prefix&#93; . "memberFormElements.default_text, " . $config&#91;table_prefix&#93; . "memberFormElements.required, " . $config&#91;table_prefix&#93; . "memberFormElements.field_elements FROM " . $config&#91;table_prefix&#93; . "UserDBElements, " . $config&#91;table_prefix&#93; . "memberFormElements WHERE &#40;&#40;" . $config&#91;table_prefix&#93; . "UserDBElements.user_id = '$edit'&#41; AND &#40;" . $config&#91;table_prefix&#93; . "UserDBElements.field_name = " . $config&#91;table_prefix&#93; . "memberFormElements.field_name&#41;&#41; ORDER BY " . $config&#91;table_prefix&#93; . "memberFormElements.rank";
&#125;
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;
while &#40;!$recordSet->EOF&#41;
&#123;
$field_name = make_db_unsafe &#40;$recordSet->fields&#91;field_name&#93;&#41;;
$field_value = make_db_unsafe &#40;$recordSet->fields&#91;field_value&#93;&#41;;
$field_type = make_db_unsafe &#40;$recordSet->fields&#91;field_type&#93;&#41;;
$field_caption = make_db_unsafe&#40;$recordSet->fields&#91;field_caption&#93;&#41;;
$default_text = make_db_unsafe&#40;$recordSet->fields&#91;default_text&#93;&#41;;
$field_elements = make_db_unsafe&#40;$recordSet->fields&#91;field_elements&#93;&#41;;
$required = make_db_unsafe&#40;$recordSet->fields&#91;required&#93;&#41;;

// pass the data to the function
renderExistingFormElement&#40;$field_type, $field_name, $field_value, $field_caption, $default_text, $required, $field_elements&#41;;
$recordSet->MoveNext&#40;&#41;;
&#125; // end while

echo "<tr><td colspan=\"2\" align=\"center\">$lang&#91;required_form_text&#93;</td></tr>";

echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"$lang&#91;update_button&#93;\"></td></tr></table></form>";

&#125; // end if
?>
</td></tr></table>

<P>
</P>

<?
include&#40;"$config&#91;template_path&#93;/admin_bottom.html"&#41;;
$conn->Close&#40;&#41;; // close the db connection
?>

awddesign
05-02-2004, 06:45 PM
Hi Jason

Have you got it working ? :D

I am still testing it on my rentals demo site and it's looking good.
OR 1.1.4b

I will check your mod out this week 8)

Al

farlopex
05-04-2004, 08:25 AM
ERRORS:


$sql .= "canModerate = $sql_edit_canModerate";
$sql .= "canModerate_Listings_Show = $sql_edit_canModerate_Listings_Show";


The lines must be...


$sql .= "canModerate = $sql_edit_canModerate,";
$sql .= "canModerate_Listings_Show = $sql_edit_canModerate_Listings_Show ";
Missing , and SPACE.

Sugestions:

ˇ I put the Input allocation inside if ($admin_privs == "yes") because I prefer only administrator can update the max. allocations. I redefided the update query, with this argument $sql .= "allocation = $sql_user_allocation,"; and delete $sql2 some lines before.
ˇ When the admin add user, it can´t add the allocation. File: add_user.php?edit_isAgent=yes, and if a user is registered, I set the default allocation value to 50

Regards!

Cybrac
05-05-2004, 11:25 PM
Thanks for the heads up

thank :lol:


jason

phoenix
05-12-2004, 05:34 PM
what is the code for database?? do i need to create something in database??

Cybrac
05-13-2004, 10:47 AM
I created a new row called allocation in the table default_UserDB with attibute of INT(11).

jason

greengiant
05-13-2004, 11:44 PM
Adding this to the feature list for 2.X

yp
05-17-2004, 01:32 PM
Cybrac ,

I used the code and I am using 1.1.4 with Full Mod.

But I get this error

UPDATE homes_UserDB SET isAdmin = 'yes',active = 'yes',isAgent = 'yes',canEditForms = 'yes',canFeatureListings = 'yes',canViewLogs = 'yes',canModerate = 'yes',canModerate_Listings_Show = '' WHERE ID = '1'

It seems to update the database if I change the number. But I get this after I hit the update in admin.

But other then that is does seem to work!!

Thanks !

Cybrac
05-19-2004, 07:20 PM
I have not used it with the full mod


UPDATE homes_UserDB SET isAdmin = 'yes',active = 'yes',isAgent = 'yes',canEditForms = 'yes',canFeatureListings = 'yes',canViewLogs = 'yes',canModerate = 'yes',canModerate_Listings_Show = '' WHERE ID = '1'

canModerate_Listings_Show = '' it looks like nothing is get sent here.

when are you getting this error what page.

jason

yp
05-20-2004, 08:35 AM
I have not used it with the full mod


UPDATE homes_UserDB SET isAdmin = 'yes',active = 'yes',isAgent = 'yes',canEditForms = 'yes',canFeatureListings = 'yes',canViewLogs = 'yes',canModerate = 'yes',canModerate_Listings_Show = '' WHERE ID = '1'

canModerate_Listings_Show = '' it looks like nothing is get sent here.

when are you getting this error what page.

jason

I only get this error within the ADMIN edit_user.php After you changed the value and click save it does update the info but get this error. I havn't tried it on a clean copy yet.

Thanks !

Cybrac
05-20-2004, 12:22 PM
ERRORS:
Code:

$sql .= "canModerate = $sql_edit_canModerate";
$sql .= "canModerate_Listings_Show = $sql_edit_canModerate_Listings_Show";



The lines must be...
Code:

$sql .= "canModerate = $sql_edit_canModerate,";
$sql .= "canModerate_Listings_Show = $sql_edit_canModerate_Listings_Show ";

Missing , and SPACE.

Jason

yp
05-20-2004, 07:09 PM
ERRORS:
Code:

$sql .= "canModerate = $sql_edit_canModerate";
$sql .= "canModerate_Listings_Show = $sql_edit_canModerate_Listings_Show";



The lines must be...
Code:

$sql .= "canModerate = $sql_edit_canModerate,";
$sql .= "canModerate_Listings_Show = $sql_edit_canModerate_Listings_Show ";

Missing , and SPACE.

Jason


Yes, I don't that one.... I will have to do a compair files and see what was added if anything from FULL MOD and what was added in this mod.

Thanks

thebeards
06-08-2004, 05:19 AM
I have not used it with the full mod

[quote]UPDATE homes_UserDB SET isAdmin = 'yes',active = 'yes',isAgent = 'yes',canEditForms = 'yes',canFeatureListings = 'yes',canViewLogs = 'yes',canModerate = 'yes',canModerate_Listings_Show = '' WHERE ID = '1'

canModerate_Listings_Show = '' it looks like nothing is get sent here.

when are you getting this error what page.

jason

I only get this error within the ADMIN edit_user.php After you changed the value and click save it does update the info but get this error. I havn't tried it on a clean copy yet.


-------------------------------------------------------------------------------

:?:
I have the same problem.... someone I have some idea of like resolving this thing.. :cry:
thanks !! emanuele
---------------------------------------------------------------------------------

RealtyOne
06-08-2004, 07:06 AM
While its not my mod and out of respect i mostly say nothing on other peoples mods unless asked this same question has been around for some time. I dont use this or have it on my servers but just from a little reading of instructions and code supplied in this thread.

What changes have you made to your database structure?
I see where you are told to add "allocation" to the userdb but i dont see where anyone has said to add "canModerate_Listings_Show" and since you are trying to save information to that coloum it first needs to be in the database.

;) Just what i have noticed i may simply have missed the required instruction. My appoligys to the mods author for stepping in.

awddesign
06-08-2004, 09:46 AM
Hi

I use this one:
http://www.open-realty.org/phpBB2/viewtopic.php?p=9344#9344

this may help you how the db is set up:

DROP TABLE IF EXISTS default_userdb;
CREATE TABLE default_userdb (
ID int(11) NOT NULL auto_increment,
user_name varchar(80) NOT NULL,
emailAddress varchar(80) NOT NULL,
Comments text NOT NULL,
user_password varchar(50) NOT NULL,
isAdmin char(3) DEFAULT 'No' NOT NULL,
canEditForms char(3) DEFAULT 'No' NOT NULL,
creation_date date DEFAULT '0000-00-00' NOT NULL,
canFeatureListings char(3) DEFAULT 'No' NOT NULL,
canViewLogs char(3) DEFAULT 'No' NOT NULL,
last_modified timestamp(14),
hitcount int(11) DEFAULT '0' NOT NULL,
canModerate char(3) DEFAULT 'no' NOT NULL,
isAgent char(3) DEFAULT 'no' NOT NULL,
active char(3) DEFAULT 'no' NOT NULL,
allocation int(11) DEFAULT '0' NOT NULL,
payments int(11) DEFAULT '0' NOT NULL,
payment_proces varchar(11) DEFAULT '0' NOT NULL,
payment_type varchar(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (ID),
UNIQUE ID (ID, user_name),
KEY ID_2 (ID)
);


al

pbflash
09-10-2004, 01:23 PM
I added the code to clean versions of user_edit, add_agent, and add_listing so there shouldn't be any problems replacing your orignals.

The mod allows you to set the maximum listings for each agent when you add them. You can also change this number through edit agents on the admin side. Just back up your original files and copy these to your admin directory.

You do have to manually add a field to the UserDB as defined below.

Name: max_listings
Type: int(10)
Default: (whatever you want the default number to be)

This has been tested and works.

neparealtor.com
09-10-2004, 04:14 PM
Error. When I added this (including the db entry) I get an error when I try and use the add_listing.php. There's been a problem -- please contact the site administrator. Did I possably not add it right in phpmyadmin?

pbflash
09-10-2004, 04:17 PM
Possibly. I noticed that I spelled the field name wrong. It should be max_listings. I edited my original post to correct.

neparealtor.com
09-10-2004, 04:42 PM
this is what I have in my userdb mysql file
Name type Null Default
max_lisitngs int(10) No 10

this is the last entry below r_listing

pbflash
09-10-2004, 05:05 PM
The name should be max_listings. I mis-spelled it in my first post.

neparealtor.com
09-10-2004, 06:35 PM
Ahhh now I see it. Thanks!

justme
09-10-2004, 07:57 PM
I loaded this mod and this is the error message I get:

You have currently added a total of 0 listings. Your maximum allocation is SELECT allocation FROM default_UserDB WHERE user_ID = 3.
Sorry you have reached your maximum alloaction of properties.
It's not really an error just what shows up when I click on "Add A Listing"

Here is the code that is causing it:

//informs current total listing count
$sql = "SELECT ID FROM " . $config[table_prefix] . "listingsDB WHERE user_ID = $userID";
$recordSet = $conn->Execute($sql);
if ($recordSet === false)
{
log_error($sql);
}
while (!$recordSet->EOF)
{
$ID = $recordSet->fields[ID];
$recordSet->MoveNext();
}
$num_listings = $recordSet->RecordCount();

$sql2 = "SELECT allocation FROM " . $config[table_prefix] . "UserDB WHERE ID = $userID";
$recordSet2 = $conn->Execute($sql2);
if ($recordSet2 === false)
{
log_error($sql2);
}
while (!$recordSet2->EOF)
{
$allocation = $recordSet2->fields[allocation];
$recordSet2->MoveNext();
}
$num_listings = $recordSet->RecordCount();

$allocation = "SELECT allocation FROM " . $config[table_prefix] . "UserDB WHERE user_ID = $userID";

echo "You have currently added a total of $num_listings listings. Your maximum allocation is $allocation.";

//this sets the maximum number of allowable properties
//message is given if user has reached limit

if ($num_listings>=$allocation and $allocation != "unlimited")
{
echo "<br>Sorry you have reached your maximum alloaction of properties.";
}
//if user has not reached their limit then the following form appears
else
{

Something just doesn't seem to be reading right or something .. any help would be greatly appreciated. Thanks in advance!

pbflash
09-10-2004, 08:10 PM
Your maximum allocation is SELECT allocation FROM default_UserDB WHERE user_ID = 3.

This is because after you run the query to get the allocation value ($allocation) you have another line that sets $allocation = "SELECT allocation FROM " . $config[table_prefix] . "UserDB WHERE user_ID = $userID"; this replaces the number it pulled from the db with the "SELECT allocation......".

Remove the line $allocation="SELECT....."

You also have $num_listings defined twice. You don't need it after the second sql so I'd remove that as well. You also don't need the while (!$recordSet->EOF) part on the first sql.

It should look something like this:

//informs current total listing count
$sql = "SELECT ID FROM " . $config[table_prefix] . "listingsDB WHERE user_ID = $userID";
$recordSet = $conn->Execute($sql);
if ($recordSet === false)
{
log_error($sql);
}
$num_listings = $recordSet->RecordCount();

$sql2 = "SELECT allocation FROM " . $config[table_prefix] . "UserDB WHERE ID = $userID";
$recordSet2 = $conn->Execute($sql2);
if ($recordSet2 === false)
{
log_error($sql2);
}
while (!$recordSet2->EOF)
{
$allocation = $recordSet2->fields[allocation];
$recordSet2->MoveNext();
}

echo "You have currently added a total of $num_listings listings. Your maximum allocation is $allocation.";

//this sets the maximum number of allowable properties
//message is given if user has reached limit

if ($num_listings>=$allocation and $allocation != "unlimited")
{
echo "<br>Sorry you have reached your maximum alloaction of properties.";
}
//if user has not reached their limit then the following form appears
else
{

justme
09-10-2004, 08:18 PM
it works great now .. now when I clicked on add a listing, it went straight to the add listing page with my allocation info up top .. you da man...

Thanks again! I will let you know that is what you have in your zip fiile, you may want to edit the add_lisiting.php file in there and take out the double stuff...thanks again!

pbflash
09-10-2004, 08:22 PM
This code is not from my zip file. I do not use the allocation variable (mine uses max_listings) and mine does not show how many they have posted and what they are allowed to post. It's a nice feature but it is not in my files. You must have grabbed a prior post.

justme
09-10-2004, 08:27 PM
I downloaded one the other day and I downloaded yours today and they are similiar in name .. almost exact..I didn't unzip yours and when I saw the one I had already downloaded I thought it was yours .. sorry for that .. thanks for helping me with someon elses then... I think I will add your adduser.php file now .. thanks again pb

pbflash
09-10-2004, 08:30 PM
My add_user won't work unless you change the max_listings variable in mine to allocation to match your table. Same with the edit_user.