The following code is what is executed when a user tries to send mail. It works excellent to block a non payer yet allow a paying user. It is a file on the server.
Code:
<?
$f_profile = f(q("SELECT name, email, member_id FROM dt_profile WHERE id='$profile_id'"));
$f_user = f(q("SELECT system_status, system_status_end FROM dt_members WHERE id='$f_profile[member_id]'"));
$f_balance = f(q("SELECT balance FROM dt_stamps_balance WHERE member_id='$fMember[id]'"));
if($f_profile == "" || $f_user == "")
{
return;
}
$free_profile = 0;
$can_contact = 0;
$valid = 0;
if($fMember[ unlimited ] && $fMember[ unlimited_end ] > strtotime(date("d M Y H:i:s")))
{
$free_profile = 1;
$can_contact = 0;
}
else
{
if($f_user[ system_status ] && ($f_user[ system_status_end ] > strtotime(date("d M Y H:i:s")))) $free_profile = 1;
if($f_balance[ balance ] >= 1) $can_contact = 1;
}
if(!$free_profile && !$can_contact)
{
include "templates/cannot_contact.ihtml";
return;
}
$profile_name = $f_profile[ name ];
$profile_email = $f_profile[ email ];
$f_address_book = f(q("SELECT id FROM dt_address_book WHERE contact_profile_id='$profile_id' AND member_id='$fMember[id]'"));
if($f_address_book != "")
{
$free_profile = 1;
}
else
{
$sql = "INSERT INTO dt_address_book (member_id, contact_profile_id) VALUES ('$fMember[id]', '$profile_id')";
q($sql);
}
$mid = $profile_id;
if($free_profile)
{
$valid = 1;
include "engine/pages/send_message.pml";
return;
}
if($can_contact)
{
q("UPDATE dt_stamps_balance SET balance=balance-1 WHERE member_id='$fMember[id]'");
$valid = 1;
include "engine/pages/send_message.pml";
return;
}
?>
These next lines of code are what executes when any user clicks on their mailbox link. Can I include any part of the above code in this one to make it do the same as above? This is also a file on the server.
Code:
<?
$r_records = q("SELECT id, rid, sid, subject, timesent, is_read FROM dt_messages WHERE (rid='$fMember[id]' and is_deleted = 0) ORDER BY timesent DESC");
$total_messages = (int)nr($r_records);
include "templates/inbox.ihtml";
?>
Bookmarks