Пример #1
0
/**
 * page code function
 */
function PageCompPageMainCode($iID, $sConfCode)
{
    global $site;
    $ID = (int) $iID;
    $ConfCode = clear_xss($sConfCode);
    $p_arr = getProfileInfo($ID);
    if (!$p_arr) {
        $_page['header'] = _t("_Error");
        $_page['header_text'] = _t("_Profile Not found");
        return MsgBox(_t('_Profile Not found Ex'));
    }
    $aCode = array('message_status' => '', 'message_info' => '', 'bx_if:form' => array('condition' => false, 'content' => array('form' => '')), 'bx_if:next' => array('condtion' => false, 'content' => array('next_url' => '')));
    if ($p_arr['Status'] == 'Unconfirmed') {
        $ConfCodeReal = base64_encode(base64_encode(crypt($p_arr[Email], CRYPT_EXT_DES ? "secret_co" : "se")));
        if (strcmp($ConfCode, $ConfCodeReal) != 0) {
            $aForm = array('form_attrs' => array('action' => BX_DOL_URL_ROOT . 'profile_activate.php', 'method' => 'post', 'name' => 'form_change_status'), 'inputs' => array('conf_id' => array('type' => 'hidden', 'name' => 'ConfID', 'value' => $ID), 'conf_code' => array('type' => 'text', 'name' => 'ConfCode', 'value' => '', 'caption' => _t("_Confirmation code")), 'submit' => array('type' => 'submit', 'name' => 'submit', 'value' => _t("_Submit"))));
            $oForm = new BxTemplFormView($aForm);
            $aCode['message_status'] = _t("_Profile activation failed");
            $aCode['message_info'] = _t("_EMAIL_CONF_FAILED_EX");
            $aCode['bx_if:form']['condition'] = true;
            $aCode['bx_if:form']['content']['form'] = $oForm->getCode();
        } else {
            $aCode['bx_if:next']['condition'] = true;
            $aCode['bx_if:next']['content']['next_url'] = BX_DOL_URL_ROOT . 'member.php';
            $send_act_mail = false;
            if (getParam('autoApproval_ifJoin') == 'on' && !(getParam('sys_dnsbl_enable') && 'approval' == getParam('sys_dnsbl_behaviour') && bx_is_ip_dns_blacklisted('', 'join'))) {
                $status = 'Active';
                $send_act_mail = true;
                $aCode['message_info'] = _t("_PROFILE_CONFIRM");
            } else {
                $status = 'Approval';
                $aCode['message_info'] = _t("_EMAIL_CONF_SUCCEEDED", $site['title']);
            }
            $update = bx_admin_profile_change_status($ID, $status, $send_act_mail);
            // Promotional membership
            if (getParam('enable_promotion_membership') == 'on') {
                $memership_days = getParam('promotion_membership_days');
                setMembership($p_arr['ID'], MEMBERSHIP_ID_PROMOTION, $memership_days, true);
            }
            // check couple profile;
            if ($p_arr['Couple']) {
                $update = bx_admin_profile_change_status($p_arr['Couple'], $status);
                //Promotional membership
                if (getParam('enable_promotion_membership') == 'on') {
                    $memership_days = getParam('promotion_membership_days');
                    setMembership($p_arr['Couple'], MEMBERSHIP_ID_PROMOTION, $memership_days, true);
                }
            }
            if (getParam('newusernotify')) {
                $oEmailTemplates = new BxDolEmailTemplates();
                $aTemplate = $oEmailTemplates->getTemplate('t_UserConfirmed', $p_arr['ID']);
                sendMail($site['email_notify'], $aTemplate['Subject'], $aTemplate['Body'], $p_arr['ID']);
            }
        }
    } else {
        $aCode['message_info'] = _t('_ALREADY_ACTIVATED');
    }
    return $GLOBALS['oSysTemplate']->parseHtmlByName('profile_activate.html', $aCode);
}
 function _processProfileJoin($oAlert)
 {
     $oPC = new BxDolProfilesController();
     //--- reparse profile tags
     $oTags = new BxDolTags();
     $oTags->reparseObjTags('profile', $oAlert->iObject);
     //--- send new user notification
     if (getParam('newusernotify') == 'on') {
         $oPC->sendNewUserNotify($oAlert->iObject);
     }
     //--- Promotional membership
     if (getParam('enable_promotion_membership') == 'on') {
         $iMemershipDays = getParam('promotion_membership_days');
         setMembership($oAlert->iObject, MEMBERSHIP_ID_PROMOTION, $iMemershipDays, true);
     }
 }
