2 /************************************************************************
\r
3 * MXChange v0.2.1 Start: 07/10/2004 *
\r
4 * =============== Last change: 07/10/2004 *
\r
6 * -------------------------------------------------------------------- *
\r
7 * File : register_functions.php *
\r
8 * -------------------------------------------------------------------- *
\r
9 * Short description : Special functions for register extension *
\r
10 * -------------------------------------------------------------------- *
\r
11 * Kurzbeschreibung : Spezielle Funktion fuer register-Erweiterung *
\r
12 * -------------------------------------------------------------------- *
\r
14 * -------------------------------------------------------------------- *
\r
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
\r
16 * For more information visit: http://www.mxchange.org *
\r
18 * This program is free software; you can redistribute it and/or modify *
\r
19 * it under the terms of the GNU General Public License as published by *
\r
20 * the Free Software Foundation; either version 2 of the License, or *
\r
21 * (at your option) any later version. *
\r
23 * This program is distributed in the hope that it will be useful, *
\r
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
\r
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
\r
26 * GNU General Public License for more details. *
\r
28 * You should have received a copy of the GNU General Public License *
\r
29 * along with this program; if not, write to the Free Software *
\r
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
\r
31 * MA 02110-1301 USA *
\r
32 ************************************************************************/
\r
34 // Some security stuff...
\r
35 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
\r
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
\r
42 function REGISTER_FILL_MUST_CONSTANTS()
\r
44 $result = SQL_QUERY("SELECT field_name, field_required FROM "._MYSQL_PREFIX."_must_register ORDER BY id", __FILE__, __LINE__);
\r
45 while(list($name, $required) = SQL_FETCHROW($result))
\r
48 if ($required == "Y") $value = "<FONT class=\\\"guest_failed\\\"> (*)</FONT>";
\r
49 $eval = "define('MUST_".strtoupper($name)."', \"".$value."\");";
\r
54 SQL_FREERESULT($result);
\r
56 // Also fill other constants
\r
57 define('MUST_SEX' , "<FONT class=\"guest_failed\"> (*)</FONT>");
\r
58 define('MUST_ADDY' , "<FONT class=\"guest_failed\"> (*)</FONT>");
\r
59 define('MUST_BIRTH' , "<FONT class=\"guest_failed\"> (*)</FONT>");
\r
60 define('MUST_MARKER', "<FONT class=\"guest_failed\"> (*)</FONT>");
\r
63 function REGISTER_CHECK_REQUIRED_FIELDS(&$array)
\r
66 foreach ($array as $key=>$value)
\r
68 $result = SQL_QUERY("SELECT field_required FROM "._MYSQL_PREFIX."_must_register WHERE field_name='".$key."' LIMIT 1", __FILE__, __LINE__);
\r
69 if (SQL_NUMROWS($result) == 1)
\r
71 // "Must-line" found
\r
72 list($chk) = SQL_FETCHROW($result);
\r
73 SQL_FREERESULT($result);
\r
75 // Check if extension country is not found (you have to enter the 2-chars long country code) or
\r
76 // if extensions is present check if country code was selected
\r
77 // 01 2 21 12 3 32 234 5 54 4 43 34 4 4 5 5432 2 3 3210
\r
78 $country = ((!EXT_IS_ACTIVE("country")) || ((EXT_IS_ACTIVE("country")) && (((empty($value)) && ($key == "cntry")) || (($key == "country_code") && (!empty($value)))) && (!empty($array['country_code']))));
\r
79 if ((empty($value)) && ($chk == "Y") && (!$country))
\r
81 // Required field not set
\r
90 function REGISTER_OUTPUT_REQUIRE_CHECK(&$array)
\r
92 $result = SQL_QUERY("SELECT field_name, field_required FROM "._MYSQL_PREFIX."_must_register ORDER BY id", __FILE__, __LINE__);
\r
93 while(list($name, $required) = SQL_FETCHROW($result))
\r
95 if (($array[$name] == "!") && ($required == "Y"))
\r
97 // Empty entry found
\r
99 $eval = "\$OUT = REGISTER_".strtoupper($name)."_REQUIRED;";
\r
101 OUTPUT_HTML ("<STRONG><SPAN class=\"register_failed\">".$OUT."</SPAN></STRONG><BR><BR>");
\r
106 SQL_FREERESULT($result);
\r
109 function REGISTER_ADD_CATEGORY_TABLE ($MODE, $return=false)
\r
111 global $_POST, $CONFIG;
\r
114 // Guests are mostly not interested in how many members has
\r
115 // choosen an individual category
\r
116 $AND = "WHERE visible='Y' ";
\r
117 // Admins are allowed to see every category...
\r
118 if (IS_ADMIN()) $AND = "";
\r
119 $result = SQL_QUERY("SELECT id, cat, visible FROM "._MYSQL_PREFIX."_cats ".$AND." ORDER BY sort", __FILE__, __LINE__);
\r
120 if (SQL_NUMROWS($result) > 0)
\r
122 // List alle visible modules (or all to the admin)
\r
124 $OUT .= "<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n";
\r
125 while (list($id, $cat, $visible) = SQL_FETCHROW($result))
\r
127 if (empty($_POST['cat'][$id])) $_POST['cat'][$id] = "";
\r
128 // Prepare array for the template
\r
137 if (($_POST['cat'][$id] == "Y") || (($CONFIG['register_default'] == "Y") && (empty($_POST['cat'][$id]))))
\r
139 $content['def_y'] = " checked";
\r
143 $content['def_n'] = " checked";
\r
146 // Load template and switch color
\r
147 $OUT .= LOAD_TEMPLATE("guest_cat_row", true, $content);
\r
150 $OUT .= "</TABLE>\n";
\r
153 SQL_FREERESULT($result);
\r
157 // No categories setted up so far...
\r
158 $OUT .= LOAD_TEMPLATE("admin_settings_saved", true, NO_CATEGORIES_VISIBLE);
\r
163 // Return generated HTML code
\r
168 // Output directly (default)
\r
169 OUTPUT_HTML ($OUT);
\r