/**
 * Print code for membership status
 * $memberID - member ID
 * $offer_upgrade - will this code be printed at [c]ontrol [p]anel
 * $credits - will print credits status if $credits == 1
 */
function GetMembershipStatus($memberID, $offer_upgrade = true, $credits = 0)
{
    global $oTemplConfig;
    $ret = "";
    $membership_info = getMemberMembershipInfo($memberID);
    $viewMembershipActions = "<br />(<a onclick=\"javascript:window.open('explanation.php?explain=membership&amp;type=" . $membership_info['ID'] . "', '', 'width=500, height=400, menubar=no, status=no, resizable=no, scrollbars=yes, toolbar=no, location=no');\" href=\"javascript:void(0);\">" . _t("_VIEW_MEMBERSHIP_ACTIONS") . "</a>)<br />";
    // Show colored membership name
    if ($membership_info['ID'] == MEMBERSHIP_ID_STANDARD) {
        $ret .= _t("_MEMBERSHIP_STANDARD") . $viewMembershipActions;
        if ($offer_upgrade) {
            $ret .= " " . _t("_MEMBERSHIP_UPGRADE_FROM_STANDARD");
        }
    } else {
        $ret .= "<font color=\"red\">{$membership_info['Name']}</font>{$viewMembershipActions}";
        $days_left = (int) (($membership_info['DateExpires'] - time()) / (24 * 3600));
        if (!is_null($membership_info['DateExpires'])) {
            if ($days_left > 0) {
                $ret .= _t("_MEMBERSHIP_EXPIRES_IN_DAYS", $days_left);
            } else {
                $ret .= _t("_MEMBERSHIP_EXPIRES_TODAY", date("H:i", $membership_info['DateExpires']), date("H:i"));
            }
        } else {
            $ret .= _t("_MEMBERSHIP_EXPIRES_NEVER");
        }
        if ($offer_upgrade && !is_null($membership_info['DateExpires'])) {
            $ret .= " - <a href=\"membership.php\">" . _t("_MEMBERSHIP_BUY_MORE_DAYS") . "</a>";
        }
    }
    if ($credits) {
        $gold_arr_cred_amount = getProfileCredits($memberID);
        $ret .= "<br /><u>" . _t("_MEMBERSHIP_CREDITS") . "</u> (<a href=\"javascript: void(0);\" onClick=\"javascript: window.open('explanation.php?explain=credits', '', 'width={$oTemplConfig->popUpWindowWidth},height={$oTemplConfig->popUpWindowHeight},menubar=no,status=no,resizable=no,scrollbars=yes,toolbar=no, location=no' );\">" . _t("_Explanation") . "</a>)<br />";
        if ($gold_arr_cred_amount) {
            $ret .= _t("_MEMBERSHIP_CREDITS_YES", $gold_arr_cred_amount) . "<br />";
        } else {
            $ret .= _t("_MEMBERSHIP_CREDITS_NO") . "<br />";
        }
        if ($offer_upgrade) {
            $ret .= " - <a href=\"membership.php\">" . _t("_MEMBERSHIP_CREDITS_BUY_MORE") . "</a>";
        }
    }
    return $ret;
}
/**
 * list of all active payment providers
 */