/**
 * Buy a membership for a member
 *
 * @param int     $iMemberId        - member that is going to get the membership
 * @param int     $iMembershipId    - bought membership
 * @param int     $sTransactionId   - internal key of the transaction (ID from Transactions table)
 * @param boolean $bStartsNow       - if true, the membership will start immediately;
 *                                  if false, the membership will start after the current
 *                                  membership expires
 *
 * @return boolean                - true in case of success, false in case of failure
 *
 */
function buyMembership($iMemberId, $iMembershipId, $sTransactionId, $bStartsNow = false)
{
    $iMemberId = (int) $iMemberId;
    $iMembershipId = (int) $iMembershipId;
    $aMembership = db_arr("SELECT\n            `tl`.`ID` AS `ID`,\n            `tlp`.`Days` AS `Days`,\n            `tl`.`Active` AS `Active`,\n            `tl`.`Purchasable` AS `Purchasable`\n        FROM `sys_acl_levels` AS `tl`\n        LEFT JOIN `sys_acl_level_prices` AS `tlp` ON `tl`.`ID`=`tlp`.`IDLevel`\n        WHERE `tlp`.`id`='" . $iMembershipId . "'");
    if (!is_array($aMembership) || empty($aMembership)) {
        return false;
    }
    $iMembershipId = (int) $aMembership['ID'];
    //check for predefined non-purchasable memberships
    if (in_array($iMembershipId, array(MEMBERSHIP_ID_NON_MEMBER, MEMBERSHIP_ID_STANDARD, MEMBERSHIP_ID_PROMOTION))) {
        return false;
    }
    //check if membership is active and purchasable
    if ($aMembership['Active'] != 'yes' || $aMembership['Purchasable'] != 'yes') {
        return false;
    }
    return setMembership($iMemberId, $iMembershipId, $aMembership['Days'], $bStartsNow, $sTransactionId);
}
Пример #4
0
 function setMembership()
 {
     $iMshipID = (int) $_POST['MembershipID'];
     $iMshipDays = (int) $_POST['MembershipDays'];
     // 0 = unlim
     $bStartsNow = $_POST['MembershipImmediately'] == 'on';
     return setMembership($this->iProfileID, $iMshipID, $iMshipDays, $bStartsNow);
 }
/**
 * Buy a membership for a member
 *
 * @param int $memberID			- member that is going to get the membership
 * @param int $membershipID		- bought membership
 * @param float $price			- one of the pricing options for the given membership
 * @param int $transactionID	- internal key of the transaction (ID from Transactions table)
 * @param boolean $startsNow	- if true, the membership will start immediately;
 *								  if false, the membership will start after the current
 *								  membership expires
 *
 * @return boolean				- true in case of success, false in case of failure
 *
 *
 */
