2 /************************************************************************
3 * MXChange v0.2.1 Start: 07/16/2004 *
4 * =============== Last change: 10/27/2004 *
6 * -------------------------------------------------------------------- *
7 * File : user_functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Special functions for user extension *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Spezielle Funktionen fuer die user-Erweiterung *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
41 function alpha($sortby, $colspan, $return=false)
44 if (empty($_GET['offset'])) $_GET['offset'] = "0";
45 $ADD = "&page=".$_GET['page']."&offset=".$_GET['offset'];
46 if (!empty($_GET['mode'])) $ADD .= "&mode=".SQL_ESCAPE($_GET['mode']);
48 /* Creates the list of letters and makes them a link. */
49 $alphabet = array(_ALL2, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", 'N', "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", 'Y', "Z", _OTHERS);
50 $num = count($alphabet) - 1;
52 while (list($counter, $ltr) = each($alphabet))
54 if ($_GET['letter'] == $ltr)
56 // Current letter is letter from URL
57 $OUT .= "<STRONG>".$ltr."</STRONG>";
61 // Output link to letter
62 $OUT .= "<A href=\"".URL."/modules.php?module=admin&what=".$GLOBALS['what'];
63 if (!empty($_GET['mode'])) $OUT .= "&mode=".SQL_ESCAPE($_GET['mode']);
64 $OUT .= "&letter=".$ltr."&sortby=".$sortby.$ADD."\">".$ltr."</A>";
66 if ((($counter / $CONFIG['user_alpha']) == round($counter / $CONFIG['user_alpha'])) && ($counter > 0))
68 $OUT .= " ]<BR>[ ";
70 elseif ( $counter != $num )
72 $OUT .= " | ";
75 define('__ALPHA_LIST', $OUT);
78 $OUT = LOAD_TEMPLATE("admin_list_user_alpha", true);
81 // Return generated code
86 // Output generated code
91 function SortLinks($letter, $sortby, $colspan, $return=false)
94 if (empty($_GET['offset'])) $_GET['offset'] = "0";
95 $ADD = "&page=".$_GET['page']."&offset=".$_GET['offset'];
96 if (!empty($_GET['mode'])) $ADD .= "&mode=".SQL_ESCAPE($_GET['mode']);
98 // Makes order by links..
99 if ($letter == "front") $letter = _ALL2;
101 // Prepare array with all possible sorters
104 'family' => FAMILY_NAME,
106 'REMOTE_ADDR' => REMOTE_IP
109 // Add nickname if extension is installed
110 if (EXT_IS_ACTIVE("nickname")) {
111 $list['nickname'] = NICKNAME;
114 foreach ($list as $sort=>$title) {
115 if ($sortby == $sort) {
116 $OUT .= "<STRONG>".$title."</STRONG> | ";
118 $OUT .= "<A href=\"".URL."/modules.php?module=admin&what=list_user&letter=".$letter."&sortby=".$sort.$ADD."\">".$title."</a> | ";
121 define('__SORT_LIST', substr($OUT, 0, -13));
124 $OUT = LOAD_TEMPLATE("admin_list_user_sort", true);
137 function ADD_PAGENAV($PAGES, $offset, $show_form, $colspan,$return=false)
142 define('__FORM_HEADER', "<TR><TD colspan=\"".$colspan."\" class=\"seperator\"> </TD></TR>");
146 // Load form for changing number of lines
147 define('__FORM_HEADER', LOAD_TEMPLATE("admin_list_user_sort_form", true));
151 // Add line with bottom border
152 define('__FORM_FOOTER', "<TR><TD colspan=\"".__COLSPAN2."\" class=\"seperator bottom2\"> </TD></TR>");
156 // Add line without bottom border
157 define('__FORM_FOOTER', "<TR><TD colspan=\"".__COLSPAN2."\" class=\"seperator bottom2\"> </TD></TR>");
161 for ($page = 1; $page <= $PAGES; $page++)
163 if (($page == $_GET['page']) || ((empty($_GET['page'])) && ($page == "1")))
169 if (empty($_GET['letter'])) $_GET['letter'] = _ALL2;
170 if (empty($_GET['sortby'])) $_GET['sortby'] = "userid";
171 $OUT .= "<A href=\"".URL."/modules.php?module=admin&what=".$GLOBALS['what'];
172 if (!empty($_GET['mode'])) $OUT .= "&mode=".SQL_ESCAPE($_GET['mode']);
173 $OUT .= "&letter=".$_GET['letter']."&sortby=".$_GET['sortby']."&page=".$page."&offset=".$offset."\">";
176 if (($page == $_GET['page']) || ((empty($_GET['page'])) && ($page == "1")))
178 $OUT .= "-</STRONG>";
184 if ($page < $PAGES) $OUT .= " | ";
186 define('__PAGENAV_LIST', $OUT);
189 $OUT = LOAD_TEMPLATE("admin_list_user_pagenav", true);
201 // Create email link to user's account
202 function USER_CREATE_EMAIL_LINK($email, $mod="admin")
204 $locked = " AND status='CONFIRMED'";
205 if (IS_ADMIN()) $locked = "";
206 $result = SQL_QUERY_ESC("SELECT userid
207 FROM "._MYSQL_PREFIX."_user_data
208 WHERE email='%s'".$locked." LIMIT 1",
209 array($email), __FILE__, __LINE__);
210 if (SQL_NUMROWS($result) == 1)
213 list($uid) = SQL_FETCHROW($result);
215 // Rewrite email address to contact link
216 $email = URL."/modules.php?module=".$mod."&what=user_contct&u_id=".bigintval($uid);
220 SQL_FREERESULT($result);
222 // Return rewritten (?) email address