/**
 * page code function
 */
function PageCompPageMainCode()
{
    global $site;
    global $prof;
    $query = "\n\t\tSELECT\n\t\t\t`id_poll`,\n\t\t\t`id_profile`,\n\t\t\t`poll_question`,\n\t\t\t`Profiles`.*\n\t\tFROM `ProfilesPolls`\n\t\tLEFT JOIN `Profiles` ON\n\t\t\t`id_profile` = `Profiles`.`ID`\n\t\tWHERE\n\t\t\t`poll_status` = 'active'\n\t\t\tAND `poll_approval`\n\t\tORDER BY `id_poll` DESC\n\t\t";
    //$query = "SELECT `ID`, `Question` FROM `polls_q` WHERE `Active` = 'on' ORDER BY `Question`";
    $res = db_res($query);
    if ($res and mysql_num_rows($res)) {
        $ret = '<div class="clear_both"></div>';
        while ($arr = mysql_fetch_array($res)) {
            $age_str = _t("_y/o", age($arr['DateOfBirth']));
            $y_o_sex = $age_str . '&nbsp;' . _t("_" . $arr['Sex']);
            $poll_coutry = _t("__" . $prof['countries'][$arr['Country']]);
            $ret .= '<div class="pollBody">';
            $ret .= '<div class="clear_both"></div>';
            $ret .= '<div class="pollInfo">';
            $ret .= get_member_icon($arr['id_profile'], 'left');
            $ret .= '<div class="pollInfo_nickname">';
            $ret .= _t('_Submitted by', $arr['NickName']);
            $ret .= '</div>';
            $ret .= '<div class="pollInfo_info">';
            $ret .= $y_o_sex . '<br />' . $poll_coutry;
            $ret .= '</div>';
            $ret .= '</div>';
            $ret .= '<div class="clear_both"></div>';
            $ret .= ShowPoll($arr['id_poll']);
            $ret .= '<div class="clear_both"></div>';
            $ret .= '</div>';
        }
        $ret .= '<div class="clear_both"></div>';
    } else {
        $ret = "<div align=center>" . _t("_No polls available") . "</div>\n";
    }
    return $ret;
}
/**
 * page code function
 */
function PageCompPageMainCode()
{
    global $site;
    $ID = (int) $_GET['ID'];
    if (!$ID) {
        return false;
    }
    $ret = '';
    $ret .= '<div class="pollBody">';
    $ret .= '<div class="clear_both"></div>';
    $ret .= ShowPoll($ID);
    $ret .= '<div class="clear_both"></div>';
    $ret .= '</div>';
    return $ret;
}
 function showBlockProfilePolls($sCaption, $bNoDB = false)
 {
     $sqlPolls = "SELECT `id_poll` FROM `ProfilesPolls` WHERE `id_profile` = {$this->_iProfileID} AND `poll_status` = 'active' AND `poll_approval`";
     $rPolls = db_res($sqlPolls);
     if (!mysql_num_rows($rPolls)) {
         return;
     }
     $ret = '<div id="profile_poll_wrap">';
     while ($aPoll = mysql_fetch_assoc($rPolls)) {
         $ret .= '<div class="blog_wrapper_n" style="width:80%;border:1px dashed #CCCCCC;">' . ShowPoll($aPoll['id_poll']);
         $ret .= '</div><div class="clear_both"></div>';
     }
     $ret .= '</div>';
     $show_hide = $this->genShowHideItem('profile_poll_wrap');
     if ($bNoDB) {
         return $ret;
     } else {
         echo DesignBoxContent(_t($sCaption), $ret, 1, $show_hide);
     }
 }
/**
 * page code function
 */