function buyMembership($memberID, $membershipID, $price, $transactionID, $startsNow = false)
{
    //input validation
    $memberID = (int) $memberID;
    $membershipID = (int) $membershipID;
    $price = (double) $price;
    $transactionID = (int) $transactionID;
    //check for predefined non-purchasable memberships
    if ($membershipID == MEMBERSHIP_ID_NON_MEMBER || $membershipID == MEMBERSHIP_ID_STANDARD || $membershipID == MEMBERSHIP_ID_PROMOTION) {
        return false;
    }
    //check if membership is active and purchasable
    $resMemLevels = db_res("SELECT Active, Purchasable FROM MemLevels WHERE ID = {$membershipID}");
    if (mysql_num_rows($resMemLevels) <= 0) {
        return false;
    }
    //membership not found
    $arrMembership = mysql_fetch_assoc($resMemLevels);
    $membershipActive = $arrMembership['Active'] == 'yes' ? true : false;
    $membershipPurchasable = $arrMembership['Purchasable'] == 'yes' ? true : false;
    if (!$membershipActive || !$membershipPurchasable) {
        return false;
    }
    //check if the given pricing option is valid for the given membership
    $membershipPrices = getMembershipPrices($membershipID);
    if (count($membershipPrices) <= 0) {
        return false;
    }
    $pricingOptionExists = false;
    foreach ($membershipPrices as $daysOption => $priceOption) {
        if ($priceOption == $price) {
            $pricingOptionExists = true;
            break;
        }
    }
    if (!$pricingOptionExists) {
        return false;
    }
    return setMembership($memberID, $membershipID, $daysOption, $startsNow, $transactionID);
}
//---------------------------------- SAVE CHANGES [END]
// check if we going to add new profile
if ($ADMIN && !$ID) {
    $NEW_TO_ADD = true;
}
// Set membership level
if ($ADMIN && $_POST['SetMembership'] == 'YES') {
    if (is_numeric($_POST['MembershipDays']) || $_POST['MembershipDays'] == 'unlimited' || !isset($_POST['MembershipDays'])) {
        if ($_POST['MembershipDays'] == 'unlimited' || !isset($_POST['MembershipDays'])) {
            $membership_days = 0;
        } else {
            $membership_days = (int) $_POST['MembershipDays'];
        }
        $membership_id = (int) $_POST['MembershipID'];
        $immediately = $_POST['MembershipImmediately'] == 'on';
        $membership_result = setMembership($ID, $membership_id, $membership_days, $immediately);
        if (!$membership_result) {
            $membership_message = "<font color=\"red\">Failed to set membership</font>";
        } else {
            $check_res = checkAction($ID, ACTION_ID_USE_CHAT);
            if ($check_res[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED) {
                modules_unblock($ID, 'chat');
            } else {
                modules_block($ID, 'chat');
            }
            $check_res = checkAction($ID, ACTION_ID_USE_FORUM);
            if ($check_res[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED) {
                modules_unblock($ID, 'forum');
            } else {
                modules_block($ID, 'forum');
            }
Пример #7
0
    function getBlockCode_Membership()
    {
        if (!isAdmin()) {
            return;
        }
        $sUnlimited = process_line_output(_t('_pfm_unlimited'));
        $this->aFormMembership = array('form_attrs' => array('id' => 'profile_edit_membership', 'name' => 'profile_edit_membership', 'action' => BX_DOL_URL_ROOT . 'pedit.php?ID=' . $this->iProfileID, 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => '', 'key' => '', 'uri' => '', 'uri_title' => '', 'submit_name' => 'save_membership')), 'inputs' => array('doSetMembership' => array('type' => 'hidden', 'name' => 'doSetMembership', 'value' => 'yes'), 'MembershipInfo' => array('type' => 'custom', 'caption' => _t('_Membership_current'), 'content' => ''), 'MembershipID' => array('type' => 'select', 'name' => 'MembershipID', 'caption' => _t('_Membership_name'), 'value' => '', 'values' => array(), 'required' => 0, 'attrs' => array('onchange' => 'checkStandard()'), 'checker' => array('func' => 'avail', 'params' => array(), 'error' => _t('_Membership_name_err_empty')), 'db' => array('pass' => 'Int')), 'MembershipDays' => array('type' => 'text', 'name' => 'MembershipDays', 'caption' => _t('_Membership_days'), 'value' => $sUnlimited, 'required' => 0, 'attrs' => array('onfocus' => "if(MembershipDays.value == '" . $sUnlimited . "') MembershipDays.value = ''", 'onblur' => "if(MembershipDays.value == '') MembershipDays.value = '" . $sUnlimited . "'"), 'info' => _t('_Membership_days_info'), 'db' => array('pass' => 'Xss')), 'MembershipImmediately' => array('type' => 'checkbox', 'name' => 'MembershipImmediately', 'caption' => _t('_Membership_starts'), 'value' => 'on', 'required' => 0, 'db' => array('pass' => 'Xss')), 'save_membership' => array('type' => 'submit', 'name' => 'save_membership', 'value' => _t('_Membership_save'))));
        $aMemberships = getMemberships();
        foreach ($aMemberships as $iId => $sName) {
            if ($iId != MEMBERSHIP_ID_NON_MEMBER) {
                $this->aFormMembership['inputs']['MembershipID']['values'][] = array('key' => $iId, 'value' => $sName);
            }
        }
        $oForm = new BxTemplFormView($this->aFormMembership);
        $oForm->initChecker();
        $sContent = "";
        if ($oForm->isSubmittedAndValid()) {
            $iMshipID = (int) $oForm->getCleanValue('MembershipID');
            $iMshipDays = (int) $oForm->getCleanValue('MembershipDays');
            //0 = unlim
            $bStartsNow = $oForm->getCleanValue('MembershipImmediately') == 'on';
            $bSave = setMembership($this->iProfileID, $iMshipID, $iMshipDays, $bStartsNow);
            $sContent .= MsgBox(_t($bSave ? '_Membership_save_msg_saved' : '_Membership_save_err_saved'), 3);
        }
        /**
         * Retrieve current membership info.
         */
        $aMembershipCurrent = getMemberMembershipInfo($this->iProfileID);
        $sMembershipCurrent = $aMembershipCurrent['Name'];
        if ($aMembershipCurrent['ID'] != MEMBERSHIP_ID_STANDARD) {
            $sMembershipCurrent .= ', ' . (!isset($aMembershipCurrent['DateExpires']) ? _t('_MEMBERSHIP_EXPIRES_NEVER') : _t('_MEMBERSHIP_EXPIRES', defineTimeInterval($aMembershipCurrent['DateExpires'])));
        }
        $oForm->aInputs['MembershipInfo']['content'] = $sMembershipCurrent;
        ob_start();
        ?>
        <script type="text/javascript">
        <!--
        function checkStandard()
        {
            var iId = parseInt($("[name='MembershipID']").val());
            if(iId == <?php 
        echo MEMBERSHIP_ID_STANDARD;
        ?>
) {
                $("[name='MembershipDays']").attr('disabled', 'disabled');
                $("[name='MembershipImmediately']").attr('disabled', 'disabled');
            } else {
                $("[name='MembershipDays']").removeAttr('disabled');
                $("[name='MembershipImmediately']").removeAttr('disabled');
            }
        }
        $(document).ready(function() {
            checkStandard();
        });
        -->
        </script>
<?php 
        $sContent .= ob_get_clean();
        return array($sContent . $oForm->getCode(), array(), array(), false);
    }
Пример #8
0
/**
 * Buy a membership for a member
 *
 * @param int $memberID			- member that is going to get the membership
 * @param int $membershipID		- bought membership
 * @param int $transactionID	- internal key of the transaction (ID from Transactions table)
 * @param boolean $startsNow	- if true, the membership will start immediately;
 *								  if false, the membership will start after the current
 *								  membership expires
 *
 * @return boolean				- true in case of success, false in case of failure
 *
 *
 */
function buyMembership($memberID, $membershipID, $transactionID, $startsNow = false)
{
    //input validation
    $memberID = (int) $memberID;
    $membershipID = (int) $membershipID;
    $price = (double) $price;
    $arrMembership = db_arr("SELECT \r\n            `tl`.`ID` AS `ID`, \r\n            `tlp`.`Days` AS `Days`,\r\n            `tl`.`Active` AS `Active`, \r\n            `tl`.`Purchasable` AS `Purchasable` \r\n        FROM `sys_acl_levels` AS `tl` \r\n        LEFT JOIN `sys_acl_level_prices` AS `tlp` ON `tl`.`ID`=`tlp`.`IDLevel` \r\n        WHERE `tlp`.`id`='" . $membershipID . "'");
    if (!is_array($arrMembership) || empty($arrMembership)) {
        return false;
    }
    $membershipID = (int) $arrMembership['ID'];
    //check for predefined non-purchasable memberships
    if (in_array($membershipID, array(MEMBERSHIP_ID_NON_MEMBER, MEMBERSHIP_ID_STANDARD, MEMBERSHIP_ID_PROMOTION))) {
        return false;
    }
    //check if membership is active and purchasable
    if ($arrMembership['Active'] != 'yes' || $arrMembership['Purchasable'] != 'yes') {
        return false;
    }
    return setMembership($memberID, $membershipID, $arrMembership['Days'], $startsNow, $transactionID);
}
/**
 * page code function
 */
function PageCompPageMainCode()
{
    global $ID;
    global $ConfCode;
    global $site;
    global $newusernotify;
    global $dir;
    $autoApproval_ifJoin = isAutoApproval('join');
    $p_arr = getProfileInfo($ID);
    if (!$p_arr) {
        $_page['header'] = _t("_Error");
        $_page['header_text'] = _t("_Profile Not found");
        $ret = "<table width=\"100%\" cellpadding=4 cellspacing=4><td align=center class=text2>";
        $ret .= _t('_Profile Not found Ex');
        $ret .= "</td></table>";
        return $ret;
    }
    ob_start();
    echo "<table width=\"100%\" cellpadding=4 cellspacing=4><td align=center class=text2>";
    if ($p_arr['Status'] == 'Unconfirmed') {
        $ConfCodeReal = base64_encode(base64_encode(crypt($p_arr[Email], "secret_confirmation_string")));
        if (strcmp($ConfCode, $ConfCodeReal) != 0) {
            ?>
<b><?php 
            echo _t("_Profile activation failed");
            ?>
</b><br /><br />
<?php 
            echo _t("_EMAIL_CONF_FAILED_EX");
            ?>
<br />
<center><form action="<?php 
            echo $_SERVER[PHP_SELF];
            ?>
" method=get>
<input type=hidden name="ConfID" value="<?php 
            echo $ID;
            ?>
">
<table class=text>
    <td><b><?php 
            echo _t("_Confirmation code");
            ?>
:</b> </td>
    <td><input class=no name="ConfCode"></td>
    <td>&nbsp;</td>
    <td><input class=no type="submit" value=" <?php 
            echo _t("_Submit");
            ?>
 "></td>
</table>
</form></center>
<?php 
        } else {
            if ($autoApproval_ifJoin) {
                $status = 'Active';
                $message = getParam("t_Activation");
                $subject = getParam('t_Activation_subject');
                sendMail($p_arr['Email'], $subject, $message, $p_arr['ID']);
            } else {
                $status = 'Approval';
            }
            $update = db_res("UPDATE `Profiles` SET `Status` = '{$status}' WHERE `ID` = '{$ID}';");
            createUserDataFile($ID);
            reparseObjTags('profile', $ID);
            // Promotional membership
            if (getParam('enable_promotion_membership') == 'on') {
                $memership_days = getParam('promotion_membership_days');
                setMembership($p_arr['ID'], MEMBERSHIP_ID_PROMOTION, $memership_days, true);
            }
            echo _t("_EMAIL_CONF_SUCCEEDED", $site['title']);
            ?>
<br /><br />
<center><a href="member.php"><b><?php 
            echo _t("_Continue");
            ?>
 &gt;&gt;</b></a></center>
<?php 
            if ($newusernotify) {
                $message = "New user {$p_arr['NickName']} with email {$p_arr['Email']} has been confirmed,\nhis/her ID is {$p_arr['ID']}.\n--\n{$site['title']} mail delivery system\n<Auto-generated e-mail, please, do not reply>\n";
                $subject = "New user confirmed";
                sendMail($site['email_notify'], $subject, $message);
            }
        }
    } else {
        echo _t('_ALREADY_ACTIVATED');
    }
    echo "</td></table>";
    $ret = ob_get_contents();
    ob_end_clean();
    return $ret;
}
Пример #10
0
    PageCode();
    exit;
}
$member['ID'] = (int) $_COOKIE['memberID'];
$_page['header'] = _t("_GETMEM_H");
$_page['header_text'] = _t("_GETMEM_H1");
$affnum_arr = db_arr("SELECT `aff_num` FROM `Profiles` WHERE `ID` = '{$member['ID']}' LIMIT 1");
$levels_res = db_res("SELECT * FROM `members_as_aff` WHERE `num_of_mem` <= '{$affnum_arr['aff_num']}'");
// --------------- GET/POST actions
if ($_POST['upgrade'] == 'YES') {
    $memtype_arr = split('-', $_POST['MemType']);
    $membershipID = (int) $memtype_arr[0];
    $membershipNumOfDays = (int) $memtype_arr[1];
    $arr = db_arr("SELECT * FROM `members_as_aff` WHERE `MID` = '{$membershipID}' AND `num_of_days` = '{$membershipNumOfDays}' AND `num_of_mem` <= '{$affnum_arr['aff_num']}' LIMIT 1");
    if ($arr) {
        setMembership($member['ID'], $arr['MID'], $arr['num_of_days']);
        $membership_info = getMembershipInfo($arr['MID']);
        db_res("UPDATE `Profiles` SET `aff_num` = `aff_num` - {$arr['num_of_mem']} WHERE `ID` = '{$member['ID']}'");
        createUserDataFile($member['ID']);
        $upgrade_out = "\r\n\t\t\t<table align=center width=\"400\" class=\"text\">\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t" . _t("_Got_new_membership_part_1") . $membership_info['Name'] . _t("_Got_new_membership_part_2") . $arr['num_of_days'] . _t("_Got_new_membership_part_3") . "\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>";
    } else {
        $upgrade_out = "";
    }
}
// --------------- page components
$_ni = $_page['name_index'];
$_page_cont[$_ni]['page_main_code'] = $_POST['upgrade'] == 'YES' && strlen($upgrade_out) ? $upgrade_out : PageCompPageMainCode();
// --------------- [END] page components
PageCode();
// --------------- page components functions
function PageCompPageMainCode()