function PageCompProviderList()
{
    global $dir;
    global $site;
    global $en_credits;
    global $enable_recurring;
    global $credit2money;
    global $memberID;
    // defined in checkout.inc.php
    global $collectDataArr;
    global $collectDataInputs;
    $ret = '';
    // show credit checkout only if credits enabled and checkout not for credit buying
    if ($en_credits && $collectDataArr['checkout_action'] != 'credits') {
        $creditBalance = getProfileCredits($memberID);
        if ($creditBalance > 0.0) {
            $creditText = _t("_MEMBERSHIP_CREDITS_YES", $creditBalance);
        } else {
            $creditText = _t("_MEMBERSHIP_CREDITS_NO");
        }
        $creditsAmount = sprintf("%.2f", (double) ($collectDataArr['amount'] * $credit2money));
        ob_start();
        ?>
<form id="fcreditsProviderForm" action="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
" method="post" style="margin: 10px;">
<input type="hidden" name="action" value="start_checkout" />
<input type="hidden" name="use_credits" value="on" />
<?php 
        echo $collectDataInputs;
        ?>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="field_caption" align="right" width="50%"><?php 
        echo _t('_Credit balance');
        ?>
:</td>
		<td align="left" width="50%"><?php 
        echo $creditText;
        ?>
</td>
	</tr>
	<tr>
		<td class="field_caption" align="right" width="50%"><?php 
        echo _t('_Payment amount in credits');
        ?>
:</td>
		<td class="field_value" align="left" width="50%"><?php 
        echo $creditsAmount;
        ?>
</td>
	</tr>
	<tr>
		<td align="center" colspan="2">
			<?php 
        echo $creditsAmount > $creditBalance ? _t('_Not enough credits') : '<input type="submit" class="no" value="' . _t('_Check Out') . '" style="width: 100px; vertical-align: middle" />';
        ?>
		</td>
	</tr>
</table>
</form>
<?php 
        $content = ob_get_contents();
        ob_end_clean();
        $designBox = DesignBoxContentBorder(_t('_MEMBERSHIP_CREDITS'), $content);
        $ret .= "<div class=\"credits_box\">\n{$designBox}\n</div>\n";
    }
    $res = db_res("SELECT `ID`, `Name`, `Caption`, `SupportsRecurring`, `LogoFilename` FROM `PaymentProviders` WHERE `Active`");
    while ($arr = mysql_fetch_assoc($res)) {
        if ($enable_recurring && $collectDataArr['allow_subscribe'] == 'on') {
            if ($arr['SupportsRecurring']) {
                $recurringField = "<input type=\"checkbox\" name=\"prov_recurring\" id=\"prov{$arr['ID']}_recurring_id\" style=\"vertical-align: middle;\" onclick=\"javascript: document.getElementById('subscribe{$arr['ID']}_days_id').disabled = !this.checked;\" />&nbsp;<label for=\"prov{$arr['ID']}_recurring_id\">" . _t('_recurring payment') . "</label>";
                if ((int) $collectDataArr['subscribe_days'] == 0) {
                    $daysVariants = array(10, 20, 30, 60, 180);
                    $recurringField .= "&nbsp<select name=\"subscribe_days\" id=\"subscribe{$arr['ID']}_days_id\" disabled=\"disabled\" style=\"vertical-align: middle;\">\n";
                    foreach ($daysVariants as $days) {
                        $recurringField .= "<option value=\"{$days}\">{$days} " . _t('_days') . "</option>";
                    }
                    $recurringField .= "</select>\n";
                }
            } else {
                $recurringField = _t('_recurring not supported');
            }
        } else {
            $recurringField = _t('_recurring not allowed');
        }
        ob_start();
        ?>
<form id="f<?php 
        echo $arr['Name'];
        ?>
ProviderForm" action="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
" method="post" style="margin: 10px;">
<input type="hidden" name="action" value="start_checkout" />
<?php 
        echo $collectDataInputs;
        ?>
<input type="hidden" name="prov_id" value="<?php 
        echo $arr['ID'];
        ?>
" />
<table cellpadding="4" cellspacing="0" border="0" width="100%">
	<tr>
		<td align="left" width="35%" rowspan="2"><?php 
        echo strlen($arr['LogoFilename']) > 0 && file_exists($dir['checkout'] . 'images/' . $arr['LogoFilename']) ? "<img src=\"{$site['checkout']}images/{$arr['LogoFilename']}\" alt=\"" . process_line_output($arr['Caption']) . "\" />" : '&nbsp;';
        ?>
</td>
		<td class="field_caption" align="right" width="65%"><?php 
        echo $recurringField;
        ?>
</td>
	</tr>
	<tr>
		<td align="right" width="65%">
			<input type="submit" class="no" value="<?php 
        echo _t('_Check Out');
        ?>
" style="width: 100px; vertical-align: middle" />
		</td>
	</tr>
</table>
</form>
<?php 
        $content = ob_get_contents();
        ob_end_clean();
        $designBox = DesignBoxContentBorder($arr['Caption'], $content);
        $ret .= "<div class=\"provider_box\">\n{$designBox}\n</div>\n";
    }
    return $ret;
}
Пример #3
0
/**
 * Send message
 */
