HomeHelpTrac

source: tags/6.1/member.php @ 10297

Revision 10297, 17.9 KB checked in by Andrey Prikaznov, 3 years ago (diff)
Line 
1<?
2
3/***************************************************************************
4*                            Dolphin Smart Community Builder
5*                              -----------------
6*     begin                : Mon Mar 23 2006
7*     copyright            : (C) 2006 BoonEx Group
8*     website              : http://www.boonex.com/
9* This file is part of Dolphin - Smart Community Builder
10*
11* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
12* http://creativecommons.org/licenses/by/3.0/
13*
14* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16* See the Creative Commons Attribution 3.0 License for more details.
17* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
18* see license.txt file; if not, write to marketing@boonex.com
19***************************************************************************/
20
21require_once( 'inc/header.inc.php' );
22require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
23require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
24require_once( BX_DIRECTORY_PATH_INC . 'members.inc.php' );
25require_once( BX_DIRECTORY_PATH_INC . 'news.inc.php' );
26require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
27require_once( BX_DIRECTORY_PATH_INC . 'sharing.inc.php' );
28
29require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolClassifieds.php' );
30require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolEvents.php' );
31require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolGroups.php' );
32require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolPageView.php' );
33require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolSharedMedia.php' );
34
35//--------------------------------------- member account class ------------------------------------------//
36
37class BxDolMember extends BxDolPageView {
38
39    // member ID
40    var $iMember;
41
42    // member info
43    var $aMemberInfo;
44
45    // config site array
46    var $aConfSite;
47
48    // config dir array
49    var $aConfDir;
50
51    var $bAjaxMode;
52
53    /*
54        constructor
55        * @param int $iMember - member ID       
56    */
57   
58    function BxDolMember($iMember, &$aSite, &$aDir) {
59        $this->iMember     = (int)$iMember;
60        $this->aMemberInfo = getProfileInfo($this->iMember);
61
62        $this->aConfSite = $aSite;
63        $this->aConfDir  = $aDir;
64
65        parent::BxDolPageView('member');
66    }
67
68    function genShowHideItem( $wrapperID, $default = '' )
69    {
70        if( !$default )
71            $default = _t( '_Hide' );
72       
73        return '
74        <div class="caption_item">
75            <a href="javascript:void(0);"
76              onclick="el = document.getElementById(\'' . $wrapperID . '\'); if( el.style.display == \'none\' ) {el.style.display = \'block\'; this.innerHTML = \'' . _t( '_Hide' ) . '\';} else {el.style.display = \'none\'; this.innerHTML = \'' . _t( '_Show' ) . '\';}"
77              >' . $default . '</a>
78        </div>';
79    }
80
81    function getBlockCode_Classifieds() {
82        if ($this->iMember > 0) {
83            $sqlQuery = "
84                SELECT DISTINCT
85                COUNT(`ClassifiedsAdvertisements`.`ID`)
86                FROM `ClassifiedsAdvertisements`
87                WHERE
88                `ClassifiedsAdvertisements`.`IDProfile`  = '{$this->iMember}' AND `ClassifiedsAdvertisements`.`Status` = 'active'
89                GROUP BY `ClassifiedsAdvertisements`.`ID`
90            ";
91            $iBlogs = db_value( $sqlQuery );
92
93            if( $iBlogs > 0 ) {
94                $oClassifieds = new BxDolClassifieds();
95                $sBlocks = $oClassifieds->GenAnyBlockContent('last', $this->iMember);
96                $ret = <<<EOF
97<div id="container_classifieds">
98    {$sBlocks}
99</div>
100EOF;
101
102                $show_hide = $this->genShowHideItem( 'container_classifieds' );
103                $sShowHide = $show_hide;
104                return $ret;
105            } else
106                return '';
107        } else {
108            return MsgBox( _t('_im_textNoCurrUser') );
109        }
110    }
111   
112    function getBlockCode_Events() {
113        if ($this->iMember > 0) {
114            $sqlQuery = "
115                SELECT COUNT(`SDatingEvents`.`ID`) AS 'Cnt'
116                FROM `SDatingEvents`
117                LEFT JOIN `SDatingParticipants` ON `SDatingParticipants`.`IDEvent` = `SDatingEvents`.`ID`
118                WHERE (`SDatingEvents`.`ResponsibleID` = '{$this->iMember}' OR `SDatingParticipants`.`IDMember` = '{$this->iMember}')
119                AND `SDatingEvents`.`Status` = 'Active'
120            ";
121            $iBlogs = db_value( $sqlQuery );
122
123            if( $iBlogs > 0 ) {
124                $oEvents = new BxDolEvents();
125                $sBlocks = $oEvents->GenAnyBlockContent('last', $this->iMember);
126                $ret = <<<EOF
127<div id="container_events">
128    {$sBlocks}
129</div>
130EOF;
131
132                $show_hide = $this->genShowHideItem( 'container_events' );
133                $sShowHide = $show_hide;
134                return $ret;
135            } else
136                return '';
137        } else {
138            return MsgBox( _t('_im_textNoCurrUser') );
139        }
140    }
141   
142    function getBlockCode_Groups() {
143        if ($this->iMember > 0) {
144            $sqlQuery = "
145                SELECT COUNT(`Groups`.`ID`) AS 'Cnt'
146                FROM `GroupsMembers`, `Groups`
147                INNER JOIN `GroupsCateg` ON `GroupsCateg`.`ID` = `Groups`.`categID`
148                WHERE
149                `GroupsMembers`.`memberID` = '{$this->iMember}' AND `GroupsMembers`.`groupID`  = `Groups`.`ID` AND `GroupsMembers`.`status`   = 'Active'
150            ";
151            $iBlogs = db_value( $sqlQuery );
152
153            if( $iBlogs > 0 ) {
154                $oGroups = new BxDolGroups();
155                $sBlocks = $oGroups->GenAnyBlockContent('latest', $this->iMember);
156                $ret = <<<EOF
157<div id="container_groups">
158    {$sBlocks}
159</div>
160EOF;
161
162                $show_hide = $this->genShowHideItem( 'container_groups' );
163                $sShowHide = $show_hide;
164                return $ret;
165            } else
166                return '';
167        } else {
168            return MsgBox( _t('_im_textNoCurrUser') );
169        }
170    }
171   
172    /*function getBlockCode_MyPhoto($iCol, $bNoDB = false) {*/
173    function getBlockCode_Topest($iCol) {
174        if(  $iCol == 1 )
175            $iPID = $this->iMember;
176        else {
177            if( !$this->aMemberInfo['Couple'] )
178                return '';
179           
180            $iPID = $this->aMemberInfo['ID'];
181        }
182        $sRet = $this->get_member_primary_photo( $iPID, 'none', $iCol);
183        return '<div class="page_block_container">' . DesignBoxContent ( _t( '_My Photos' ), $sRet, 1) . '</div>';
184        //return $sRet;
185    }
186   
187    function getBlockCode_Contacts () {
188        $sSiteUrl = $GLOBALS['site']['url'];
189   
190        $free_mode = getParam("free_mode") == "on" ? 1 : 0;
191
192        $iChMemberID = 0;
193        $iChMemberID = ($this->aMemberInfo['ID'] > 0) ? $this->aMemberInfo['ID'] : $this->iMember;
194        if ($iChMemberID == 0) {
195            return MsgBox(_t('_Sorry, nothing found'));
196        }
197
198        /*if ($_REQUEST['debug']=='1') {
199        }*/
200
201        // new messages attention
202        $new_mess_arr = db_arr( "SELECT ID FROM `Messages` WHERE Recipient = {$iChMemberID} AND New = '1' ORDER BY Date DESC LIMIT 1" );
203        if ( $new_mess_arr )
204            $mess = $new_mess_arr[ID];
205   
206        // new kisses attention
207        $new_kiss_arr = db_arr( "SELECT ID FROM `VKisses` WHERE Member = {$iChMemberID} AND New = '1' LIMIT 1" );
208        if ( $new_kiss_arr )
209            $vkiss = 1;
210   
211        // new friends attention
212        $new_friend_arr = db_arr( "SELECT `ID` FROM `FriendList` WHERE `Profile` = {$iChMemberID} AND  `Check` = '0' LIMIT 1" );
213        if ( $new_friend_arr )
214            $frd = 1;
215
216        ob_start();
217   
218    ?>
219        <table class=control_panel_table width="100%" cellspacing=0 cellpadding=1>
220   
221        <tr class=table>
222        <td class=control_panel_td_1_first valign=top align="left"><? echo _t( "_Messages" ); ?>:</td>
223        <td class=control_panel_td_2_first valign=top align="left"><?
224            if ( $mess )
225                echo _t( "_ATT_MESSAGE", $mess, $sSiteUrl );
226            else
227                echo _t( "_ATT_MESSAGE_NONE", $sSiteUrl );?>
228        </td>
229        </tr>
230   
231   
232        <tr class=table>
233        <td class=control_panel_td_1 valign=top align="left"><? echo _t( "_Kisses" ); ?>:</td>
234        <td class=control_panel_td_2 valign=top align="left"><?
235            if ( $vkiss )
236                echo _t( "_ATT_VKISS", $sSiteUrl );
237            else
238                echo _t( "_ATT_VKISS_NONE", $sSiteUrl );?>
239        </td>
240        </tr>
241   
242        <tr class=table>
243        <td class=control_panel_td_1 valign=top align="left"><? echo _t( "_Friends" ); ?>:</td>
244        <td class=control_panel_td_2 valign=top align="left"><?
245            if ( $frd )
246                echo _t( "_ATT_FRIEND", $sSiteUrl );
247            else
248                echo _t( "_ATT_FRIEND_NONE", $sSiteUrl );?>
249        </td>
250        </tr>
251        </table>
252   
253    <?php
254   
255        $ret = ob_get_contents();
256        ob_end_clean();
257   
258        return $ret;
259    }
260   
261    function getBlockCode_MemberInfo () {
262        global $oTemplConfig;
263   
264        $free_mode = getParam("free_mode")  == "on" ? 1 : 0;
265        $en_aff    = getParam("enable_aff") == 'on' ? 1 : 0;
266   
267        ob_start();
268   
269    ?>
270        <table class="control_panel_table" width="100%" cellspacing="0" cellpadding="1">
271   
272        <tr class=table>
273   
274    <!-- Profile Status -->
275   
276        <td valign="top" align="left" class="control_panel_td_1_first"><? echo _t( "_Profile status" ); ?>: </td>
277        <td valign="top" align="left" class="control_panel_td_2_first">
278            <b><font class="prof_stat_<? echo $this->aMemberInfo['Status']; ?>">&nbsp;<? echo _t( "__{$this->aMemberInfo['Status']}" ); ?>&nbsp;</font></b>
279    <?
280   
281        switch ( $this->aMemberInfo['Status'] )
282        {
283            case 'Unconfirmed': echo _t( "_ATT_UNCONFIRMED", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight ); break;
284            case 'Approval': echo _t( "_ATT_APPROVAL", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight ); break;
285            case 'Active': echo _t( "_ATT_ACTIVE", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight ); break;
286            case 'Rejected': echo _t( "_ATT_REJECTED", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight ); break;
287            case 'Suspended': echo _t( "_ATT_SUSPENDED", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight ); break;
288        }
289   
290    ?>
291        </td>
292        </tr>
293   
294    <!-- Membership -->
295   
296    <?php if ( !$free_mode ) { ?>
297   
298    <tr class=table>
299        <td valign=top align="left" class=control_panel_td_1><? echo _t( "_Membership2" ); ?>:</td>
300        <td valign=top align="left" class=control_panel_td_2>
301    <?
302        echo GetMembershipStatus($this->aMemberInfo['ID']);
303    ?>
304        </td>
305    </tr>
306   
307    <?php } ?>
308   
309    <!-- Last login -->
310   
311        <tr class=table>
312            <td valign=top align="left" class=control_panel_td_1><? echo _t( "_Last login" ); ?>: </td>
313            <td valign=top align="left" class=control_panel_td_2>
314    <?
315        if ( !$this->aMemberInfo['DateLastLogin'] || $this->aMemberInfo['DateLastLogin'] == "0000-00-00 00:00:00" )
316            $this->aMemberInfo['DateLastLogin'] = 'never';
317        echo $this->aMemberInfo['DateLastLogin'];
318    ?>
319            </td>
320        </tr>
321   
322    <!--  Affiliate Program starts here -->
323    <?
324   
325        if ( 0 == $free_mode && 1 == $en_aff )
326        {
327            echo "<tr class=table>
328                <td valign=top align=\"left\" class=control_panel_td_1>" . _t( "_Affiliate Program" ) . ": </td>
329                <td valign=top align=\"left\" class=control_panel_td_2>";
330   
331        $ar = db_arr ( "SELECT aff_num FROM Profiles WHERE ID='{$this->aMemberInfo['ID']}' LIMIT 1" );
332   
333        $res = db_res ( "SELECT * FROM members_as_aff WHERE num_of_mem <= '$ar[0]'" );
334   
335        $txt = _t( "_Got_members_part_1" ).$ar[0]._t ( "_Got_members_part_2" );
336   
337        if ( mysql_num_rows( $res ) > 0 )
338        {
339                $txt  = _t ( "_Congratulation" ).$txt;
340                $txt .= _t('_Click here to change your membership status');
341        }
342        else
343        {
344                $txt .= _t ( "_Need_more_members" );
345        }
346   
347        echo $txt;
348   
349            echo "</td>
350                </tr>";
351        }
352   
353    //<!--  Affiliate Program ends here -->
354   
355    echo "</table>";
356   
357        $ret = ob_get_contents();
358        ob_end_clean();
359   
360        return $ret;
361    }
362   
363    function getBlockCode_News () {
364        global $oTemplConfig;
365       
366        return printNewsPanel($oTemplConfig->iMaxNewsOnMemberPanel);
367    }
368   
369    function getBlockCode_SharePhotos () {
370        $aMem = array('ID'=>$this->iMember);
371        $oNew = new BxDolSharedMedia('photo', $this->aConfSite, $this->aConfDir, $aMem);
372        $aRes = $oNew->getBlockCode_SharedMedia($oNew->iViewer);
373       
374        return $aRes;
375    }
376
377    function getBlockCode_ShareVideos () {
378        $aMem = array('ID'=>$this->iMember);
379        $oNew = new BxDolSharedMedia('video', $this->aConfSite, $this->aConfDir, $aMem);
380        $aRes = $oNew->getBlockCode_SharedMedia($oNew->iViewer);
381       
382        return $aRes;
383    }
384   
385    function getBlockCode_ShareMusic () {
386        $aMem = array('ID'=>$this->iMember, 'Password'=>$this->aMemberInfo['Password']);
387        $oNew = new BxDolSharedMedia('music', $this->aConfSite, $this->aConfDir, $aMem);
388        $aRes = $oNew->getBlockCode_SharedMedia($oNew->iViewer);
389
390        return $aRes;
391    }
392   
393    function getBlockCode_Friends () {
394        global $site;
395       
396        $sFriendList = ShowFriendList( $this -> iMember);
397        $iFriendNums = getFriendNumber( $this -> iMember );
398       
399        if( $sFriendList )
400        {
401            ob_start();
402           
403            ?>
404                <div class="clear_both"></div>
405                <?= $sFriendList ?>
406                <div class="clear_both"></div>
407            <?
408           
409            $ret = ob_get_clean();
410           
411            $sFriendInfo = '<div class="caption_item"><a href="'.$site['url'].'viewFriends.php?iUser='.$this -> _iProfileID.'">'.$iFriendNums.' '._t("_Friends").'</a></div>';
412           
413            $aDbTopMenu = array(
414                _t("_Friends") => array(
415                    'href' => "{$site['url']}viewFriends.php?iUser={$this -> iMember}"
416                )
417            );
418               
419            return array( $ret, $aDbTopMenu );
420        }
421    }
422   
423    function showMyPhotos($iCol) {
424        if(  $iCol == 1 ){
425            $iPID = $this->aMemberInfo['ID'];
426        } else {
427            if( !$this->aMemberInfo['Couple'] )
428                return '';
429       
430            $iPID = $this->aMemberInfo['ID'];
431        }
432   
433        return $this->get_member_primary_photo( $iPID, 'none', $iCol);
434    }
435   
436    function get_member_primary_photo ($iPID, $float, $iCol = 0) {
437        require_once( BX_DIRECTORY_PATH_ROOT . 'profilePhotos.php' );
438
439        $oPhoto = new ProfilePhotos( $iPID );
440        $oPhoto -> getActiveMediaArray();
441        $iDesc = 0;
442        //echoDbg($this->aMemberInfo);
443        if ($this->aMemberInfo['Couple']>0 && $iCol == 2) {
444            $aCoupleInfo = getProfileInfo($this->aMemberInfo['Couple']);
445            $iDesc = $aCoupleInfo['PrimPhoto'];
446        }
447        $aFile = $oPhoto -> getPrimaryPhotoArray($iDesc);
448
449        if( extFileExists( $oPhoto -> sMediaDir . 'photo_' . $aFile['med_file'] ) )
450            $sFileName = $oPhoto -> sMediaUrl . 'photo_' . $aFile['med_file'];
451        else
452            $sFileName = getTemplateIcon( $oPhoto -> sSexPic );
453   
454        $style =
455            'width:' . $oPhoto -> aMediaConfig['size']['photoWidth'] . 'px;' .
456            'height:' . $oPhoto -> aMediaConfig['size']['photoHeight'] . 'px;' .
457            'background-image:url(' . $sFileName . ');';
458           
459        $ret = '';
460        $ret .= '<div class="thumbnail_block" style="float:' . $float . '; ">';
461            $ret .= "<a href=\"{$this->aConfSite['url']}upload_media.php\">";
462                $ret .= '<img src="' . getTemplateIcon( 'spacer.gif' ) . '" style="' . $style . '" alt="' . process_line_output( $aFileName['med_title'] ) . '" />';
463            $ret .= '</a>';
464        $ret .= '</div>';
465   
466        return $ret;
467    }
468}
469
470//-------------------------------------------------------------------------------------------------------//
471
472// --------------- page variables and login
473
474$_page['name_index'] = 81;
475$_page['css_name'] = 'member_panel.css';
476
477$_page['extra_js'] = '<script type="text/javascript">urlIconLoading = "'.getTemplateIcon('loading.gif').'";</script>';
478
479$_page['header'] = _t( "_My Account" );
480
481// --------------- GET/POST actions
482
483$member['ID']       = $_POST['ID'];
484$member['Password']   = md5( process_pass_data( $_POST['Password'] ) );
485
486$bAjxMode = ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) ? true : false;
487
488if ( !( $_POST['ID'] && $_POST['Password'] ) && ( $_COOKIE['memberID'] && $_COOKIE['memberPassword'] ) )
489{
490    if ( !( $logged['member'] = member_auth( 0, false ) ) )
491    login_form( _t( "_LOGIN_OBSOLETE" ), 0, $bAjxMode );
492}
493else
494{
495    if ( !$_POST['ID'] && !$_POST['Password'] )
496    {
497        // this is dynamic page -  send headers to do not cache this page
498        send_headers_page_changed();
499
500        $bAjxMode = ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) ? true : false;
501        login_form('', 0, $bAjxMode);
502
503    } else {
504        $member['ID'] = getID( $member['ID'] );
505        if (isLoggedBanned($member['ID'])) {
506            $_page['name_index'] = 55;
507            $_page['css_name'] = '';
508            $_ni = $_page['name_index'];
509            $_page_cont[$_ni]['page_main_code'] = MsgBox(_t('_member_banned'));
510            PageCode();
511            exit;
512        }
513
514        // Check if ID and Password are correct (addslashes already inside)
515        if ( check_login( $member['ID'], $member['Password'] ) )
516        {
517            $iCookieTime = 0;
518       
519            if (isset($_POST['rememberMe']) && $_POST['rememberMe'])
520                $iCookieTime = time() + 24*60*60*30;
521           
522            setcookie( "memberID", $_COOKIE['memberID'], time() - 24*60*60, '/' );
523            setcookie( "memberPassword", $_COOKIE['memberPassword'], time() - 24*60*60, '/' );
524            setcookie( "memberID", $member['ID'], $iCookieTime, '/' );
525            setcookie( "memberPassword", $member['Password'], $iCookieTime, '/' );
526            //setcookie( 'userArray', 'aUser' . $member['ID'] );
527            $update_res = db_res( "UPDATE `Profiles` SET `DateLastLogin` = NOW() WHERE `ID` = {$member['ID']}" );
528            createUserDataFile( $member['ID'] );
529
530            $p_arr = getProfileInfo( $member['ID'] );
531           
532            if( !$sUrlRelocate = $_REQUEST['relocate'] or basename( $_REQUEST['relocate'] ) == 'index.php' or basename( $_REQUEST['relocate'] ) == 'join.php' )
533                 $sUrlRelocate = $_SERVER['PHP_SELF'];
534
535            $_page['name_index'] = 150;
536            $_page['css_name'] = '';
537           
538            $_ni = $_page['name_index'];
539            $_page_cont[$_ni]['page_main_code'] = MsgBox( _t( '_Please Wait' ) );
540            $_page_cont[$_ni]['url_relocate'] = htmlspecialchars( $sUrlRelocate );
541            PageCode();
542        }
543        exit;
544    }
545}
546
547$member['ID'] = (int)$_COOKIE['memberID'];
548$member['Password'] = $_COOKIE['memberPassword'];
549
550$_ni = $_page['name_index'];
551
552// --------------- [END] page components
553
554// this is dynamic page -  send headers to do not cache this page
555
556// --------------- page components functions
557
558
559send_headers_page_changed();
560
561$oNew = new BxDolMember($member['ID'], $site, $dir);
562
563/*
564$sPhotoBlock = '<div style="width:49%;">'.DesignBoxContent ( _t( '_My Photos' ), $oNew->showMyPhotos(1), 1).'</div>';
565if (strlen($oNew->showMyPhotos(2)) > 0)
566    $sPhotoBlock .= '<div style="width:49%; border:=1px solid red;">'.DesignBoxContent ( _t( '_My Photos' ), $oNew->showMyPhotos(2), 1).'</div>';*/
567
568$_page_cont[$_ni]['page_main_code'] = $oNew->getCode();
569PageCode();
570
571?>
Note: See TracBrowser for help on using the repository browser.