source: trunk/inc/admin.inc.php

Last change on this file was 2, checked in by george, 14 years ago
  • Přidáno: Trunk revize 13719.
File size: 28.0 KB
Line 
1<?php
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( 'header.inc.php' );
22require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
23require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
24require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
25require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolEmailTemplates.php' );
26
27$menu_color_0 = "#dddddd";
28
29function login_form($text = "", $member = 0, $bbAjaxMode = false)
30{
31 global $site;
32 global $_page_cont;
33 global $_page;
34 global $admin_dir;
35
36 if($member == 1) {
37 LoginFormAdmin();
38 exit;
39 }
40
41 $sFormCode = getMemberLoginFormCode('login_box_form');
42
43 $sCloseImg = getTemplateImage('close.gif');
44
45 $sCaptionItem = <<<BLAH
46 <div class="dbTopMenu">
47 <img src="{$sCloseImg}" class="login_ajx_close" />
48 </div>
49BLAH;
50
51 if($bbAjaxMode) {
52
53 $sMemberLoginFormAjx = $GLOBALS['oFunctions']->transBox(
54 DesignBoxContent(_t('_Member Login'), $sFormCode, 1, $sCaptionItem), true
55 );
56
57 echo $sMemberLoginFormAjx;
58 exit;
59 }
60
61 $sMemberLoginForm = <<<EOF
62<div class="controlsDiv">
63{$sFormCode}
64</div>
65EOF;
66
67
68 $_page['header'] = $site['title'] . ' ' . _t("_Member Login");
69 $_page['header_text'] = _t("_Member Login");
70
71 if ($bbAjaxMode && $member==1)
72 $template = BX_DIRECTORY_PATH_ROOT . "templates/base/login_form_ajax_a.html";
73
74 if ($bbAjaxMode==false && $member==0) {
75 $_page_cont[0]['page_main_code'] = $sMemberLoginForm;
76 } else {
77 $_page_cont[0]['page_main_code'] = PageCompLoginForm($text,$member,$mem,$login_page,$join_page,$forgot_page,$template);
78 }
79
80 if ($bbAjaxMode) {
81 echo <<<EOF
82<div class="login_ajax_wrap">
83 {$_page_cont[0]['page_main_code']}
84</div>
85EOF;
86 exit;
87 }
88
89 $_page['name_index'] = 0;
90 PageCode();
91 exit;
92}
93
94function PageCompLoginForm($text, $member, $mem, $login_page, $join_page, $forgot_page, $template = '') {
95 global $site;
96
97 $aFormReplace = array();
98
99 if ($member == 1)
100 $name_label = _t("_Log In");
101 else
102 $name_label = ($member == 2) ? _t("_ID") : _t("_E-mail or ID");
103
104 $aFormReplace['header_text'] = $site['title'] . ' ' . $mem . ' Login';
105 $aFormReplace['warning_text'] = $text;
106 $aFormReplace['action_url'] = $login_page;
107
108 if (! $sUrlRelocate = $_REQUEST['relocate'] or basename($_REQUEST['relocate']) == 'index.php' or basename($_REQUEST['relocate']) == 'join.php')
109 $sUrlRelocate = $_SERVER['PHP_SELF'];
110
111 $aFormReplace['site_a_url'] = BX_DOL_URL_ROOT;
112 $aFormReplace['relocate_url'] = htmlspecialchars( $sUrlRelocate ); //$_SERVER['PHP_SELF'];
113 $aFormReplace['images'] = $site['images'];
114 $aFormReplace['name_label'] = $name_label;
115 $aFormReplace['password_label'] = _t("_Password");
116 $aFormReplace['submit_label'] = _t("_Log In");
117 $aFormReplace['member_label'] = _t('_Member Login');
118 $aFormReplace['remeber_label'] = _t("_Remember password");
119 $aFormReplace['form_onsubmit'] = "validateLoginForm( this, '" . BX_DOL_URL_ROOT . "', '" . addslashes( htmlspecialchars( _t('_PROFILE_ERR') ) ) . "'); return false;";
120
121 if ($forgot_page) {
122 $aFormReplace['forgot_page_url'] = $forgot_page;
123 $aFormReplace['forgot_label'] = _t("_forgot_your_password") . '?';
124 $aFormReplace['clickhere_label'] = _t("_Click here");
125 } else {
126 $aFormReplace['forgot_page_url'] = '';
127 $aFormReplace['forgot_label'] = '';
128 }
129
130 if ($join_page) {
131 $aFormReplace['not_a_member'] = _t('_not_a_member');
132 $aFormReplace['or'] = _t( '_or' );
133 $aFormReplace['join_label'] = _t( '_Join now' );
134 $aFormReplace['join_page_url'] = $join_page;
135 } else {
136 $aFormReplace['or'] = '';
137 $aFormReplace['not_a_member'] = '';
138 $aFormReplace['join_label'] = '';
139 $aFormReplace['join_page_url'] = '';
140 }
141
142 $sTemplateFilename = basename($template);
143 return $GLOBALS['oSysTemplate']->parseHtmlByName($sTemplateFilename, $aFormReplace);
144}
145
146function activation_mail( $ID, $text = 1 ) {
147 global $ret;
148
149 $ID = (int)$ID;
150 $p_arr = db_arr( "SELECT `Email` FROM `Profiles` WHERE `ID` = '$ID'" );
151 if ( !$p_arr ) {
152 $ret['ErrorCode'] = 7;
153 return false;
154 }
155
156 $rEmailTemplate = new BxDolEmailTemplates();
157 $aTemplate = $rEmailTemplate -> getTemplate( 't_Confirmation' ) ;
158 $recipient = $p_arr['Email'];
159
160 $sConfirmationCode = base64_encode( base64_encode( crypt( $recipient, CRYPT_EXT_DES ? "secret_co" : "se" ) ) );
161 $sConfirmationLink = BX_DOL_URL_ROOT . "profile_activate.php?ConfID={$ID}&ConfCode=" . urlencode( $sConfirmationCode );
162
163 $aPlus = array();
164 $aPlus['ConfCode'] = $sConfirmationCode;
165 $aPlus['ConfirmationLink'] = $sConfirmationLink;
166
167 $mail_ret = sendMail( $recipient, $aTemplate['Subject'], $aTemplate['Body'], $ID, $aPlus );
168
169 if ( $mail_ret ) {
170 if ( $text ) {
171 $page_text .= '<div class="Notice">' . _t("_EMAIL_CONF_SENT") . "</div>";
172
173 $page_text .= "<center><form method=get action=\"" . BX_DOL_URL_ROOT . "profile_activate.php\">";
174 $page_text .= "<table class=text2 cellspacing=0 cellpadding=0><td><b>"._t("_ENTER_CONF_CODE").":</b>&nbsp;</td><td><input type=hidden name=\"ConfID\" value=\"{$ID}\">";
175 $page_text .= '<input class=no type="text" name="ConfCode" size=30></td><td>&nbsp;</td>';
176 $page_text .= '<td><input class=no type="submit" value="'._t("_Submit").'"></td></table>';
177 $page_text .= '</form></center><br />';
178 } else
179 return true;
180 } else {
181 if ( $text )
182 $page_text .= "<br /><br />"._t("_EMAIL_CONF_NOT_SENT");
183 else {
184 $ret['ErrorCode'] = 10;
185 return false;
186 }
187 }
188 return ($text) ? $page_text : true;
189}
190
191function mem_expiration_letter( $ID, $membership_name, $expire_days ) {
192 $ID = (int)$ID;
193
194 if ( !$ID )
195 return false;
196
197 $p_arr = db_arr( "SELECT `Email` FROM `Profiles` WHERE `ID` = $ID", 0 );
198 if ( !$p_arr )
199 return false;
200
201 $rEmailTemplate = new BxDolEmailTemplates();
202 $aTemplate = $rEmailTemplate -> getTemplate( 't_MemExpiration', $ID ) ;
203
204 $recipient = $p_arr['Email'];
205
206 $aPlus = array();
207 $aPlus['MembershipName'] = $membership_name;
208 $aPlus['ExpireDays'] = $expire_days;
209
210 $mail_ret = sendMail( $recipient, $aTemplate['Subject'], $aTemplate['Body'], $ID, $aPlus );
211
212 if ($mail_ret)
213 return true;
214 else
215 return false;
216}
217
218function get_vars($with_page = 1, $with_per_page = 1, $with_sort_by = 1, $with_sort_order = 1, $with_gallery_view = 1) {
219 global $affID;
220
221 $get_parameters = "?";
222
223 // common parameters
224 if ( isset($_REQUEST['ID']) && (int)$_REQUEST['ID'] > 0 )
225 $get_parameters .= 'ID='. (int)$_REQUEST['ID'] .'&amp;';
226 if ( isset($_REQUEST['NickName']) && strlen($_REQUEST['NickName']) > 0 )
227 $get_parameters .= 'NickName='. process_pass_data($_REQUEST['NickName']) .'&amp;';
228 if ( isset($_REQUEST['gallery_view']) && (int)$_REQUEST['gallery_view'] > 0 && $with_gallery_view )
229 $get_parameters .= 'gallery_view='. (int)$_REQUEST['gallery_view'] .'&amp;';
230 if ( isset($_REQUEST['photos_only']) && strlen($_REQUEST['photos_only']) > 0 )
231 $get_parameters .= ($_REQUEST['photos_only'] == 'on' ? 'photos_only=on&amp;' : '');
232 if ( isset($_REQUEST['online_only']) && strlen($_REQUEST['online_only']) > 0 )
233 {
234 $get_parameters .= 'online_only=on&amp;';
235 }
236 // navigation parameters
237 if ( isset($_REQUEST['page']) && (int)$_REQUEST['page'] > 0 && $with_page )
238 $get_parameters .= 'page='. (int)$_REQUEST['page'] .'&amp;';
239 if ( isset($_REQUEST['p_per_page']) && (int)$_REQUEST['p_per_page'] > 0 && $with_per_page )
240 $get_parameters .= 'p_per_page='. (int)$_REQUEST['p_per_page'] .'&amp;';
241 if ( isset($_REQUEST['sortby']) && strlen($_REQUEST['sortby']) > 0 && $with_sort_by )
242 $get_parameters .= 'sortby='. process_pass_data($_REQUEST['sortby']) .'&amp;';
243 if ( isset($_REQUEST['sortorder']) && strlen($_REQUEST['sortorder']) > 0 && $with_sort_order )
244 $get_parameters .= ($_REQUEST['sortorder'] == 'ASC' ? 'sortorder=ASC&amp;' : 'sortorder=DESC&amp;');
245
246 // ZIP search parameters
247 if ( isset($_REQUEST['zip']) && strlen($_REQUEST['zip']) > 0 )
248 $get_parameters .= 'zip='. process_pass_data($_REQUEST['zip']) .'&amp;';
249 if ( isset($_REQUEST['metric']) && strlen($_REQUEST['metric']) > 0 )
250 $get_parameters .= ($_REQUEST['metric'] == 'miles' ? 'metric=miles&amp;' : 'metric=km&amp;');
251 if ( isset($_REQUEST['distance']) )
252 $get_parameters .= 'distance='. (int)$_REQUEST['distance'] .'&amp;';
253
254 // extra parameters
255 if ( isset($_REQUEST['profiles']) && strlen($_REQUEST['profiles']) > 0 )
256 $get_parameters .= 'profiles='. process_pass_data($_REQUEST['profiles']) .'&amp;';
257 if ( isset($_REQUEST['status']) && strlen($_REQUEST['status']) > 0 )
258 $get_parameters .= 'status='. process_pass_data($_REQUEST['status']) .'&amp;';
259
260 // admin parameters
261 if ( isset($_REQUEST['search']) && strlen($_REQUEST['search']) > 0 )
262 $get_parameters .= 'search='. process_pass_data($_REQUEST['search']) .'&amp;';
263 if ( isset($_REQUEST['s_nickname']) && strlen($_REQUEST['s_nickname']) > 0 )
264 $get_parameters .= 's_nickname='. process_pass_data($_REQUEST['s_nickname']) .'&amp;';
265
266 // affiliate parameters
267 if ( isset($affID) && (int)$affID > 0 )
268 $get_parameters .= 'affID='. (int)$affID .'&amp;';
269
270 $respd = db_res("SELECT * FROM `sys_profile_fields` WHERE `Type` <> 'none' ORDER BY `Type` ASC");
271 while ( $arrpd = mysql_fetch_array($respd) ) {
272 //$fname = get_field_name ( $arrpd );
273 $fname = $arrpd['Name'];
274 switch ($arrpd['search_type']) {
275 case 'select_one':
276 case 'text':
277 case 'area':
278 $fval = process_pass_data($_REQUEST[$fname]);
279 if ( isset($_REQUEST[$fname]) && strlen($fval) ) {
280 $get_parameters .= "{$fname}={$fval}&amp;";
281 }
282 break;
283
284 /*case 'list':
285 $fval = $_REQUEST[$fname];
286 if ( is_array($fval) && count($fval) > 0 )
287 {
288 while ( list( $key, $val ) = each( $fval ) )
289 $get_parameters .= "{$fname}[]=". process_pass_data($val) ."&amp;";
290 }
291 break;*/
292
293 /*case 'check':
294 if ( $arrpd['type'] == 'r' )
295 {
296 $findok = 0;
297 $funcbody = $arrpd['extra'];
298 $func = create_function("", $funcbody);
299 $ar = $func();
300
301 foreach ( $ar as $key => $value )
302 {
303 if ( $_REQUEST["{$fname}_{$key}"] == "on" )
304 {
305 $findok = 1;
306 break;
307 }
308 }
309
310 if ( is_array($ar) && $findok )
311 {
312 foreach ( $ar as $key => $value )
313 {
314 if ( $_REQUEST["{$fname}_{$key}"] == "on" )
315 $get_parameters .= "{$fname}_{$key}=on&amp;";
316 }
317 }
318 }
319 elseif ( $arrpd['type'] == 'e' )
320 {
321 $findok = 0;
322
323 $vals = preg_split ("/[,\']+/", $arr['extra'], -1, PREG_SPLIT_NO_EMPTY);
324
325 foreach ( $vals as $key )
326 {
327 if ( $_REQUEST["{$fname}_{$key}"] == "on" )
328 {
329 $findok = 1;
330 break;
331 }
332 }
333
334 if ( $findok )
335 {
336 foreach ( $vals as $key )
337 {
338 if ( $_REQUEST["{$fname}_{$key}"] == "on" )
339 $get_parameters .= "{$fname}_{$key}=on&amp;";
340 }
341 }
342 }
343 break;*/
344
345 /*case 'check_set':
346 $vals = preg_split ("/[,\']+/", $arrpd['extra'], -1, PREG_SPLIT_NO_EMPTY);
347 $offset = 0;
348
349 foreach ( $vals as $v )
350 {
351 if ( $_REQUEST["{$fname}_{$offset}"] == "on" )
352 $get_parameters .= "{$fname}_{$offset}=on&amp;";
353 $offset++;
354 }
355
356 break;*/
357
358 case 'date':
359 $fval_s = process_pass_data($_REQUEST["{$fname}_start"]);
360 $fval_e = process_pass_data($_REQUEST["{$fname}_end"]);
361
362 if ( strlen($fval_s) ) {
363 $get_parameters .= "{$fname}_start={$fval_s}&amp;";
364 }
365 if ( strlen($fval_e) ) {
366 $get_parameters .= "{$fname}_end={$fval_e}&amp;";
367 }
368 break;
369 }
370 }
371
372 // exclude last character from the string
373 return $get_parameters;
374}
375
376function get_vars_controls($with_page = 1, $with_per_page = 1, $with_sort_by = 1, $with_sort_order = 1, $with_gallery_view = 1) {
377 global $affID;
378
379 $get_inputs = "";
380
381 // common parameters
382 if ( isset($_REQUEST['ID']) && (int)$_REQUEST['ID'] > 0 )
383 $get_inputs .= '<input type="hidden" name="ID" value="'. (int)$_REQUEST['ID'] .'" />';
384 if ( isset($_REQUEST['NickName']) && strlen($_REQUEST['NickName']) > 0 )
385 $get_inputs .= '<input type="hidden" name="NickName" value="'. process_pass_data($_REQUEST['NickName']) .'" />';
386 if ( isset($_REQUEST['gallery_view']) && (int)$_REQUEST['gallery_view'] > 0 && $with_gallery_view )
387 $get_inputs .= '<input type="hidden" name="gallery_view" value="'. (int)$_REQUEST['gallery_view'] .'" />';
388 if ( isset($_REQUEST['photos_only']) && strlen($_REQUEST['photos_only']) > 0 )
389 $get_inputs .= ($_REQUEST['photos_only'] == 'on' ? '<input type="hidden" name="photos_only" value="on" />' : '');
390 if ( isset($_REQUEST['online_only']) && strlen($_REQUEST['online_only']) > 0 )
391 {
392 $get_inputs .= '<input type="hidden" name="online_only" value="on" />';
393 }
394 // navigation parameters
395 if ( isset($_REQUEST['page']) && (int)$_REQUEST['page'] > 0 && $with_page )
396 $get_inputs .= '<input type="hidden" name="page" value="'. (int)$_REQUEST['page'] .'" />';
397 if ( isset($_REQUEST['p_per_page']) && (int)$_REQUEST['p_per_page'] > 0 && $with_per_page )
398 $get_inputs .= '<input type="hidden" name="p_per_page" value="'. (int)$_REQUEST['p_per_page'] .'" />';
399 if ( isset($_REQUEST['sortby']) && strlen($_REQUEST['sortby']) > 0 && $with_sort_by )
400 $get_inputs .= '<input type="hidden" name="sortby" value="'. process_pass_data($_REQUEST['sortby']) .'" />';
401 if ( isset($_REQUEST['sortorder']) && strlen($_REQUEST['sortorder']) > 0 && $with_sort_order )
402 $get_inputs .= ($_REQUEST['sortorder'] == 'ASC' ? '<input type="hidden" name="sortorder" value="ASC" />' : '<input type="hidden" name="sortorder" value="DESC" />');
403
404 // ZIP search parameters
405 if ( isset($_REQUEST['zip']) && strlen($_REQUEST['zip']) > 0 )
406 $get_inputs .= '<input type="hidden" name="zip" value="'. process_pass_data($_REQUEST['zip']) .'" />';
407 if ( isset($_REQUEST['metric']) && strlen($_REQUEST['metric']) > 0 )
408 $get_inputs .= ($_REQUEST['metric'] == 'miles' ? '<input type="hidden" name="metric" value="miles" />' : '<input type="hidden" name="metric" value="km" />');
409 if ( isset($_REQUEST['distance']) )
410 $get_inputs .= '<input type="hidden" name="distance" value="'. (int)$_REQUEST['distance'] .'" />';
411
412 // extra parameters
413 if ( isset($_REQUEST['profiles']) && strlen($_REQUEST['profiles']) > 0 )
414 $get_inputs .= '<input type="hidden" name="profiles" value="'. process_pass_data($_REQUEST['profiles']) .'" />';
415 if ( isset($_REQUEST['status']) && strlen($_REQUEST['status']) > 0 )
416 $get_inputs .= '<input type="hidden" name="status" value="'. process_pass_data($_REQUEST['status']) .'" />';
417
418 // admin parameters
419 if ( isset($_REQUEST['search']) && strlen($_REQUEST['search']) > 0 )
420 $get_inputs .= '<input type="hidden" name="search" value="'. process_pass_data($_REQUEST['search']) .'" />';
421 if ( isset($_REQUEST['s_nickname']) && strlen($_REQUEST['s_nickname']) > 0 )
422 $get_inputs .= '<input type="hidden" name="s_nickname" value="'. process_pass_data($_REQUEST['s_nickname']) .'" />';
423
424 // affiliate parameters
425 if ( isset($affID) && (int)$affID > 0 )
426 $get_inputs .= '<input type="hidden" name="affID" value="'. (int)$affID .'" />';
427
428 $respd = db_res("SELECT * FROM `sys_profile_fields` WHERE `Type` <> 'none' ORDER BY `Type` ASC");
429 while ( $arrpd = mysql_fetch_array($respd) ) {
430 //$fname = get_field_name( $arrpd );
431 $fname = $arrpd['Name'];
432 switch ($arrpd['Type']) {
433 case 'select_one':
434 case 'text':
435 case 'area':
436 $fval = process_pass_data($_REQUEST[$fname]);
437 if ( isset($_REQUEST[$fname]) && strlen($fval) ) {
438 $get_inputs .= "<input type=\"hidden\" name=\"$fname\" value=\"$fval\" />";
439 }
440 break;
441
442 /*case 'list':
443 $fval = $_REQUEST[$fname];
444 if ( is_array($fval) && count($fval) > 0 )
445 {
446 while ( list( $key, $val ) = each( $fval ) )
447 $get_inputs .= "<input type=\"hidden\" name=\"{$fname}[]\" value=\"". process_pass_data($val) ."\" />";
448 }
449 break;*/
450
451 /*case 'check':
452 if ($arrpd['type'] == 'r')
453 {
454 $findok = 0;
455 $funcbody = $arrpd['extra'];
456 $func = create_function("", $funcbody);
457 $ar = $func();
458
459 foreach ( $ar as $key => $value )
460 {
461 if ( $_REQUEST["{$fname}_{$key}"] == "on" )
462 {
463 $findok = 1;
464 break;
465 }
466 }
467
468 if ( $findok )
469 {
470 foreach ( $ar as $key => $value )
471 {
472 if ( $_REQUEST["{$fname}_{$key}"] == "on" )
473 $get_inputs .= "<input type=\"hidden\" name=\"{$fname}_{$key}\" value=\"on\" />";
474 }
475 }
476 }
477 elseif ($arrpd['type'] == 'e')
478 {
479 $findok = 0;
480
481 $vals = preg_split ("/[,\']+/", $arr['extra'], -1, PREG_SPLIT_NO_EMPTY);
482
483 foreach ( $vals as $key )
484 {
485 if ( $_REQUEST["{$fname}_{$key}"] == "on" )
486 {
487 $findok = 1;
488 break;
489 }
490 }
491
492 if ( $findok )
493 {
494 foreach ( $vals as $key )
495 {
496 if ( $_REQUEST["{$fname}_{$key}"] == "on" )
497 $get_inputs .= "<input type=\"hidden\" name=\"{$fname}_{$key}\" value=\"on\" />";
498 }
499 }
500 }
501 break;*/
502
503 /*case 'check_set':
504 $vals = preg_split ("/[,\']+/", $arrpd['extra'], -1, PREG_SPLIT_NO_EMPTY);
505 $offset = 0;
506
507 foreach ( $vals as $v )
508 {
509 if ( $_REQUEST["{$fname}_{$offset}"] == "on" )
510 $get_inputs .= "<input type=\"hidden\" name=\"{$fname}_{$offset}\" value=\"on\" />";
511 $offset++;
512 }
513 break;*/
514
515 case 'date':
516 $fval_s = process_pass_data($_REQUEST["{$fname}_start"]);
517 $fval_e = process_pass_data($_REQUEST["{$fname}_end"]);
518
519 if ( isset($_REQUEST["{$fname}_start"]) && strlen($fval_s) ) {
520 $get_inputs .= "<input type=\"hidden\" name=\"{$fname}_start\" value=\"$fval_s\" />";
521 }
522 if ( isset($_REQUEST["{$fname}_end"]) && strlen($fval_e) ) {
523 $get_inputs .= "<input type=\"hidden\" name=\"{$fname}_end\" value=\"$fval_e\" />";
524 }
525 break;
526 }
527 }
528
529 return $get_inputs;
530}
531
532function ResNavigationRet( $form_name, $short = 0, $function='', $aVar = '' ) {
533 global $p_num;
534 global $page;
535 global $_page;
536 global $p_per_page;
537 global $page_first_p;
538 global $pages_num;
539 global $oTemplConfig;
540 global $gallery_view;
541
542 $pages_around = 5;
543 if ( !is_array($aVar) ) {
544 $per_page_array = array(10, 15, 20, 30, 50);
545 } else
546 {
547 $per_page_array = $aVar;
548 }
549
550 if ( $GLOBALS['logged']['admin'] )
551 array_push($per_page_array, 100);
552
553 if ( !$function ) {
554 $get_vars_controls = get_vars_controls(1, 0, 1, 1, 1);
555 $get_vars = get_vars(0, 1, 1, 1, 0);
556 } else {
557 $func = create_function( '', $function );
558 $get_vars = $func();
559 }
560
561 $gallery_view = (int)$gallery_view;
562
563 ob_start();
564
565 if ( $p_num ) {
566?>
567 <form name="<?= 'NavForm' . $form_name ?>" id="<?= 'NavForm' . $form_name ?>" method="get" action="<?= $_SERVER['PHP_SELF'] ?>" style="margin: 0px;">
568 <?= $get_vars_controls ?>
569 <table class="text2" cellpadding="0" cellspacing="0" border="0">
570<?
571 if ( !$short ) {
572?>
573 <tr>
574 <td><?= _t("_Results") ?>:&nbsp;<b><?= (int)$page_first_p ?></b>-<b><?= min((int)($page_first_p + $p_per_page - 1), (int)$p_num) ?></b>&nbsp;|&nbsp;<?= _t("_Total") ?>:&nbsp;<b><?= (int)$p_num ?></b></td>
575 <td>&nbsp;|&nbsp;<?= _t("_Results per page") ?>:&nbsp;</td>
576 <td>
577 <select name="p_per_page" onchange="javascript: document.forms['<?= 'NavForm' . $form_name ?>'].submit();">
578<?
579 foreach ( $per_page_array as $per_page_elem ) {
580 echo "<option value=\"{$per_page_elem}\" ". ($p_per_page == $per_page_elem ? 'selected="selected"' : '') .">{$per_page_elem}</option>";
581 }
582?>
583 </select>
584 </td>
585 <td>&nbsp;</td>
586 </tr>
587<?
588 }
589?>
590 <tr>
591 <td align="center" colspan="3">
592 <?= _t('_Pages') ?>:&nbsp;
593<?
594 if ( $page > 1 ) {
595 echo "
596 <a href=\"{$_SERVER['PHP_SELF']}{$get_vars}page=1&amp;gallery_view={$gallery_view}\">". _t("_First") ."</a>&nbsp;|&nbsp;
597 <a href=\"{$_SERVER['PHP_SELF']}{$get_vars}page=". (int)($page - 1) ."&amp;gallery_view={$gallery_view}\">". _t("_Prev") ."</a>&nbsp;|&nbsp;";
598 }
599
600 // print all previous pages
601 for ( $i = max($page - $pages_around, 1); $i < $page ; $i++ ) {
602 echo "
603 <a href=\"{$_SERVER['PHP_SELF']}{$get_vars}page={$i}&amp;gallery_view={$gallery_view}\">{$i}</a>&nbsp;";
604 }
605 // print current page
606 echo "
607 [{$page}]&nbsp;";
608 // print all next pages
609 for ( $i = $page + 1; $i <= min($page + $pages_around, $pages_num); $i++ ) {
610 echo "
611 <a href=\"{$_SERVER['PHP_SELF']}{$get_vars}page={$i}&amp;gallery_view={$gallery_view}\">{$i}</a>&nbsp;";
612 }
613
614 if ( $page < $pages_num ) {
615 echo "
616 <a href=\"{$_SERVER['PHP_SELF']}{$get_vars}page=". (int)($page + 1) ."&amp;gallery_view={$gallery_view}\">". _t("_Next") ."</a>&nbsp;|&nbsp;
617 <a href=\"{$_SERVER['PHP_SELF']}{$get_vars}page={$pages_num}&amp;gallery_view={$gallery_view}\">". _t("_Last") ."</a>";
618 }
619?>
620 </td>
621<?
622 // print gallery option for search page
623 if ( $_page['name_index'] == 32 && $oTemplConfig -> show_gallery_link_in_page_navigation ) {
624 if ( $gallery_view ) {
625 echo "
626 <td style=\"padding-left: 10px;\"><a href=\"{$_SERVER['PHP_SELF']}{$get_vars}page={$page}&amp;gallery_view=0\">". _t("_view as profile details") ."</a></td>";
627 } else {
628 echo "
629 <td style=\"padding-left: 10px;\"><a href=\"{$_SERVER['PHP_SELF']}{$get_vars}page={$page}&amp;gallery_view=1\">". _t("_view as photo gallery") ."</a></td>";
630 }
631 } else {
632 echo "
633 <td>&nbsp;</td>";
634 }
635?>
636 </tr>
637 </table>
638 </form>
639<?
640 }
641
642 $ret = ob_get_contents();
643 ob_end_clean();
644
645 return $ret;
646}
647
648function getID( $str, $with_email = 1 ) {
649 if ( $with_email ) {
650 if ( eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,4}$", $str) ) {
651 $str = process_db_input($str);
652 $mail_arr = db_arr( "SELECT `ID` FROM `Profiles` WHERE `Email` = '$str'" );
653 if ( (int)$mail_arr['ID'] ) {
654 return (int)$mail_arr['ID'];
655 }
656 }
657 }
658
659 $str = process_db_input($str);
660 $iID = (int)db_value( "SELECT `ID` FROM `Profiles` WHERE `NickName` = '$str'" );
661
662 if(!$iID) {
663 $aProfile = getProfileInfo($str);
664 $iID = isset($aProfile['ID']) ? $aProfile['ID'] : 0;
665 }
666 return $iID;
667}
668
669// check encrypted password (ex., from Cookie)
670function check_login($ID, $passwd, $iRole = BX_DOL_ROLE_MEMBER, $error_handle = true) {
671 $ID = (int)$ID;
672
673 if (!$ID) {
674 if ($error_handle)
675 login_form(_t("_PROFILE_ERR"), $member);
676 return false;
677 }
678
679 //New Feature - IP Black list
680 //Make automatically logout for Banned IP
681 if ($iRole == BX_DOL_ROLE_MEMBER) {
682 if ((int)getParam('ipBlacklistMode') == 2) {
683 if (isIPLoggedBanned($ID))
684 return false;
685 }
686 }
687
688 switch ($iRole) {
689 case BX_DOL_ROLE_MEMBER: $member = 0; break;
690 case BX_DOL_ROLE_ADMIN: $member = 1; break;
691 }
692
693 $aProfile = getProfileInfo($ID);
694
695 // If no such members
696 if (!$aProfile) {
697 if ($error_handle)
698 login_form(_t("_PROFILE_ERR"), $member);
699 return false;
700 }
701
702 // If password is incorrect
703 if (strcmp($aProfile['Password'], $passwd) != 0) {
704 if ($error_handle)
705 login_form(_t("_INVALID_PASSWD"), $member);
706 return false;
707 }
708
709 if (!((int)$aProfile['Role'] & $iRole)) {
710 if ($error_handle)
711 login_form(_t("_INVALID_ROLE"), $member);
712 return false;
713 }
714
715 // If profile is banned
716 if(((int)$aProfile['Role'] & BX_DOL_ROLE_ADMIN) || ((int)$aProfile['Role'] & BX_DOL_ROLE_MODERATOR))
717 return true;
718
719 // If profile is banned logout it automatically
720 if (isLoggedBanned($aProfile['ID'])) {
721 bx_logout();
722 return false;
723 }
724
725 //If IP is banned terminate the script
726 if ((int)getParam('ipBlacklistMode') == 1 && isIPLoggedBanned()) {
727 echo _t('_Sorry, your IP been banned');
728 exit;
729 }
730
731 return true;
732}
733
734function check_logged(){
735 $aAccTypes = array(
736 1 => 'admin',
737 0 => 'member'
738 );
739
740 $bLogged = false;
741 foreach($aAccTypes as $iKey => $sValue)
742 if($GLOBALS['logged'][$sValue] = member_auth($iKey, false)) {
743 $bLogged = true;
744 break;
745 }
746
747 if((isset($_COOKIE['memberID']) || isset($_COOKIE['memberPassword'])) && !$bLogged)
748 bx_logout(false);
749}
750
751// 0 - member, 1 - admin
752function member_auth($member = 0, $error_handle = true, $bAjx = false) {
753 global $site;
754
755 switch ($member) {
756 case 0:
757 $mem = 'member';
758 $login_page = BX_DOL_URL_ROOT . "member.php";
759 $iRole = BX_DOL_ROLE_MEMBER;
760 break;
761 case 1:
762 $mem = 'admin';
763 $login_page = BX_DOL_URL_ADMIN . "index.php";
764 $iRole = BX_DOL_ROLE_ADMIN;
765 break;
766 }
767
768 if (!$_COOKIE['memberID'] || !$_COOKIE['memberPassword']) {
769 if ($error_handle) {
770 $text = _t("_LOGIN_REQUIRED_AE1");
771 if ($member == 0)
772 $text .= "<br />"._t("_LOGIN_REQUIRED_AE2", $site['images'], BX_DOL_URL_ROOT, $site['title']);
773
774 $bAjxMode = (isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') ? true : false;
775 if ($member=1 && $bAjx==true) $bAjxMode = true;
776 login_form($text, $member, $bAjxMode);
777 }
778 return false;
779 }
780
781 return check_login(process_pass_data($_COOKIE['memberID']), process_pass_data($_COOKIE['memberPassword' ]), $iRole, $error_handle);
782}
783
784// check unencrypted password
785function check_password($sUsername, $sPassword, $iRole = BX_DOL_ROLE_MEMBER, $error_handle = true) {
786 $iId = getID($sUsername);
787 if (!$iId) return false;
788
789 $aUser = getProfileInfo($iId);
790 $sPassCheck = encryptUserPwd($sPassword, $aUser['Salt']);
791
792 return check_login($iId, $sPassCheck, $iRole, $error_handle);
793}
794
795function profile_delete($ID) {
796 //global $MySQL;
797 global $dir;
798
799 //recompile global profiles cache
800 clearCacheFile(BX_DIRECTORY_PATH_DBCACHE . 'sys_browse_peoples.inc');
801
802 $ID = (int)$ID;
803
804 if ( !$ID )
805 return false;
806
807 if ( !getProfileInfo( $ID ) )
808 return false;
809
810 db_res( "DELETE FROM `sys_admin_ban_list` WHERE `ProfID`='". $ID . "' LIMIT 1");
811 db_res( "DELETE FROM `sys_greetings` WHERE `ID` = '{$ID}' OR `Profile` = '{$ID}'" );
812 db_res( "DELETE FROM `sys_block_list` WHERE `ID` = '{$ID}' OR `Profile` = '{$ID}'" );
813 db_res( "DELETE FROM `sys_messages` WHERE Recipient = {$ID} " );
814 db_res( "DELETE FROM `sys_fave_list` WHERE ID = {$ID} OR Profile = {$ID}" );
815 db_res( "DELETE FROM `sys_friend_list` WHERE ID = {$ID} OR Profile = {$ID}" );
816 db_res( "DELETE FROM `sys_acl_levels_members` WHERE `IDMember` = {$ID}" );
817 db_res( "DELETE FROM `sys_tags` WHERE `ObjID` = {$ID} AND `Type` = 'profile'" );
818
819 // delete profile votings
820 require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolVoting.php' );
821 $oVotingProfile = new BxDolVoting ('profile', 0, 0);
822 $oVotingProfile->deleteVotings ($ID);
823
824 // delete profile comments
825 require_once (BX_DIRECTORY_PATH_CLASSES . 'BxDolCmts.php');
826 $oCmts = new BxDolCmts('profile', $ID);
827 $oCmts->onObjectDelete();
828 // delete all comments in all comments' systems, this user posted
829 $oCmts->onAuthorDelete($ID);
830
831 $iPossibleCoupleID = (int)db_value( "SELECT `ID` FROM `Profiles` WHERE `Couple` = '{$ID}'" );
832 if ($iPossibleCoupleID) {
833 db_res( "DELETE FROM `Profiles` WHERE `ID` = '{$iPossibleCoupleID}'" );
834 //delete cache file
835 deleteUserDataFile( $iPossibleCoupleID );
836 }
837
838 db_res( "DELETE FROM `Profiles` WHERE `ID` = '{$ID}'" );
839
840 // create system event
841 require_once(BX_DIRECTORY_PATH_CLASSES . 'BxDolAlerts.php');
842 $oZ = new BxDolAlerts('profile', 'delete', $ID);
843 $oZ->alert();
844
845 //delete cache file
846 deleteUserDataFile( $ID );
847}
848
849function get_user_online_status ($ID) {
850 $iOnline = 0;
851
852 if($ID && is_numeric($ID) ) {
853 $aMemberInfo = getProfileInfo($ID);
854 // check user status;
855 if($aMemberInfo['UserStatus'] != 'offline') {
856 $min = getParam( "member_online_time" );
857 $iOnline = db_value("SELECT count(ID) as count_id FROM Profiles WHERE DateLastNav > SUBDATE(NOW(), INTERVAL {$min} MINUTE) AND ID={$ID}");
858 }
859 }
860
861 return $iOnline;
862}
863?>
Note: See TracBrowser for help on using the repository browser.