function MemberSendMessage($member, $recipient, $must_use_credits = false)
{
    global $site;
    $en_dest_choice = getParam("enable_msg_dest_choice");
    $max_message_size = getParam("max_inbox_message_size");
    $max_messages = getParam("max_inbox_messages");
    // Check if recipient is active
    if ('Active' != $recipient['Status']) {
        return 10;
    }
    // Check if member is blocked
    if (db_arr("SELECT `ID`, `Profile` FROM `BlockList` WHERE `Profile` = {$member['ID']} AND `ID` = '{$recipient['ID']}';")) {
        return 5;
    }
    // If must use credits then check for enough amount
    if ($must_use_credits && getProfileCredits($member['ID']) < (double) $msg_credits) {
        return 21;
    }
    // antispam ))
    if (db_arr("SELECT `ID` FROM `Messages` WHERE `Sender` = {$member[ID]} AND date_add(`Date`, INTERVAL 1 MINUTE) > Now()")) {
        return 3;
    }
    // Get sender info
    $sender = getProfileInfo($member['ID']);
    $aPlus = array();
    $aPlus['ProfileReference'] = $sender ? '<a href="' . getProfileLink($member['ID']) . '">' . $sender['NickName'] . '</a> (' . getProfileLink($member['ID']) . ') ' : '<b>' . _t("_Visitor") . '</b>';
    // Don't send notification if message is sending to email
    if ($_POST['notify'] && !($_POST['sendto'] == "email" || $_POST['sendto'] == "both")) {
        $message_text = getParam("t_Compose");
        $subject = getParam('t_Compose_subject');
        $aPlus['senderNickName'] = $sender ? $sender['NickName'] : _t("_Visitor");
        $notify_res = sendMail($recipient['Email'], $subject, $message_text, $recipient['ID'], $aPlus);
        if (!$notify_res) {
            echo "<div class=\"err\">" . _t("_Notification send failed") . "</div><br />\n";
        }
    }
    // Send message to email
    if ($en_dest_choice && ($_POST['sendto'] == "email" || $_POST['sendto'] == "both")) {
        $message_text = getParam("t_Message");
        $subject = process_pass_data($_POST['mes_subject']);
        $aPlus['MessageText'] = strmaxtextlen(clear_xss(replace_full_uris(process_pass_data($_POST['text']))), $max_message_size);
        $result = sendMail($recipient['Email'], $subject, $message_text, $recipient['ID'], $aPlus);
    }
    // Send message to communicator
    if ($_POST['sendto'] == "lovemail" || $_POST['sendto'] == "both") {
        // Restrict with total messages count
        $messages_count = db_arr("SELECT COUNT(*) AS `mess_count` FROM `Messages` WHERE `Recipient` = '{$recipient['ID']}'");
        $messages_count = $messages_count['mess_count'];
        if ($messages_count - 1 > $max_messages) {
            $del_res = db_res("SELECT `ID` FROM `Messages` WHERE `Recipient` = '{$recipient['ID']}' ORDER BY `Date` ASC LIMIT " . ($messages_count - $max_messages + 1));
            while ($del_arr = mysql_fetch_array($del_res)) {
                db_res("DELETE FROM `Messages` WHERE `ID` = {$del_arr['ID']}");
            }
        }
        // Insert message into database
        $message_text = strmaxtextlen(addslashes(clear_xss(process_pass_data($_POST['text']))), $max_message_size);
        $message_subject = strmaxwordlen(process_db_input($_POST['mes_subject']), 30);
        $result = db_res("INSERT INTO `Messages` ( `Date`, `Sender`, `Recipient`, `Text`, `Subject`, `New` ) VALUES ( NOW(), {$member['ID']}, {$recipient['ID']}, '{$message_text}', '{$message_subject}', '1' )");
    }
    // If sending successful then mark as performed action
    if ($result) {
        checkAction($member['ID'], ACTION_ID_SEND_MESSAGE, true);
        if ($must_use_credits) {
            decProfileCredits($member['ID'], $msg_credits);
        }
    } else {
        return 1;
    }
    return 0;
}