function ThisPageMainCode()
{
    global $logged;
    global $member;
    // create poll section -------------------------------------------------------------------
    $ret .= '<div class="createPollSection">';
    $query = "SELECT COUNT(id_poll) FROM ProfilesPolls WHERE id_profile = '{$member['ID']}'";
    $ras_arr = db_arr($query);
    $polls_num = db_arr($query);
    $profile_poll_num = getParam("profile_poll_num");
    if ($profile_poll_num && $polls_num[0] < $profile_poll_num) {
        // limit number of polls
        $ret .= ShowPollCreationForm();
    } else {
        $ret .= _t('_max_poll_reached');
    }
    $ret .= '</div>';
    // show polls section --------------------------------------------------------------------
    $ret .= '<div class="pollContainer" id="pol_container">';
    $ret .= '<div class="clear_both"></div>';
    $query = "SELECT id_poll, poll_status FROM ProfilesPolls WHERE id_profile = '{$member['ID']}'";
    $polls_num = db_res($query);
    while ($poll_arr = mysql_fetch_array($polls_num)) {
        $uID = $poll_arr['id_poll'];
        $ret .= '<div id="pol_container_pol_' . $uID . '" class="controlsDiv">';
        $ret .= ShowPoll($uID);
        $ret .= '<div class="innerControlBlock">';
        //$ret .= '<div class="controlsHeader">' . _t('_controls') . ':</div>';
        $sCurStatus = '';
        $sCTStatus = '';
        $status_change_to = '';
        if ('active' == $poll_arr['poll_status']) {
            $sCurStatus = _t('_Active');
            $sCTStatus = _t('_Disabled');
            $status_change_to = 'disabled';
        } else {
            $sCurStatus = _t('_Disabled');
            $sCTStatus = _t('_Active');
            $status_change_to = 'active';
        }
        $ret .= "<span id=\"poll_status_{$uID}\" style=\"padding: 0px 2px;\"></span>";
        $ret .= '<span class="deleteDiv"><a href="#" onclick=" if ( window.confirm(\'' . _t('_are you sure?') . '\') ) { send_data( \'\', \'delete\', \'\', \'' . $uID . '\' ); del_question_bar( document.getElementById(\'pol_container\'), document.getElementById(\'pol_container_pol_' . $uID . '\') ); } return false;">' . _t('_delete') . '</a></span>';
        $ret .= '<script language="javascript">
			poll_status_show( \'' . $uID . '\', \'poll_status_' . $uID . '\', \'' . $poll_arr['poll_status'] . '\', \'' . $status_change_to . '\', \'' . $sCurStatus . '\', \'' . $sCTStatus . '\' );
	    	    </script>';
        $ret .= '</div>';
        $ret .= '</div>';
    }
    // if no polls
    if (!$uID) {
        $ret .= _t_err('_no poll');
    }
    $ret .= '<div class="clear_both"></div>';
    $ret .= '</div>';
    return $ret;
}
			<div style="float:left;margin-right:5px;margin-top:5px;border: solid 1px #cccccc;background-color: #f6f6ff;">
			    <div style="position:relative; padding-top:25px;width:260px; height:160px;">
					<div style="position:absolute; top:4px; left:4px;">
						<input type="checkbox" id="<?php 
        echo $arr['id_poll'];
        ?>
" value="poll" name="<?php 
        echo $arr['id_poll'];
        ?>
">
					</div>
					<label for="<?php 
        echo $arr['id_profile'];
        ?>
"><?php 
        echo ShowPoll($arr['id_poll']);
        ?>
</label>
			    </div>
				<div style="text-align:center; background-color:#FFFFFF;padding:3px;">
					<a href="<?php 
        echo $site['url'];
        ?>
profile.php?ID=<?php 
        echo $arr['id_profile'];
        ?>
" target="_blank">View Profile</a> |
					<a href="<?php 
        echo $site['url'];
        ?>
pedit.php?ID=<?php 
 function showBlockProfilePolls($sCaption)
 {
     $sqlPolls = "SELECT `id_poll` FROM `ProfilesPolls` WHERE `id_profile` = {$this->_iProfileID} AND `poll_status` = 'active' AND `poll_approval`";
     $rPolls = db_res($sqlPolls);
     if (!mysql_num_rows($rPolls)) {
         return;
     }
     $ret = '<div id="profile_poll_wrap">';
     while ($aPoll = mysql_fetch_assoc($rPolls)) {
         $ret .= ShowPoll($aPoll['id_poll']);
         $ret .= '<div class="clear_both"></div>';
     }
     $ret .= '</div>';
     $show_hide = $this->genShowHideItem('profile_poll_wrap');
     echo DesignBoxContent(_t($sCaption), $ret, 1, $show_hide);
 }
    function getBlockCode_ProfilePoll()
    {
        global $getBlockCode_ProfilePoll_db_num;
        global $oTemplConfig;
        global $aPreValues;
        $query = "\r\n\t\t\tSELECT\r\n\t\t\t\t`id_poll`,\r\n\t\t\t\t`id_profile`,\r\n\t\t\t\t`Profiles`.*\r\n\t\t\tFROM `ProfilesPolls`\r\n\t\t\tLEFT JOIN `Profiles` ON\r\n\t\t\t\t`id_profile` = `Profiles`.`ID`\r\n\t\t\tWHERE\r\n\t\t\t\t`poll_status` = 'active'\r\n\t\t\t\tAND `poll_approval`\r\n\t\t\t";
        $mode = strlen($_GET['ppoll_mode']) ? $_GET['ppoll_mode'] : 'last';
        $aDBTopMenu = array();
        //$menu = '<div class="dbTopMenu">';
        foreach (array('admin', 'last', 'top', 'rand') as $sMyMode) {
            switch ($sMyMode) {
                //admin polls
                case 'admin':
                    $sModeTitle = _t('_Admin');
                    break;
                    // random polls
                // random polls
                case 'rand':
                    if ($mode == $sMyMode) {
                        $query .= " ORDER BY RAND() LIMIT 2";
                    }
                    $sModeTitle = _t('_Random');
                    break;
                    // latest polls
                // latest polls
                case 'last':
                    if ($mode == $sMyMode) {
                        $query .= " ORDER BY id_poll DESC LIMIT 2";
                    }
                    $sModeTitle = _t('_Latest');
                    break;
                    // top polls
                // top polls
                case 'top':
                    if ($mode == $sMyMode) {
                        $query .= " ORDER BY poll_total_votes DESC LIMIT 2";
                    }
                    $sModeTitle = _t('_Top');
                    break;
            }
            /*if( $sMyMode == $mode )
            			$menu .= "<div class=\"active\">$sModeTitle</a></div>";
            		else
            			$menu .= "<div class=\"notActive\"><a href=\"{$_SERVER['PHP_SELF']}?ppoll_mode=$sMyMode\" class=\"top_members_menu\" onclick=\"getHtmlData( 'profile_poll_cont', this.href+'&amp;show_only=ppoll');return false;\">$sModeTitle</a></div>";*/
            $aDBTopMenu[$sModeTitle] = array('href' => "{$_SERVER['PHP_SELF']}?ppoll_mode={$sMyMode}", 'dynamic' => true, 'active' => $sMyMode == $mode);
        }
        /*$menu .= '<div class="clear_both"></div>';
        		$menu .= '</div>';*/
        if ($mode == 'admin') {
            $ret = $this->getBlockCode_SitePolls();
        } else {
            $ret = '';
            $poll_res = db_res($query);
            if (mysql_num_rows($poll_res) == 0) {
                $ret .= '<div class="no_result"><div>';
                $ret .= _t("_No profile polls available.");
                $ret .= '</div></div>';
            } else {
                while ($poll_arr = mysql_fetch_array($poll_res)) {
                    $age_str = _t("_y/o", age($poll_arr['DateOfBirth']));
                    $y_o_sex = $age_str . '&nbsp;' . _t("_" . $poll_arr['Sex']);
                    $poll_coutry = _t($aPreValues['Country'][$poll_arr['Country']]['LKey']);
                    //$NickName = "<b><a href=\"".getProfileLink($poll_arr['ID'])."\">{$poll_arr['NickName']}</a></b>";
                    $sNickName = $poll_arr['NickName'];
                    $sNickNameLnk = getProfileLink($poll_arr['ID']);
                    ///////////////////////////////////
                    $sPic = get_member_icon($poll_arr['ID'], 'left');
                    $sPoll = ShowPoll($poll_arr['id_poll']);
                    $ret .= <<<EOF
<div class="blog_block">
\t<div class="icon_block">
\t\t{$sPic}
\t</div>
\t<div class="blog_wrapper_n" style="width:80%;border:1px dashed #CCCCCC;">
\t\t<div class="blog_subject_n">
\t\t\t<a href="{$sNickName}" class="bottom_text">
\t\t\t\t{$sNickName}
\t\t\t</a>
\t\t</div>
\t\t<div class="blogSnippet">
\t\t\t{$sPoll}
\t\t</div>
\t</div>
</div>
<div class="clear_both"></div>
EOF;
                    /*
                    				$ret .= '<div class="pollInfo">';
                    					$ret .= get_member_icon( $poll_arr['ID'], 'left' );
                    					$ret .= '<div class="featured_info">';
                    						$ret .= '<div class="featured_nickname">';
                    							$ret .= $NickName;
                    						$ret .= '</div>';
                    					
                    						$ret .= '<div class="pollBody">';
                    							$ret .= ShowPoll( $poll_arr['id_poll'] );
                    						$ret .= '</div>';
                    					$ret .= '</div>';
                    					$ret .= '<div class="clear_both"></div>';
                    				$ret .= '</div>';
                    				
                    				$ret .= '<div class="clear_both"></div>';*/
                }
            }
        }
        return array($ret, $aDBTopMenu);
        //return $ret;
    }
function PageCompProfilePollContent($sCaption)
{
    global $PageCompProfilePoll_db_num;
    global $oTemplConfig;
    global $prof;
    $query = "\r\n\t\tSELECT\r\n\t\t\t`id_poll`,\r\n\t\t\t`id_profile`,\r\n\t\t\t`Profiles`.*\r\n\t\tFROM `ProfilesPolls`\r\n\t\tLEFT JOIN `Profiles` ON\r\n\t\t\t`id_profile` = `Profiles`.`ID`\r\n\t\tWHERE\r\n\t\t\t`poll_status` = 'active'\r\n\t\t\tAND `poll_approval`\r\n\t\t";
    $mode = strlen($_GET['ppoll_mode']) ? $_GET['ppoll_mode'] : 'last';
    $menu = '<div class="dbTopMenu">';
    foreach (array('admin', 'last', 'top', 'rand') as $sMyMode) {
        switch ($sMyMode) {
            //admin polls
            case 'admin':
                $sModeTitle = _t('_Admin');
                break;
                // random polls
            // random polls
            case 'rand':
                if ($mode == $sMyMode) {
                    $query .= " ORDER BY RAND() LIMIT 2";
                }
                $sModeTitle = _t('_Random');
                break;
                // latest polls
            // latest polls
            case 'last':
                if ($mode == $sMyMode) {
                    $query .= " ORDER BY id_poll DESC LIMIT 2";
                }
                $sModeTitle = _t('_Latest');
                break;
                // top polls
            // top polls
            case 'top':
                if ($mode == $sMyMode) {
                    $query .= " ORDER BY poll_total_votes DESC LIMIT 2";
                }
                $sModeTitle = _t('_Top');
                break;
        }
        if ($sMyMode == $mode) {
            $menu .= "<div class=\"active\">{$sModeTitle}</a></div>";
        } else {
            $menu .= "<div class=\"notActive\"><a href=\"{$_SERVER['PHP_SELF']}?ppoll_mode={$sMyMode}\" class=\"top_members_menu\" onclick=\"getHtmlData( 'profile_poll_cont', this.href+'&amp;show_only=ppoll');return false;\">{$sModeTitle}</a></div>";
        }
    }
    $menu .= '<div class="clear_both"></div>';
    $menu .= '</div>';
    if ($mode == 'admin') {
        $ret = PageCompSitePolls();
    } else {
        $ret = '';
        $poll_res = db_res($query);
        if (mysql_num_rows($poll_res) == 0) {
            $ret .= '<div class="no_result"><div>';
            $ret .= _t("_No profile polls available.");
            $ret .= '</div></div>';
        } else {
            while ($poll_arr = mysql_fetch_array($poll_res)) {
                $age_str = _t("_y/o", age($poll_arr['DateOfBirth']));
                $y_o_sex = $age_str . '&nbsp;' . _t("_" . $poll_arr['Sex']);
                $poll_coutry = _t("__" . $prof['countries'][$poll_arr['Country']]);
                $NickName = "<b><a href=\"" . getProfileLink($poll_arr['ID']) . "\">{$poll_arr['NickName']}</a></b>";
                $ret .= '<div class="pollInfo">';
                $ret .= get_member_icon($poll_arr['ID'], 'left');
                $ret .= '<div class="featured_info">';
                $ret .= '<div class="featured_nickname">';
                $ret .= $NickName;
                $ret .= '</div>';
                $ret .= '<div class="pollBody">';
                $ret .= ShowPoll($poll_arr['id_poll']);
                $ret .= '</div>';
                $ret .= '</div>';
                $ret .= '<div class="clear_both"></div>';
                $ret .= '</div>';
                $ret .= '<div class="clear_both"></div>';
            }
        }
    }
    return DesignBoxContent(_t($sCaption), $ret, 1, $menu);
}