function print_row_search_content($name, $content, $search_hide, $class = "", $section_hide = 0, $display_name = "")
{
    global $odd;
    global $c_search_table;
    $name2 = $name;
    $name = _t($display_name);
    if ($search_hide) {
        $div_hide = "none";
        $div_show = "block";
    } else {
        $div_hide = "block";
        $div_show = "none";
    }
    if ($section_hide) {
        $section_display = 'none';
    } else {
        $section_display = 'block';
    }
    $ret = "\n\t\t<div class=\"search_show_hide\">\n\t\t\t<div id=\"div_hide_{$name2}\" style=\"display:{$div_hide}\">\n\t\t\t\t<a href=\"javascript:void(0)\" onClick=\"javascript: ShowHideHide(document.getElementById('div_show_{$name2}'),document.getElementById('table_hide_{$name2}'),document.getElementById('div_hide_{$name2}'));\">" . _t("_Hide") . "</a>\n\t\t\t</div>\n\n\t\t\t<div id=\"div_show_{$name2}\" style=\"display:{$div_show}\">\n\t\t\t\t<a href=\"javascript:void(0)\" onClick=\"javascript: ShowShowHide(document.getElementById('table_hide_{$name2}'),document.getElementById('div_hide_{$name2}'),document.getElementById('div_show_{$name2}'));\">" . _t("_Show") . "</a>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<table id=\"table_hide_{$name2}\" cellspacing=\"1\" cellpadding=\"0\" style=\"display:{$div_hide};\" align=\"center\" width=\"85%\" border=\"0\">\n\t\t\t\t" . $content . "\n\t\t</table>";
    return "<div id=\"section_{$name2}\" style=\"display:{$section_display}\">" . DesignBoxContentBorder($name, $ret) . "</div>";
}
function displayRayMP3Player()
{
    global $member;
    $chechActionRes = checkAction($member['ID'], ACTION_ID_USE_RAY_MP3);
    if ($chechActionRes[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED) {
        $ret = '';
        $ret .= '<div id="playerBlock">' . "\n";
        $ret .= getRayMP3Player($member['ID'], getPassword($member['ID']), $member['ID']) . "\n";
        $ret .= '</div>' . "\n";
        $langShow = _t('_Show');
        $langHide = _t('_Hide');
        $menu = '<div class="block_menu" onclick="javascript: if ( \'none\' == document.getElementById(\'playerBlock\').style.display ) { document.getElementById(\'playerBlock\').style.display=\'block\'; this.innerHTML=\'' . $langHide . '\'; } else { document.getElementById(\'playerBlock\').style.display=\'none\'; this.innerHTML=\'' . $langShow . '\'; }" >' . $langHide . '</div>';
        return DesignBoxContentBorder(_t('_mp3_player'), $ret, $menu);
    }
    return '';
}
/**
 * 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;
}
/**
 * "Search by ID"
 */
function PageCodeSearchByID()
{
    global $w_ex;
    global $tmpl;
    ob_start();
    ?>
    <form method=get action="search_result.php"><br />
    <input class=no name="ID" size=13 id="by_nick_id" /><br />
	<br />
<?php 
    echo "<input class=no type=\"submit\" value=" . _t("_Fetch") . " />";
    ?>

    </form><br />
<?php 
    $out = ob_get_contents();
    ob_end_clean();
    if ($tmpl == 'adl') {
        $w_ex = 0;
    }
    $ret = DesignBoxContentBorder(_t("_Search by ID"), $out);
    return $ret;
}
/**	
 * Starts transaction process for specified transaction
 * 
 * @param int $localTranID				- starting transaction database ID
 * @param bool $recurring				- indicates whether transaction recurring or not
 * @param int $recurringDays			- if $recurring true, then this value specifies
 * 										  subscription days
 * 
 * @return bool 						- true if start is successful, false otherwise
 * 
 * 
 */
function moduleStartTransaction($localTranID, $recurring = false, $recurringDays = 0)
{
    global $providerConf;
    global $checkoutURL;
    global $memberID;
    // defined in checkout.inc.php
    global $cryptKey;
    global $currency_code;
    global $_page;
    global $_page_cont;
    global $_ni;
    global $date_format;
    // validate arguments
    $localTranID = (int) $localTranID;
    $recurringDays = (int) $recurringDays;
    $tranRes = db_res("SELECT DATE_FORMAT(`Date`,  '{$date_format}' ) AS 'Date', `Amount`, `Currency`, `Status`, `Data`, `Description` FROM `Transactions`\r\n\t\t\t\t\t\t\tWHERE `ID` = {$localTranID}\r\n\t\t\t\t\t\t\tAND `Status` = 'pending'\r\n\t\t\t\t\t\t\tAND `IDProvider` = {$providerConf['ID']}");
    if (!$tranRes || mysql_num_rows($tranRes) == 0) {
        return false;
    }
    $tranArr = mysql_fetch_assoc($tranRes);
    $tranData = transStringToData($tranArr['Data']);
    if ($providerConf['Param_implementation'] == 'AIM') {
        $profileEmail = '';
        $_page = array();
        $_page_cont = array();
        $_page['name_index'] = 0;
        $_page['css_name'] = 'checkout.css';
        $_ni = $_page['name_index'];
        $_page['header'] = $providerConf['Caption'];
        $_page['header_text'] = $providerConf['Caption'];
        ob_start();
        $expDateMonthes = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
        $expDateYears = array('2004', '2005', '2006', '2007', '2008', '2009', '2010');
        ?>
<center>
	<form id="authSendForm" action="<?php 
        echo $checkoutURL;
        ?>
" method="post" style="margin: 0px;">
	<input type="hidden" name="auth_tran_id" value="<?php 
        echo $localTranID;
        ?>
" />
	<table cellpadding="4" cellspacing="0" border="0" width="360">
		<tr>
			<td align="center" colspan="2" class="field_value"><?php 
        echo $tranArr['Description'];
        ?>
</td>
		</tr>
		<tr>
			<td align="left"><?php 
        echo _t('_Credit card number');
        ?>
:</td>
			<td align="left" width="160"><input type="text" class="no" name="auth_card_num" style="width: 150px" /></td>
		</tr>
		<tr>
			<td align="left"><?php 
        echo _t('_Expiration date');
        ?>
:</td>
			<td align="left" width="160">
				<select class="no" name="auth_expire_month">
<?php 
        foreach ($expDateMonthes as $month) {
            echo "<option value=\"{$month}\">{$month}</option>";
        }
        ?>
				</select>&nbsp;
				<select class="no" name="auth_expire_year">
<?php 
        foreach ($expDateYears as $year) {
            echo "<option value=\"{$year}\">{$year}</option>";
        }
        ?>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left"><?php 
        echo _t('_E-mail');
        ?>
:</td>
			<td align="left" width="160"><input type="text" class="no" name="auth_email" value="<?php 
        echo $profileEmail;
        ?>
" style="width: 150px" /></td>
		</tr>
		<tr>
			<td align="center" colspan="2"><input type="submit" class="no" name="send_data" value="<?php 
        echo _t('_Check Out');
        ?>
" style="width: 100px" /></td>
		</tr>
	</table>
	</form>
</center>
<?php 
        $content = ob_get_contents();
        ob_end_clean();
        $designBox = DesignBoxContentBorder($providerConf['Caption'], $content);
        $_page_cont[$_ni]['page_main_code'] = '<div style="width: 380px; margin-left: auto; margin-right: auto;">' . $designBox . '</div>';
        PageCode();
        exit;
    } elseif ($providerConf['Param_implementation'] == 'SIM') {
        $actionURL = 'https://secure.authorize.net/gateway/transact.dll';
        $formData = array();
        $timestamp = time();
        srand($timestamp);
        $sequence = rand(1, 1000);
        // account ID
        $formData['x_login'] = $providerConf['Param_x_login'];
        $formData['x_fp_sequence'] = $sequence;
        $formData['x_fp_timestamp'] = $timestamp;
        $formData['x_fp_hash'] = calculateFingerPrint($timestamp, $sequence, $tranArr['Amount'], $currency_code);
        // transaction common data
        $formData['x_method'] = 'CC';
        $formData['x_type'] = 'AUTH_CAPTURE';
        $formData['x_amount'] = sprintf("%.2f", (double) $tranArr['Amount']);
        $formData['x_description'] = $tranArr['Description'];
        $formData['x_invoice_num'] = $localTranID;
        $formData['x_version'] = '3.1';
        $formData['x_show_form'] = 'PAYMENT_FORM';
        $formData['x_relay_response'] = 'TRUE';
        $formData['x_email_customer'] = 'FALSE';
        $formData['x_cust_id'] = $memberID;
        // return and redirect
        $formData['x_relay_url'] = $checkoutURL;
        // test mode
        $formData['x_test_request'] = $providerConf['Mode'] == 'live' ? 'FALSE' : 'TRUE';
        Redirect($actionURL, $formData, 'post', $providerConf['Caption']);
        exit;
    }
}
function PageCodeSearchByTag()
{
    ob_start();
    ?>
    <div class="search_by_tag">
	    <form method="GET" action="<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
">
	    	<input type="text" class="input_by_tag" name="Tags" />
	    	<br />
			<input type="submit" value="<?php 
    echo _t('_Fetch');
    ?>
" />
	    </form>
	</div>
	<?php 
    return DesignBoxContentBorder(_t('_Search by Tag'), ob_get_clean());
}
/**
 * Place HTML code for search result
 */
function PageCompGallery()
{
    global $result;
    global $gallery_cols;
    global $boxbg;
    global $boxbg2;
    global $boxbg3;
    global $site;
    global $tmpl;
    global $logged;
    global $max_thumb_width;
    global $max_thumb_height;
    $ret = "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\">";
    $count = 0;
    while ($p_arr = mysql_fetch_array($result)) {
        // get user online status
        $user_is_online = (int) $p_arr['is_onl'];
        //get_user_online_status($p_arr['ID']);
        // online/offline status
        if ($user_is_online) {
            $offline_online = "<img border=\"0\" src=\"{$site['icons']}online.gif\" alt=\"" . _t("_Online") . "\" />";
            $off_on_text = _t("_Online");
        } else {
            $offline_online = "<img border=\"0\" src=\"{$site['icons']}offline.gif\" alt=\"" . _t("_Offline") . "\" />";
            $off_on_text = _t("_Offline");
        }
        if ($tmpl == 'act') {
            $offline_online = "<table style=\"margin-top:2px; margin-bottom:2px;\" border=0 cellspacing=0 cellpadding=0><tr height=15><td width=4 height=15><img src=templates/tmpl_act/images_act/button2_left.gif width=4 height=15></td><td width=10 height=15 valign=middle background=templates/tmpl_act/images_act/button2_fill.gif>" . $offline_online . "</td>";
            $offline_online = $offline_online . "<td height=15 valign=top background=templates/tmpl_act/images_act/button2_fill.gif class=small3>&nbsp;" . $off_on_text . "</td><td width=4 height=15><img src=templates/tmpl_act/images_act/button2_right.gif width=4 height=15></td></tr></table>";
        }
        if (!($count % $gallery_cols)) {
            $ret .= "<tr>\r\n                        \t\t\t<td>\r\n                        \t\t\t\t<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr><td align=\"center\">";
        } else {
            $ret .= "<td align=\"center\">";
        }
        // -----------------
        $out = "";
        $out .= "<table border=\"0\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\" width=\"{$max_thumb_width}\">\n";
        $out .= "<tr>";
        $out .= "<td height=\"{$max_thumb_height}\" align=\"center\">\n";
        $out .= get_member_thumbnail($p_arr['ID'], none);
        $out .= "</td>";
        $out .= "</tr>\n";
        $out .= "<tr><td align=\"center\">\n";
        $out .= $offline_online;
        $out .= "</td></tr>\n";
        $out .= "</table>\n";
        $ret .= DesignBoxContentBorder("<div STYLE=\"font-weight:normal; text-transform:none; overflow : hidden\">{$p_arr['NickName']}: " . age($p_arr[DateOfBirth]) . " " . _t("_y/o") . "</div>", $out);
        // -------------------
        if (!(($count + 1) % $gallery_cols)) {
            $ret .= "</td></table> </td></tr>";
        } else {
            $ret .= "";
        }
        $count += 1;
    }
    if ($count % $gallery_cols) {
        $ret .= "</td></table>\n </td></tr>\n";
    }
    $ret .= "</table>\n\n";
    return $ret;
}
 /**
  * page show participants function
  * @return HTML presentation of data
  */
 function PageSDatingShowParticipants()
 {
     global $site;
     global $oTemplConfig;
     $sRetHtml = '';
     $sEventParticipantsC = _t('_Event participants');
     $sListOfParticipantsC = _t('_List') . ' ' . _t('_of') . ' ' . _t('_Participants');
     // collect information about current member
     if ($logged['member']) {
         $aMember['ID'] = (int) $_COOKIE['memberID'];
         $aMemberData = getProfileInfo($aMember['ID']);
     } else {
         $aMember['ID'] = 0;
     }
     $aMembership = getMemberMembershipInfo($aMember['ID']);
     $iEventID = (int) $_REQUEST['event_id'];
     $sQuery = "\r\n\t\t\tSELECT `ID`, `Title`,\r\n\t\t\t\t(NOW() > `EventEnd` AND NOW() < DATE_ADD(`EventEnd`, INTERVAL `ChoosePeriod` DAY)) AS `ChooseActive`\r\n\t\t\tFROM `SDatingEvents`\r\n\t\t\tWHERE\r\n\t\t\t\t`ID` = {$iEventID} AND `Status` = 'Active' AND `AllowViewParticipants` = 1";
     $aEventData = db_arr($sQuery);
     if (!$aEventData['ID']) {
         return DesignBoxContent('', '<center>' . _t('_Event is unavailable') . '</center>', $oTemplConfig->PageSDatingShowParticipants_db_num);
     }
     $sRetHtml .= '<div class="text">' . process_line_output($aEventData['Title']) . '</div>';
     // list of participants
     $aSelfPart = db_arr("SELECT `ID` FROM `SDatingParticipants`\r\n\t\t\t\t\t\t\t\t\tWHERE `IDEvent` = {$iEventID}\r\n\t\t\t\t\t\t\t\t\tAND `IDMember` = {$aMember['ID']}");
     $iPartPage = isset($_REQUEST['part_page']) ? (int) $_REQUEST['part_page'] : 1;
     $iPartPPerPage = isset($_REQUEST['part_p_per_page']) ? (int) $_REQUEST['part_p_per_page'] : 30;
     $iLimitFirst = (int) ($iPartPage - 1) * $iPartPPerPage;
     $vPartProfilesRes = db_res("SELECT `Profiles`.*, `SDatingParticipants`.`ParticipantUID` AS `UID`\r\n\t\t\t\t\t\t\t\t\t\tFROM `SDatingParticipants`\r\n\t\t\t\t\t\t\t\t\t\tINNER JOIN `Profiles` ON `SDatingParticipants`.`IDMember` = `Profiles`.`ID`\r\n\t\t\t\t\t\t\t\t\t\tWHERE `SDatingParticipants`.`IDEvent` = {$iEventID}\r\n\t\t\t\t\t\t\t\t\t\tORDER BY `Profiles`.`NickName`\r\n\t\t\t\t\t\t\t\t\t\tLIMIT {$iLimitFirst}, {$iPartPPerPage}");
     $aTotal = db_arr("SELECT COUNT(*) FROM `SDatingParticipants`\r\n\t\t\t\t\t\t\t\t\tWHERE `SDatingParticipants`.`IDEvent` = {$iEventID}");
     $iPartProfilesTotal = (int) $aTotal[0];
     $iPagesNum = ceil($iPartProfilesTotal / $iPartPPerPage);
     $sPartGetUrl = "{$_SERVER['PHP_SELF']}?action=show_part&amp;event_id={$iEventID}" . (isset($_REQUEST['part_p_per_page']) ? '&amp;part_p_per_page=' . (int) $_REQUEST['part_p_per_page'] : '');
     if ($iPartProfilesTotal == 0) {
         $sRetHtml .= _t('_There are no participants for this event');
     } else {
         if ($iPagesNum > 1) {
             $sRetHtml .= '<div class="text">' . _t('_Pages') . ':&nbsp;';
             for ($i = 1; $i <= $iPagesNum; $i++) {
                 if ($i == $iPartPage) {
                     $sRetHtml .= "[{$i}]&nbsp;";
                 } else {
                     $sRetHtml .= "<a href=\"{$sPartGetUrl}&amp;part_page={$i}\">{$i}</a>&nbsp;";
                 }
             }
             $sRetHtml .= '</div><br />';
         }
         $sProfilesTrs = '';
         while ($part_profiles_arr = mysql_fetch_assoc($vPartProfilesRes)) {
             $iUserIsOnline = get_user_online_status($part_profiles_arr[ID]);
             $sCont = get_member_thumbnail($part_profiles_arr['ID'], 'none') . '<br /><center>' . getProfileOnlineStatus($iUserIsOnline) . '</center>';
             $sProfilesTrs .= DesignBoxContentBorder(process_line_output(strmaxtextlen($part_profiles_arr['NickName'], 11)) . ': ' . age($part_profiles_arr['DateOfBirth']) . ' ' . _t('_y/o'), $sCont);
         }
         $sNicknameC = _t('_Nickname');
         $sDateOfBirthC = _t('_DateOfBirth');
         $sSexC = _t('_Sex');
         $sEventUIDC = _t('_Event UID');
         $sChooseParts = '';
         // show 'choose participants' link only during choose period and if member is participant of this event
         // if ( $this->bAdminMode==FALSE || ($aEventData['ChooseActive'] && $aSelfPart['ID'] )) {
         // $sChooseParts = '<div class="text" align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=select_match&amp;event_id='.$iEventID.'">'._t('_Choose participants you liked').'</a></div><br />';
         // }
         $sPagesHref = '';
         if ($iPagesNum > 1) {
             $sPagesHref .= '<div class="text">' . _t('_Pages') . ':&nbsp;';
             for ($i = 1; $i <= $iPagesNum; $i++) {
                 if ($i == $iPartPage) {
                     $sPagesHref .= "[{$i}]&nbsp;";
                 } else {
                     $sPagesHref .= "<a href=\"{$sPartGetUrl}&amp;part_page={$i}\">{$i}</a>&nbsp;";
                 }
             }
             $sPagesHref .= '</div><br />';
         }
         $sRetHtml .= $sProfilesTrs . $sPagesHref;
     }
     return DesignBoxContent($sListOfParticipantsC, $sRetHtml, $oTemplConfig->PageSDatingShowParticipants_db_num);
 }