From b0ed0547ba277e815ca38b3333b191149a88019c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 7 Oct 2012 10:34:28 +0000 Subject: [PATCH] This debug message was to noisy but it is needed in development (where debug-mode is enabled) --- .gitattributes | 6 + inc/callback-functions.php | 21 +- inc/expression-functions.php | 7 +- inc/extensions-functions.php | 56 ++++ inc/extensions/ext-bank.php | 4 +- inc/extensions/ext-country.php | 2 +- inc/extensions/ext-coupon.php | 2 +- inc/extensions/ext-debug.php | 6 +- inc/extensions/ext-grade.php | 6 +- inc/extensions/ext-imprint.php | 2 +- inc/extensions/ext-network.php | 4 +- inc/extensions/ext-sponsor.php | 4 +- inc/extensions/ext-sql_patches.php | 2 +- inc/extensions/ext-theme.php | 2 +- inc/extensions/ext-user.php | 63 +++- inc/filter/user_filter.php | 26 ++ inc/libs/user_functions.php | 38 +++ inc/modules/admin/admin-inc.php | 207 +------------ inc/modules/member/what-points.php | 1 + inc/modules/member/what-subids.php | 107 +++++++ inc/mysql-manager.php | 274 +++++++++++++++--- inc/purge/purge-user.php | 50 ++++ inc/referral-functions.php | 13 +- inc/xml-functions.php | 1 + install/tables.sql | 2 +- templates/de/html/member/member_add_subid.tpl | 27 ++ .../html/member/member_list_user_subids.tpl | 24 ++ .../member/member_list_user_subids_row.tpl | 16 + .../de/html/member/member_mydata_edit.tpl | 17 +- .../xml/admin/admin_add_do_forced_ads.xml | 12 + .../xml/admin/admin_add_do_forced_costs.xml | 12 + templates/xml/admin/admin_list_forced_ads.xml | 4 +- .../xml/admin/admin_list_forced_campaigns.xml | 4 +- .../xml/admin/admin_list_forced_costs.xml | 4 +- templates/xml/admin/admin_list_grade_data.xml | 4 +- .../xml/admin/admin_list_nickname_history.xml | 4 +- .../xml/admin/admin_list_point_accounts.xml | 4 +- .../xml/admin/admin_list_surfbar_actions.xml | 4 +- .../xml/admin/admin_list_surfbar_urls.xml | 4 +- .../xml/admin/admin_unlock_surfbar_urls.xml | 4 +- templates/xml/admin_list_data_template.xml | 4 +- templates/xml/member/.htaccess | 1 + templates/xml/member/member_add_do_subid.xml | 68 +++++ templates/xml/member/member_list_subid.xml | 119 ++++++++ 44 files changed, 939 insertions(+), 303 deletions(-) create mode 100644 inc/modules/member/what-subids.php create mode 100644 inc/purge/purge-user.php create mode 100644 templates/de/html/member/member_add_subid.tpl create mode 100644 templates/de/html/member/member_list_user_subids.tpl create mode 100644 templates/de/html/member/member_list_user_subids_row.tpl create mode 100644 templates/xml/member/.htaccess create mode 100644 templates/xml/member/member_add_do_subid.xml create mode 100644 templates/xml/member/member_list_subid.xml diff --git a/.gitattributes b/.gitattributes index bb41fca686..2d0949cf35 100644 --- a/.gitattributes +++ b/.gitattributes @@ -723,6 +723,7 @@ inc/modules/member/what-sponsor_list.php svneol=native#text/plain inc/modules/member/what-start_surfbar.php svneol=native#text/plain inc/modules/member/what-stats.php svneol=native#text/plain inc/modules/member/what-stats_surfbar.php svneol=native#text/plain +inc/modules/member/what-subids.php svneol=native#text/plain inc/modules/member/what-support.php svneol=native#text/plain inc/modules/member/what-surfbar_book.php svneol=native#text/plain inc/modules/member/what-surfbar_list.php svneol=native#text/plain @@ -808,6 +809,7 @@ inc/purge/purge-inact.php svneol=native#text/plain inc/purge/purge-mails.php svneol=native#text/plain inc/purge/purge-tasks.php svneol=native#text/plain inc/purge/purge-unconfirmed.php svneol=native#text/plain +inc/purge/purge-user.php svneol=native#text/plain inc/referal-functions.php svneol=native#text/plain inc/referral-functions.php svneol=native#text/plain inc/request-functions.php svneol=native#text/plain @@ -1903,6 +1905,7 @@ templates/de/html/mediadata_extra_hrow.tpl svneol=native#text/plain templates/de/html/mediadata_extra_row.tpl svneol=native#text/plain templates/de/html/mediadata_extra_row2.tpl svneol=native#text/plain templates/de/html/member/.htaccess svneol=native#text/plain +templates/de/html/member/member_add_subid.tpl -text templates/de/html/member/member_advert.tpl svneol=native#text/plain templates/de/html/member/member_beg.tpl svneol=native#text/plain templates/de/html/member/member_beg_404.tpl svneol=native#text/plain @@ -1956,6 +1959,8 @@ templates/de/html/member/member_list_surfbar.tpl svneol=native#text/plain templates/de/html/member/member_list_surfbar_form.tpl svneol=native#text/plain templates/de/html/member/member_list_surfbar_row.tpl svneol=native#text/plain templates/de/html/member/member_list_surfbar_table.tpl svneol=native#text/plain +templates/de/html/member/member_list_user_subids.tpl svneol=native#text/plain +templates/de/html/member/member_list_user_subids_row.tpl svneol=native#text/plain templates/de/html/member/member_login_js.tpl svneol=native#text/plain templates/de/html/member/member_mail_bonus_deleted.tpl svneol=native#text/plain templates/de/html/member/member_mail_bonus_new.tpl svneol=native#text/plain @@ -2187,6 +2192,7 @@ templates/en/html/register_header.tpl svneol=native#text/plain templates/en/html/welcome.tpl svneol=native#text/plain templates/xml/.htaccess svneol=native#text/plain templates/xml/admin/.htaccess svneol=native#text/plain +templates/xml/member/.htaccess svneol=native#text/plain theme/README.txt svneol=native#text/plain theme/business/images/code_bg.jpg -text svneol=unset#image/jpeg theme/business/images/code_bg.png -text svneol=unset#image/png diff --git a/inc/callback-functions.php b/inc/callback-functions.php index d6d2b927e5..042781b9c1 100644 --- a/inc/callback-functions.php +++ b/inc/callback-functions.php @@ -49,6 +49,15 @@ function doXmlAdminEntryMetaData ($resource, $attributes) { } // END - if } +// Handles the XML node 'member-entry-meta-data' +function doXmlMemberEntryMetaData ($resource, $attributes) { + // There should be no attributes + if (count($attributes) > 0) { + // Please don't add any attributes to foo-list nodes + reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes)); + } // END - if +} + // Handles the XML node 'callback-function' function doXmlCallbackFunction ($resource, $attributes) { // There are two attributes, by default @@ -692,6 +701,15 @@ function doXmlAdminListData ($resource, $attributes) { } // END - if } +// Handles the XML node 'member-list-data' +function doXmlMemberListData ($resource, $attributes) { + // There should be no attributes + if (count($attributes) > 0) { + // Please don't add any attributes to foo-list nodes + reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes, got ' . count($attributes)); + } // END - if +} + // Handles the XML node 'data-tables' function doXmlDataTables ($resource, $attributes) { // There should be no attributes @@ -836,9 +854,6 @@ function doXmlWhereSelectFromListEntry ($resource, $attributes) { } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['CONDITION'])) { // 'CONDITION' not valid/verifyable reportBug(__FUNCTION__, __LINE__, 'Attribute CONDITION does not validate. CONDITION=' . $attributes['CONDITION']); - } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['LOOK-FOR'])) { - // 'LOOK-FOR' not valid/verifyable - reportBug(__FUNCTION__, __LINE__, 'Attribute LOOK-FOR does not validate. LOOK-FOR=' . $attributes['LOOK-FOR']); } elseif (!isXmlConditionValid($attributes['CONDITION'])) { // 'CONDITION' is not known reportBug(__FUNCTION__, __LINE__, 'Attribute CONDITION is not valid. LOOK-FOR=' . $attributes['CONDITION']); diff --git a/inc/expression-functions.php b/inc/expression-functions.php index 82ba0ca9a3..92e1757623 100644 --- a/inc/expression-functions.php +++ b/inc/expression-functions.php @@ -287,8 +287,11 @@ function doExpressionTemplate ($data) { // This is very bad and needs fixing reportBug(__FUNCTION__, __LINE__, 'current_template in GLOBALS not set, callbackFunction=' . $callbackFunction . ',function_exists()=' . intval(function_exists($callbackFunction))); } elseif (!function_exists($callbackFunction)) { - // Log missing function - logDebugMessage(__FUNCTION__, __LINE__, 'Call-back function ' . $callbackFunction . ' does not exist.'); + // Log missing function only in debug mode + if (isDebugModeEnabled()) { + // Log it here + logDebugMessage(__FUNCTION__, __LINE__, 'Call-back function ' . $callbackFunction . ' does not exist.'); + } // END - if } else { // Do the replacement //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'template='.$GLOBALS['current_template']); diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index dc6b67f9b4..acd01be780 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -2035,6 +2035,62 @@ function addConfigChangeSql ($oldColumnName, $newColumnName, $columnSql) { addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_config` CHANGE `' . $oldColumnName . '` `' . $newColumnName . '` ' . $columnSql); } +/** + * Checks if given subject is found and if not, adds an SQL query to the + * extension registration queue. + */ +function registerExtensionPointsData ($subject, $columnName, $lockedMode, $paymentMethod) { + // Default is old extension version + $add = ''; + + // Is the extension equal or newer 0.8.9? + if (((isInstallationPhase()) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (isExtensionInstalledAndNewer('sql_patches', '0.8.9'))) { + // Then add provider + $add = " AND `account_provider`='EXTENSION'"; + } // END - if + + // Is the 'subject' there? + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ifSqlTableExists(points_data)=' . ifSqlTableExists('points_data') . ',getExtensionMode()=' . getExtensionMode() . ',add=' . $add); + if (((!ifSqlTableExists('points_data')) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (countSumTotalData($subject, 'points_data', 'id', 'subject', true, $add) == 0)) { + // Not found so: + if ((isset($GLOBALS['previous_extension'][getCurrentExtensionName()])) && (!ifSqlTableExists('points_data'))) { + $dummy = $GLOBALS['previous_extension'][getCurrentExtensionName()]; + reportBug(__FUNCTION__, __LINE__, 'previous_extension[' . gettype($dummy) . ']=' . $dummy . ',getCurrentExtensionName()=' . getCurrentExtensionName() . ' - Under development, please report this!'); + } // END - if + + // ... add an SQL query + addExtensionSql(sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`,`column_name`,`locked_mode`,`payment_method`) VALUES ('%s','%s','%s','%s')", + $subject, + $columnName, + $lockedMode, + $paymentMethod + )); + } // END - if +} + +/** + * Checks if given subject is found and if so, adds an SQL query to the + * extension unregistration queue. + */ +function unregisterExtensionPointsData ($subject) { + // Default is old extension version + $add = ''; + + // Is the extension equal or newer 0.8.9? + if (isExtensionInstalledAndNewer('sql_patches', '0.8.9')) { + // Then add provider + $add = " AND `account_provider`='EXTENSION'"; + } // END - if + + // Is the 'subject' there? + if (countSumTotalData($subject, 'points_data', 'id', 'subject', true, $add) == 1) { + // Found one or more, so add an SQL query + addExtensionSql(sprintf("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_points_data` WHERE `subject`='%s'" . $add . " LIMIT 1", + $subject + )); + } // END - if +} + // Enables/disables productive mode for current extension (used only while // registration). // @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' diff --git a/inc/extensions/ext-bank.php b/inc/extensions/ext-bank.php index 7e9434efda..ee1d728798 100644 --- a/inc/extensions/ext-bank.php +++ b/inc/extensions/ext-bank.php @@ -73,7 +73,7 @@ switch (getExtensionMode()) { `account_type` ENUM('CHECK','SAVING') NOT NULL DEFAULT 'CHECK', `overdraft_credit` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000, PRIMARY KEY (`id`), -UNIQUE (`pin`), +UNIQUE INDEX (`pin`), INDEX `userid_type` (`userid`,`account_type`), INDEX (`account_created`), INDEX (`account_locked`), @@ -127,7 +127,7 @@ PRIMARY KEY (`id`)", `tan` VARCHAR(50) NOT NULL DEFAULT '', `used` ENUM('Y','N') NOT NULL DEFAULT 'N', PRIMARY KEY (`id`), -UNIQUE (`account_id`,`tan`)", +UNIQUE INDEX (`account_id`,`tan`)", 'Bank TAN lists per user'); // Admin menu queries diff --git a/inc/extensions/ext-country.php b/inc/extensions/ext-country.php index 170328812d..cdf0382a34 100644 --- a/inc/extensions/ext-country.php +++ b/inc/extensions/ext-country.php @@ -59,7 +59,7 @@ switch (getExtensionMode()) { `descr` VARCHAR(255) NOT NULL DEFAULT 'Deutschland', `is_active` ENUM('Y','N') NOT NULL DEFAULT 'N', PRIMARY KEY (`id`), -UNIQUE (`code`)", +UNIQUE INDEX (`code`)", 'Country codes and their full-length descriptions'); // Insert first (Germany) country diff --git a/inc/extensions/ext-coupon.php b/inc/extensions/ext-coupon.php index 4a90ed7920..676a9da2f3 100644 --- a/inc/extensions/ext-coupon.php +++ b/inc/extensions/ext-coupon.php @@ -78,7 +78,7 @@ PRIMARY KEY (`id`)", `cashed_on` TIMESTAMP NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `coupon_user` (`coupon_id`,`userid`), -UNIQUE (`coupon_code`)", +UNIQUE INDEX (`coupon_code`)", 'Coupon->user connection'); // Configuration entries diff --git a/inc/extensions/ext-debug.php b/inc/extensions/ext-debug.php index 48b19796fd..2775de07b7 100644 --- a/inc/extensions/ext-debug.php +++ b/inc/extensions/ext-debug.php @@ -95,8 +95,8 @@ INDEX (`client_id`)", `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `lock_spam_reason` TINYTEXT, PRIMARY KEY (`id`), -UNIQUE (`key`), -UNIQUE (`url`)", +UNIQUE INDEX (`key`), +UNIQUE INDEX (`url`)", 'Debug clients'); // Add this exchange as first client @@ -109,7 +109,7 @@ UNIQUE (`url`)", `client_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `log_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`id`), -UNIQUE (`log_id`), +UNIQUE INDEX (`log_id`), INDEX `client_log` (`client_id`,`log_id`)", 'Debug client <-> log connection'); diff --git a/inc/extensions/ext-grade.php b/inc/extensions/ext-grade.php index 0ec4081d60..f160c29450 100644 --- a/inc/extensions/ext-grade.php +++ b/inc/extensions/ext-grade.php @@ -58,7 +58,7 @@ switch (getExtensionMode()) { `grade_name` VARCHAR(255) NOT NULL DEFAULT '', `grade_description` TINYTEXT NOT NULL, `grade_parent_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL, -UNIQUE (`grade_name`), +UNIQUE INDEX (`grade_name`), INDEX (`grade_parent_id`), PRIMARY KEY (`grade_id`)", 'Grade data'); @@ -72,7 +72,7 @@ PRIMARY KEY (`grade_id`)", `reached_points` FLOAT(20,5) UNSIGNED NULL DEFAULT NULL, `reached_mails` BIGINT(20) UNSIGNED NULL DEFAULT NULL, `time_valid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, -UNIQUE (`grade_cash_name`), +UNIQUE INDEX (`grade_cash_name`), PRIMARY KEY (`cash_id`)", 'Data for "cashed" grades'); @@ -94,7 +94,7 @@ PRIMARY KEY (`connect_id`)", `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `grade_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `grade_expired` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', -UNIQUE (`userid`,`grade_id`), +UNIQUE INDEX (`userid`,`grade_id`), INDEX (`grade_id`), PRIMARY KEY (`connect_id`)", 'Grade<->user connection'); diff --git a/inc/extensions/ext-imprint.php b/inc/extensions/ext-imprint.php index a976b8da92..af8ad211a5 100644 --- a/inc/extensions/ext-imprint.php +++ b/inc/extensions/ext-imprint.php @@ -71,7 +71,7 @@ switch (getExtensionMode()) { `imprint_key` VARCHAR(255) NOT NULL DEFAULT '', `imprint_value` VARCHAR(255) NOT NULL DEFAULT '', PRIMARY KEY (`imprint_id`), -UNIQUE (`imprint_key`)", +UNIQUE INDEX (`imprint_key`)", 'Imprint data'); // Init imprint data diff --git a/inc/extensions/ext-network.php b/inc/extensions/ext-network.php index 0b1a6709a3..7ca36e8b6c 100644 --- a/inc/extensions/ext-network.php +++ b/inc/extensions/ext-network.php @@ -92,7 +92,7 @@ switch (getExtensionMode()) { `network_query_amount` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `network_active` ENUM('Y','N') NOT NULL DEFAULT 'Y', PRIMARY KEY (`network_id`), -UNIQUE (`network_short_name`)", +UNIQUE INDEX (`network_short_name`)", 'Network data'); // Types the network provider is supporting (e.g. Forced-Banner and so on) @@ -167,7 +167,7 @@ UNIQUE INDEX `provider_type` (`network_id`, `network_vcheck_error_type`)", `network_translation_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `network_translation_name` VARCHAR(100) NOT NULL DEFAULT '', PRIMARY KEY (`network_translation_id`), -UNIQUE (`network_translation_name`)", +UNIQUE INDEX (`network_translation_name`)", 'Translations for array keys, generic data, DO NOT ALTER!'); // Array-Element translation tables per type/provider diff --git a/inc/extensions/ext-sponsor.php b/inc/extensions/ext-sponsor.php index 98eb105a89..49305ebdfb 100644 --- a/inc/extensions/ext-sponsor.php +++ b/inc/extensions/ext-sponsor.php @@ -92,7 +92,7 @@ switch (getExtensionMode()) { `last_payment` FLOAT(7,2) UNSIGNED NOT NULL DEFAULT 0.00, `last_currency` VARCHAR(255) NOT NULL DEFAULT '€', PRIMARY KEY (`id`), -UNIQUE (`hash`), +UNIQUE INDEX (`hash`), INDEX (`refid`), INDEX (`email`)", 'Main sponsor data'); @@ -153,7 +153,7 @@ INDEX (`ext_name`)", `sort` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE INDEX `action_what` (`action`,`what`), -UNIQUE (`what`), +UNIQUE INDEX (`what`), INDEX (`action`)", 'Sponsor menu'); // diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index c0a268cc53..c90cdc548b 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -398,7 +398,7 @@ INDEX (`la_what`)", `la_posx` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `la_posy` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`id`), -UNIQUE (`la_id`), +UNIQUE INDEX (`la_id`), INDEX (`la_posx`), INDEX (`la_posy`)", 'LAS position and title data'); diff --git a/inc/extensions/ext-theme.php b/inc/extensions/ext-theme.php index d8ead4b10e..2df24a983b 100644 --- a/inc/extensions/ext-theme.php +++ b/inc/extensions/ext-theme.php @@ -129,7 +129,7 @@ switch (getExtensionMode()) { `theme_active` ENUM('Y','N') NOT NULL DEFAULT 'N', `theme_ver` VARCHAR(255) NOT NULL DEFAULT '0.0.0', PRIMARY KEY (`id`), -UNIQUE (`theme_path`), +UNIQUE INDEX (`theme_path`), INDEX (`theme_active`)", 'Themes'); // Admin menu diff --git a/inc/extensions/ext-user.php b/inc/extensions/ext-user.php index 9d8e7163ab..9e1ed4d56f 100644 --- a/inc/extensions/ext-user.php +++ b/inc/extensions/ext-user.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.5.2'); +setThisExtensionVersion('0.5.3'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2')); +setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3')); // Keep this extension always active! setExtensionAlwaysActive('Y'); @@ -97,7 +97,7 @@ INDEX (`cat_id`)", `login_failures` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `last_failure` TIMESTAMP NULL DEFAULT NULL, PRIMARY KEY (`userid`), -UNIQUE (`user_hash`), +UNIQUE INDEX (`user_hash`), INDEX (`refid`), INDEX `status_mails` (`status`,`max_mails`)", 'Main user data'); @@ -180,7 +180,10 @@ INDEX (`stats_type`)", addDropTableSql('user_refs'); addDropTableSql('user_stats'); addDropTableSql('user_stats_data'); + addDropTableSql('user_subids'); + addDropTableSql('subid_log'); addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('config_user','user_contct','list_user_del') OR `action`='user'"); + addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what` IN ('subids')"); // Register new filters for gathering points unregisterFilter(__FILE__, __LINE__, 'get_total_points', 'USER_POINTS', true, isExtensionDryRun()); @@ -191,6 +194,8 @@ INDEX (`stats_type`)", unregisterFilter(__FILE__, __LINE__, 'user_inclusion_sql', 'TESTER_USER_INCLUSION_SQL', true, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'pre_user_registration', 'TESTER_USER_REGISTRATION_ADD_SQL_COLUMNS', true, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'convert_user_data_columns', 'ADD_USER_DATA_CONVERT_SQL_COLUMNS', true, isExtensionDryRun()); + unregisterFilter(__FILE__, __LINE__, 'post_refid_validation', 'HANDLE_USER_SUBID', true, isExtensionDryRun()); + unregisterFilter(__FILE__, __LINE__, 'pre_user_registration', 'SUBID_USER_REGISTRATION_ADD_SQL_COLUMNS', true, isExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension @@ -378,7 +383,7 @@ INDEX (`userid`)", case '0.3.6': // SQL queries for v0.3.6 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` DROP INDEX `userid`'); - addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` ADD UNIQUE INDEX `userid_catid` (`userid`,`cat_id`)'); + addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` ADD UNIQUE `userid_catid` (`userid`,`cat_id`)'); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Der Sperrgrund wird nun mit abgespeichert und beim Löschen des Users mit ausgesendet."); @@ -469,7 +474,7 @@ INDEX (`userid`)", `level` smallINT(6) UNSIGNED NOT NULL DEFAULT 0, `refid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`id`), -UNIQUE INDEX `user_refid` (`userid`,`level`,`refid`), +UNIQUE `user_refid` (`userid`,`level`,`refid`), INDEX (`level`), INDEX (`refid`)", 'User referrals'); @@ -570,6 +575,54 @@ INDEX (`refid`)", // Update notes (these will be set as task text!) setExtensionUpdateNotes("Filter zum Hinzufügen von SQL-Spalten für die Mitgliederanmeldung hinzugefügt."); break; + + case '0.5.3': // SQL queries for v0.5.3 + // Register filter + registerFilter(__FILE__, __LINE__, 'post_refid_validation', 'HANDLE_USER_SUBID', false, true, isExtensionDryRun()); + registerFilter(__FILE__, __LINE__, 'pre_user_registration', 'SUBID_USER_REGISTRATION_ADD_SQL_COLUMNS', false, true, isExtensionDryRun()); + + // Admin menu + addAdminMenuSql('user', 'list_user_subid', 'Sub-Ids', 'Listet alle pro vom Mitglied eingegebenen Sub-Ids und ermittelten Referral-URLs auf.', 7); + + // Member menu + addMemberMenuSql('extras', 'subids', 'Sub-Id Tracking', 4); + + // Add table for subids + addDropTableSql('user_subids'); + addCreateTableSql('user_subids', " +`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`subid` VARCHAR(255) NOT NULL DEFAULT '', +`subid_added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +PRIMARY KEY (`id`), +UNIQUE `user_subid` (`userid`, `subid`), +INDEX (`subid`)", + 'User sub ids'); + + // Add table for subid logging + addDropTableSql('subid_log'); + addCreateTableSql('subid_log', " +`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +`refid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`subid` VARCHAR(255) NOT NULL DEFAULT '', +`referral_url` TINYTEXT, +`remote_address` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0', +`entry_added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +PRIMARY KEY (`id`), +INDEX (`refid`), +INDEX (`subid`)", + 'Sub id logging'); + + // For saving used subid in user_data table + addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `subid` VARCHAR(255) NULL DEFAULT NULL'); + addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD INDEX (`subid`)'); + + // Configuration entry for purging old subid logs (7 days default) + addConfigAddSql('user_subid_purge', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 7)); + + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Filter, Datenbanktabelle und Menüpunkte für SubId-Tracking hinzugefügt."); + break; } // END - switch break; diff --git a/inc/filter/user_filter.php b/inc/filter/user_filter.php index 95f91b3df5..1040aaee4e 100644 --- a/inc/filter/user_filter.php +++ b/inc/filter/user_filter.php @@ -147,5 +147,31 @@ function FILTER_ADD_USER_DATA_CONVERT_SQL_COLUMNS ($sql) { return $sql; } +// Filter for handling user subids (called by referral link) +function FILTER_HANDLE_USER_SUBID ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Return filter data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + //* NOISY-DEBUG: */ print __FUNCTION__.':filterData=
'.print_r($filterData,true).'
'; + return $filterData; +} + +// Filter for adding SQL columns on user registration for subid +function FILTER_SUBID_USER_REGISTRATION_ADD_SQL_COLUMNS ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Is the sub id set in session? + if (isSessionVariableSet('subid')) { + // Okay, add subid here + addExtraRegistrationColumns(', `subid`'); + addExtraRegistrationData(", '" . getSession('subid') . "'"); + } // END - if + + // Return filter data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + // [EOF] ?> diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 566c762b0c..75f0edf54b 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -796,6 +796,33 @@ function createTesterUserAccount () { return $isCreated; } +// Checks whether the given sub id is fused by current member +function isMemberSubIdFree ($subId) { + // Check it + $isFree = (countSumTotalData(getMemberId(), 'user_subids', 'id', 'userid', true, sprintf(" AND `subid`='%s'", $subId)) == 0); + + // Return result + return $isFree; +} + +// Prepares given sub id for storage in database +function prepareSubId ($subId) { + // First convert any spaces/dashes to underscores + $subId = str_replace(' ', '_', str_replace('-', '_', $subId)); + + // Then filter out any unwanted characters + $subId = preg_replace('/([^a-zA-Z0-9_])/', '', $subId); + + // Then Check if it is available + if (!isMemberSubIdFree($subId)) { + // Is not free + $subId = false; + } // END - if + + // Return prepared sub id + return $subId; +} + //----------------------------------------------------------------------------- // EL code functions //----------------------------------------------------------------------------- @@ -883,6 +910,17 @@ function doTemplateDisplayUsername ($template, $clear = false, $userid = NULL) { return $GLOBALS[__FUNCTION__][$userid]; } +// ---------------------------------------------------------------------------- +// XML call-back functions +// ---------------------------------------------------------------------------- + +// For 'doing' add subid, the column-index is required +function addXmlSpecialMemberAddDoSubid () { + // So set it all here + $GLOBALS['__COLUMN_INDEX']['doXmlCallbackFunction'] = 'column'; + $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['column_index'] = 'column'; +} + // ---------------------------------------------------------------------------- // Wrapper functions for configuration entries // ---------------------------------------------------------------------------- diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 4de2f33ea3..f2cae6f298 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -1323,78 +1323,11 @@ function adminUndeleteEntriesConfirm ($tableName, $columns = array(), $filterFun // Adds a given entry to the database function adminAddEntries ($tableName, $columns = array(), $filterFunctions = array(), $extraValues = array(), $timeColumns = array(), $columnIndex = NULL) { - //* DEBUG: */ die('columns=
'.print_r($columns,true).'
,filterFunctions=
'.print_r($filterFunctions,true).'
,extraValues=
'.print_r($extraValues,true).'
,POST=
'.print_r($_POST,true).'
'); - // Verify that tableName and columns are not empty - if ((!is_array($tableName)) || (count($tableName) != 1)) { - // No tableName specified - reportBug(__FUNCTION__, __LINE__, 'tableName is not given. Please fix your XML,tableName[]=' . gettype($tableName) . '!=array: userIdColumn=' . $userIdColumn); - } elseif (count($columns) == 0) { - // No columns specified - reportBug(__FUNCTION__, __LINE__, 'columns is not given. Please fix your XML.'); - } - - // Init columns and value elements - $sqlColumns = array(); - $sqlValues = array(); - - // Do we have "time columns"? - if (count($timeColumns) > 0) { - // Then "walk" through all entries - foreach ($timeColumns as $column) { - // Convert all (possible) selections - convertSelectionsToEpocheTimeInPostData($column . '_ye'); - } // END - foreach - } // END - if - - // Add columns and values - foreach ($columns as $key => $columnName) { - //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',columnName=' . $columnName); - // Is columnIndex set? - if (!is_null($columnIndex)) { - // Check conditions - //* DEBUG: */ die('columnIndex=
'.print_r($columnIndex,true).'
'.debug_get_printable_backtrace()); - assert((is_array($columnName)) && (isset($columnName[$columnIndex]))); - - // Then use that index "blindly" - $columnName = $columnName[$columnIndex]; - } // END - if - - // Debug message - /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',columnName[' . gettype($columnName) . ']=' . $columnName . ',filterFunctions=' . $filterFunctions[$key] . ',extraValues=' . intval(isset($extraValues[$key])) . ',extraValuesName=' . intval(isset($extraValues[$columnName . '_list'])) . '
'); - - // Copy entry securely to the final arrays - $sqlColumns[$key] = SQL_ESCAPE($columnName); - $sqlValues[$key] = SQL_ESCAPE(postRequestElement($columnName)); - - // Send data through the filter function if found - if ((isset($filterFunctions[$key])) && (isset($extraValues[$key . '_list']))) { - // Filter function set! - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - BEFORE!'); - $sqlValues[$key] = call_user_func_array($filterFunctions[$key], merge_array(array($columnName), $extraValues[$key . '_list'])); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - AFTER!'); - } elseif ((isset($filterFunctions[$key])) && (!empty($filterFunctions[$key]))) { - // Run through an extra filter - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - BEFORE!'); - $sqlValues[$key] = handleExtraValues($filterFunctions[$key], $sqlValues[$key], ''); - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - AFTER!'); - } - - // Is the value not a number? - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key]); - if (($sqlValues[$key] != 'NULL') && (is_string($sqlValues[$key]))) { - // Add quotes around it - $sqlValues[$key] = chr(39) . $sqlValues[$key] . chr(39); - } // END - if - } // END - foreach - - // Build the SQL query - $SQL = 'INSERT INTO `{?_MYSQL_PREFIX?}_' . $tableName[0] . '` (`' . implode('`,`', $sqlColumns) . "`) VALUES (" . implode(',', $sqlValues) . ')'; - - // Run the SQL query - SQL_QUERY($SQL, __FUNCTION__, __LINE__); + // Call inner function + doGenericAddEntries($tableName, $columns, $filterFunctions, $extraValues, $timeColumns, $columnIndex); // Entry has been added? - if (!SQL_HASZEROAFFECTED()) { + if ((!SQL_HASZEROAFFECTED()) && ($GLOBALS['__XML_PARSE_RESULT'] === true)) { // Display success message displayMessage('{--ADMIN_ENTRY_ADDED--}'); } else { @@ -1403,140 +1336,6 @@ function adminAddEntries ($tableName, $columns = array(), $filterFunctions = arr } } -// List all given rows (callback function from XML) -function adminListEntries ($tableTemplate, $rowTemplate, $noEntryMessageId, $tableName, $columns, $whereColumns, $orderByColumns, $callbackColumns, $extraParameters = array(), $conditions = array()) { - // Verify that tableName and columns are not empty - if ((!is_array($tableName)) || (count($tableName) != 1)) { - // No tableName specified - reportBug(__FUNCTION__, __LINE__, 'tableName is not given. Please fix your XML,tableName[]=' . gettype($tableName) . '!=array,tableTemplate=' . $tableTemplate . ',rowTemplate=' . $rowTemplate); - } elseif (count($columns) == 0) { - // No columns specified - reportBug(__FUNCTION__, __LINE__, 'columns is not given. Please fix your XML,tableTemplate=' . $tableTemplate . ',rowTemplate=' . $rowTemplate . ',tableName[0]=' . $tableName[0]); - } - - // This is the minimum query, so at least columns and tableName must have entries - $SQL = 'SELECT '; - - // Get the sql part back from given array - $SQL .= getSqlPartFromXmlArray($columns); - - // Remove last commata and add FROM statement - $SQL .= ' FROM `{?_MYSQL_PREFIX?}_' . $tableName[0] . '`'; - - // Do we have entries from whereColumns to add? - if (count($whereColumns) > 0) { - // Then add these as well - if (count($whereColumns) == 1) { - // One entry found - $SQL .= ' WHERE '; - - // Table/alias included? - if (!empty($whereColumns[0]['table'])) { - // Add it as well - $SQL .= $whereColumns[0]['table'] . '.'; - } // END - if - - // Add the rest - $SQL .= '`' . $whereColumns[0]['column'] . '`' . $whereColumns[0]['condition'] . chr(39) . $whereColumns[0]['look_for'] . chr(39); - } elseif ((count($whereColumns > 1)) && (count($conditions) > 0)) { - // More than one "WHERE" + condition found - foreach ($whereColumns as $idx => $columnArray) { - // Default is WHERE - $condition = 'WHERE'; - - // Is the condition element there? - if (isset($conditions[$columnArray['column']])) { - // Assume the condition - $condition = $conditions[$columnArray['column']]; - } // END - if - - // Add to SQL query - $SQL .= ' ' . $condition; - - // Table/alias included? - if (!empty($whereColumns[$idx]['table'])) { - // Add it as well - $SQL .= $whereColumns[$idx]['table'] . '.'; - } // END - if - - // Add the rest - $SQL .= '`' . $whereColumns[$idx]['column'] . '`' . $whereColumns[$idx]['condition'] . chr(39) . convertDollarDataToGetElement($whereColumns[$idx]['look_for']) . chr(39); - } // END - foreach - } else { - // Did not set $conditions - reportBug(__FUNCTION__, __LINE__, 'Supplied more than "whereColumns" entries but no conditions! Please fix your XML template.'); - } - } // END - if - - // Do we have entries from orderByColumns to add? - if (count($orderByColumns) > 0) { - // Add them as well - $SQL .= ' ORDER BY '; - foreach ($orderByColumns as $orderByColumn => $array) { - // Get keys (table/alias) and values (sorting itself) - $table = trim(implode('', array_keys($array))); - $sorting = trim(implode('', array_keys($array))); - - // table/alias can be omitted - if (!empty($table)) { - // table/alias is given - $SQL .= $table . '.'; - } // END - if - - // Add order-by column - $SQL .= '`' . $orderByColumn . '` ' . $sorting . ','; - } // END - foreach - - // Remove last column - $SQL = substr($SQL, 0, -1); - } // END - if - - // Now handle all over to the inner function which will execute the listing - doAdminListEntries($SQL, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters); -} - -// Do the listing of entries -function doAdminListEntries ($SQL, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters = array()) { - // Run the SQL query - $result = SQL_QUERY($SQL, __FUNCTION__, __LINE__); - - // Do we have some URLs left? - if (!SQL_HASZERONUMS($result)) { - // List all URLs - $OUT = ''; - while ($content = SQL_FETCHARRAY($result)) { - // "Translate" content - foreach ($callbackColumns as $columnName => $callbackName) { - // Fill the callback arguments - $args = array($content[$columnName]); - - // Do we have more to add? - if (isset($extraParameters[$columnName])) { - // Add them as well - $args = merge_array($args, $extraParameters[$columnName]); - } // END - if - - // Call the callback-function - //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'callbackFunction=' . $callbackName . ',args=
'.print_r($args, true).'
'); - // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided - $content[$columnName] = call_user_func_array($callbackName, $args); - } // END - foreach - - // Load row template - $OUT .= loadTemplate(trim($rowTemplate[0]), true, $content); - } // END - while - - // Load main template - loadTemplate(trim($tableTemplate[0]), false, $OUT); - } else { - // No URLs in surfbar - displayMessage('{--' .$noEntryMessageId[0] . '--}'); - } - - // Free result - SQL_FREERESULT($result); -} - // Checks proxy settins by fetching check-updates3.php from mxchange.org function adminTestProxySettings ($settingsArray) { // Set temporary the new settings diff --git a/inc/modules/member/what-points.php b/inc/modules/member/what-points.php index 6b64c1a843..7975df0833 100644 --- a/inc/modules/member/what-points.php +++ b/inc/modules/member/what-points.php @@ -189,6 +189,7 @@ if (isExtensionActive('user')) { displayMessage('{--PROBLEM_POINTS_OVERVIEW_UNAVAILABLE--}'); } +// Is ext-payout installed? if (isExtensionActive('payout')) { // Payput extension is installed and active so we can check if the user has enougth points outputPayoutList($content['part_points'] - getUserData('used_points')); diff --git a/inc/modules/member/what-subids.php b/inc/modules/member/what-subids.php new file mode 100644 index 0000000000..3ca4364019 --- /dev/null +++ b/inc/modules/member/what-subids.php @@ -0,0 +1,107 @@ + diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 8d55ecfb33..a21023e06e 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1798,60 +1798,248 @@ LIMIT 1", } } -/** - * Checks if given subject is found and if not, adds an SQL query to the - * extension registration queue. - */ -function registerExtensionPointsData ($subject, $columnName, $lockedMode, $paymentMethod) { - // Default is old extension version - $add = ''; +// List all given rows (callback function from XML) +function doGenericListEntries ($tableTemplate, $rowTemplate, $noEntryMessageId, $tableName, $columns, $whereColumns, $orderByColumns, $callbackColumns, $extraParameters = array(), $conditions = array()) { + // Verify that tableName and columns are not empty + if ((!is_array($tableName)) || (count($tableName) != 1)) { + // No tableName specified + reportBug(__FUNCTION__, __LINE__, 'tableName is not given. Please fix your XML,tableName[]=' . gettype($tableName) . '!=array,tableTemplate=' . $tableTemplate . ',rowTemplate=' . $rowTemplate); + } elseif (count($columns) == 0) { + // No columns specified + reportBug(__FUNCTION__, __LINE__, 'columns is not given. Please fix your XML,tableTemplate=' . $tableTemplate . ',rowTemplate=' . $rowTemplate . ',tableName[0]=' . $tableName[0]); + } + + // This is the minimum query, so at least columns and tableName must have entries + $SQL = 'SELECT '; - // Is the extension equal or newer 0.8.9? - if (((isInstallationPhase()) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (isExtensionInstalledAndNewer('sql_patches', '0.8.9'))) { - // Then add provider - $add = " AND `account_provider`='EXTENSION'"; + // Get the sql part back from given array + $SQL .= getSqlPartFromXmlArray($columns); + + // Remove last commata and add FROM statement + $SQL .= ' FROM `{?_MYSQL_PREFIX?}_' . $tableName[0] . '`'; + + // Do we have entries from whereColumns to add? + if (count($whereColumns) > 0) { + // Then add these as well + if (count($whereColumns) == 1) { + // One entry found + $SQL .= ' WHERE '; + + // Table/alias included? + if (!empty($whereColumns[0]['table'])) { + // Add it as well + $SQL .= $whereColumns[0]['table'] . '.'; + } // END - if + + // Add the rest + $SQL .= '`' . $whereColumns[0]['column'] . '`' . $whereColumns[0]['condition'] . chr(39) . $whereColumns[0]['look_for'] . chr(39); + } elseif ((count($whereColumns > 1)) && (count($conditions) > 0)) { + // More than one "WHERE" + condition found + foreach ($whereColumns as $idx => $columnArray) { + // Default is WHERE + $condition = 'WHERE'; + + // Is the condition element there? + if (isset($conditions[$columnArray['column']])) { + // Assume the condition + $condition = $conditions[$columnArray['column']]; + } // END - if + + // Add to SQL query + $SQL .= ' ' . $condition; + + // Table/alias included? + if (!empty($whereColumns[$idx]['table'])) { + // Add it as well + $SQL .= $whereColumns[$idx]['table'] . '.'; + } // END - if + + // Add the rest + $SQL .= '`' . $whereColumns[$idx]['column'] . '`' . $whereColumns[$idx]['condition'] . chr(39) . convertDollarDataToGetElement($whereColumns[$idx]['look_for']) . chr(39); + } // END - foreach + } else { + // Did not set $conditions + reportBug(__FUNCTION__, __LINE__, 'Supplied more than "whereColumns" entries but no conditions! Please fix your XML template.'); + } } // END - if - // Is the 'subject' there? - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ifSqlTableExists(points_data)=' . ifSqlTableExists('points_data') . ',getExtensionMode()=' . getExtensionMode() . ',add=' . $add); - if (((!ifSqlTableExists('points_data')) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (countSumTotalData($subject, 'points_data', 'id', 'subject', true, $add) == 0)) { - // Not found so: - if ((isset($GLOBALS['previous_extension'][getCurrentExtensionName()])) && (!ifSqlTableExists('points_data'))) { - $dummy = $GLOBALS['previous_extension'][getCurrentExtensionName()]; - reportBug(__FUNCTION__, __LINE__, 'previous_extension[' . gettype($dummy) . ']=' . $dummy . ',getCurrentExtensionName()=' . getCurrentExtensionName() . ' - Under development, please report this!'); - } // END - if + // Do we have entries from orderByColumns to add? + if (count($orderByColumns) > 0) { + // Add them as well + $SQL .= ' ORDER BY '; + foreach ($orderByColumns as $orderByColumn => $array) { + // Get keys (table/alias) and values (sorting itself) + $table = trim(implode('', array_keys($array))); + $sorting = trim(implode('', array_keys($array))); + + // table/alias can be omitted + if (!empty($table)) { + // table/alias is given + $SQL .= $table . '.'; + } // END - if - // ... add an SQL query - addExtensionSql(sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`,`column_name`,`locked_mode`,`payment_method`) VALUES ('%s','%s','%s','%s')", - $subject, - $columnName, - $lockedMode, - $paymentMethod - )); + // Add order-by column + $SQL .= '`' . $orderByColumn . '` ' . $sorting . ','; + } // END - foreach + + // Remove last column + $SQL = substr($SQL, 0, -1); } // END - if + + // Now handle all over to the inner function which will execute the listing + doListEntries($SQL, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters); } -/** - * Checks if given subject is found and if so, adds an SQL query to the - * extension unregistration queue. - */ -function unregisterExtensionPointsData ($subject) { - // Default is old extension version - $add = ''; +// Do the listing of entries +function doListEntries ($SQL, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters = array()) { + // Run the SQL query + $result = SQL_QUERY($SQL, __FUNCTION__, __LINE__); + + // Do we have some URLs left? + if (!SQL_HASZERONUMS($result)) { + // List all URLs + $OUT = ''; + while ($content = SQL_FETCHARRAY($result)) { + // "Translate" content + foreach ($callbackColumns as $columnName => $callbackName) { + // Fill the callback arguments + $args = array($content[$columnName]); + + // Do we have more to add? + if (isset($extraParameters[$columnName])) { + // Add them as well + $args = merge_array($args, $extraParameters[$columnName]); + } // END - if + + // Call the callback-function + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'callbackFunction=' . $callbackName . ',args=
'.print_r($args, true).'
'); + // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided + $content[$columnName] = call_user_func_array($callbackName, $args); + } // END - foreach - // Is the extension equal or newer 0.8.9? - if (isExtensionInstalledAndNewer('sql_patches', '0.8.9')) { - // Then add provider - $add = " AND `account_provider`='EXTENSION'"; + // Load row template + $OUT .= loadTemplate(trim($rowTemplate[0]), true, $content); + } // END - while + + // Load main template + loadTemplate(trim($tableTemplate[0]), false, $OUT); + } else { + // No URLs in surfbar + displayMessage('{--' .$noEntryMessageId[0] . '--}'); + } + + // Free result + SQL_FREERESULT($result); +} + +// Adds a given entry to the database +function doGenericAddEntries ($tableName, $columns = array(), $filterFunctions = array(), $extraValues = array(), $timeColumns = array(), $columnIndex = NULL) { + //* DEBUG: */ die('columns=
'.print_r($columns,true).'
,filterFunctions=
'.print_r($filterFunctions,true).'
,extraValues=
'.print_r($extraValues,true).'
,POST=
'.print_r($_POST,true).'
'); + // Verify that tableName and columns are not empty + if ((!is_array($tableName)) || (count($tableName) != 1)) { + // No tableName specified + reportBug(__FUNCTION__, __LINE__, 'tableName is not given. Please fix your XML,tableName[]=' . gettype($tableName) . '!=array: userIdColumn=' . $userIdColumn); + } elseif (count($columns) == 0) { + // No columns specified + reportBug(__FUNCTION__, __LINE__, 'columns is not given. Please fix your XML.'); + } + + // Init columns and value elements + $sqlColumns = array(); + $sqlValues = array(); + + // Default is that all went fine + $GLOBALS['__XML_PARSE_RESULT'] = true; + + // Do we have "time columns"? + if (count($timeColumns) > 0) { + // Then "walk" through all entries + foreach ($timeColumns as $column) { + // Convert all (possible) selections + convertSelectionsToEpocheTimeInPostData($column . '_ye'); + } // END - foreach + } // END - if + + // Add columns and values + foreach ($columns as $key => $columnName) { + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',columnName=' . $columnName); + // Is columnIndex set? + if (!is_null($columnIndex)) { + // Check conditions + //* DEBUG: */ die('columnIndex=
'.print_r($columnIndex,true).'
'.debug_get_printable_backtrace()); + assert((is_array($columnName)) && (is_string($columnIndex)) && (isset($columnName[$columnIndex]))); + + // Then use that index "blindly" + $columnName = $columnName[$columnIndex]; + } // END - if + + // Debug message + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',columnName[' . gettype($columnName) . ']=' . $columnName . ',filterFunctions=' . $filterFunctions[$key] . ',extraValues=' . intval(isset($extraValues[$key])) . ',extraValuesName=' . intval(isset($extraValues[$columnName . '_list'])) . '
'); + + // Copy entry securely to the final arrays + $sqlColumns[$key] = SQL_ESCAPE($columnName); + $sqlValues[$key] = SQL_ESCAPE(postRequestElement($columnName)); + + // Send data through the filter function if found + if ((isset($filterFunctions[$key])) && (isset($extraValues[$key . '_list']))) { + // Filter function set! + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - BEFORE!'); + $sqlValues[$key] = call_user_func_array($filterFunctions[$key], merge_array(array($columnName), $extraValues[$key . '_list'])); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - AFTER!'); + } elseif ((isset($filterFunctions[$key])) && (!empty($filterFunctions[$key]))) { + // Run through an extra filter + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - BEFORE!'); + $sqlValues[$key] = handleExtraValues($filterFunctions[$key], $sqlValues[$key], ''); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - AFTER!'); + } + + // Is the value not a number? + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key]); + if (($sqlValues[$key] != 'NULL') && (is_string($sqlValues[$key]))) { + // Add quotes around it + $sqlValues[$key] = chr(39) . $sqlValues[$key] . chr(39); + } // END - if + + // Is the value false? + if ($sqlValues[$key] === false) { + // One "parser" didn't like it + $GLOBALS['__XML_PARSE_RESULT'] = false; + break; + } // END - if + } // END - foreach + + // If all values are okay, continue + if ($sqlValues[$key] !== false) { + // Build the SQL query + $SQL = 'INSERT INTO `{?_MYSQL_PREFIX?}_' . $tableName[0] . '` (`' . implode('`,`', $sqlColumns) . "`) VALUES (" . implode(',', $sqlValues) . ')'; + + // Run the SQL query + SQL_QUERY($SQL, __FUNCTION__, __LINE__); } // END - if +} - // Is the 'subject' there? - if (countSumTotalData($subject, 'points_data', 'id', 'subject', true, $add) == 1) { - // Found one or more, so add an SQL query - addExtensionSql(sprintf("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_points_data` WHERE `subject`='%s'" . $add . " LIMIT 1", - $subject - )); +// Adds a given entry to the database +function memberAddEntries ($tableName, $columns = array(), $filterFunctions = array(), $extraValues = array(), $timeColumns = array(), $columnIndex = NULL) { + // Is it a member? + if (!isMember()) { + // Then abort here + return false; } // END - if + + // Set POST data generic userid + setPostRequestElement('userid', getMemberId()); + + // Call inner function + doGenericAddEntries($tableName, $columns, $filterFunctions, $extraValues, $timeColumns, $columnIndex); + + // Entry has been added? + if ((!SQL_HASZEROAFFECTED()) && ($GLOBALS['__XML_PARSE_RESULT'] === true)) { + // Display success message + displayMessage('{--MEMBER_ENTRY_ADDED--}'); + } else { + // Display failed message + displayMessage('{--MEMBER_ENTRY_NOT_ADDED--}'); + } } // [EOF] diff --git a/inc/purge/purge-user.php b/inc/purge/purge-user.php new file mode 100644 index 0000000000..3e4850c6d4 --- /dev/null +++ b/inc/purge/purge-user.php @@ -0,0 +1,50 @@ + diff --git a/inc/referral-functions.php b/inc/referral-functions.php index 667a25e0d4..04c32fa240 100644 --- a/inc/referral-functions.php +++ b/inc/referral-functions.php @@ -812,12 +812,10 @@ function determineReferralId () { if (isReferralIdValid()) { // Do not determine it, just return it return getReferralId(); - } // END - if - - // Skip this in non-html-mode and outside ref.php - if ((!isHtmlOutputMode()) && (basename($_SERVER['PHP_SELF']) != 'ref.php')) { + } elseif ((!isHtmlOutputMode()) && (basename($_SERVER['PHP_SELF']) != 'ref.php')) { + // Skip this in non-html-mode and outside ref.php return false; - } // END - if + } // Check if refid is set if (isReferralIdValid()) { @@ -833,7 +831,7 @@ function determineReferralId () { setReferralId(secureString(getRequestElement('refid'))); } elseif (isGetRequestElementSet('ref')) { // Set refid=ref (the referral link uses such variable) - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using ref from GET data (' . getRequestElement('refid') . ')'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using ref from GET data (' . getRequestElement('ref') . ')'); setReferralId(secureString(getRequestElement('ref'))); } elseif ((isGetRequestElementSet('user')) && (basename($_SERVER['PHP_SELF']) == 'click.php')) { // The variable user comes from click.php @@ -900,6 +898,9 @@ function determineReferralId () { setSession('refid', getReferralId()); } + // Run post validation filter chain + runFilterChain('post_refid_validation'); + // Return determined refid return getReferralId(); } diff --git a/inc/xml-functions.php b/inc/xml-functions.php index a623e70181..10c3d95e96 100644 --- a/inc/xml-functions.php +++ b/inc/xml-functions.php @@ -157,6 +157,7 @@ function doCallXmlCallbackFunction () { // Is it there? if (!function_exists($callbackName)) { + // No, then please add it reportBug(__FUNCTION__, __LINE__, 'callback=' . $callback . ',function=' . $function . 'arguments()=' . count($GLOBALS['__XML_ARGUMENTS'][$callback]) . ' - execute call-back does not exist.'); } // END - if diff --git a/install/tables.sql b/install/tables.sql index 30d0763955..43ccce3f6d 100644 --- a/install/tables.sql +++ b/install/tables.sql @@ -16,7 +16,7 @@ CREATE TABLE `{?_MYSQL_PREFIX?}_admins` ( `password` VARCHAR(255) NOT NULL DEFAULT '', `email` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`), - UNIQUE (`login`) + UNIQUE INDEX (`login`) ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT 'Administrator accounts'; DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_cats`; diff --git a/templates/de/html/member/member_add_subid.tpl b/templates/de/html/member/member_add_subid.tpl new file mode 100644 index 0000000000..4f7ab9b48b --- /dev/null +++ b/templates/de/html/member/member_add_subid.tpl @@ -0,0 +1,27 @@ +
+
+
+
+ {--MEMBER_ADD_SUBID_TITLE--} +
+ +
+ {--MEMBER_ADD_SUBID_LEGEND--} + +
+ + +
+
+ + +
+
+
+ +
+ {--MEMBER_ADD_SUBID_NOTICE--} +
diff --git a/templates/de/html/member/member_list_user_subids.tpl b/templates/de/html/member/member_list_user_subids.tpl new file mode 100644 index 0000000000..81e0b79398 --- /dev/null +++ b/templates/de/html/member/member_list_user_subids.tpl @@ -0,0 +1,24 @@ +
+
+ + + + + + + + + + $content + + + +
+ {--MEMBER_USER_SUBID_EDIT_DELETE_TITLE--} +
{--ID_SELECT--}{--SUBID_VALUE--}:{--SUBID_ADDED--}:
+
+
diff --git a/templates/de/html/member/member_list_user_subids_row.tpl b/templates/de/html/member/member_list_user_subids_row.tpl new file mode 100644 index 0000000000..9d8d0eeb91 --- /dev/null +++ b/templates/de/html/member/member_list_user_subids_row.tpl @@ -0,0 +1,16 @@ + + + + + +
+ $content[subid] +
+
+ {--MEMBER_USER_SUBID_STATS_LINK--} +
+ + + $content[subid_added] + + diff --git a/templates/de/html/member/member_mydata_edit.tpl b/templates/de/html/member/member_mydata_edit.tpl index 2a3cf23b35..fc99eccbe0 100644 --- a/templates/de/html/member/member_mydata_edit.tpl +++ b/templates/de/html/member/member_mydata_edit.tpl @@ -1,4 +1,4 @@ -
+
@@ -6,12 +6,14 @@ {--YOUR_LOGIN--}: {%pipe,getMemberId%} + + + + + + + - + + + + +
{--GENDER--}: {%pipe,generateGenderSelectionBox=$content[gender]%}
{--SURNAME--}, {--FAMILY--}: @@ -19,12 +21,14 @@
{--STREET_NR--}:
{--COUNTRY--}, {--ZIP--}, {--CITY--}: @@ -33,36 +37,45 @@
{--EMAIL--}:
{--BIRTHDAY--}: $content[dob]
$content[max_receive_list] + $content[max_receive_list] +
{--MEMBER_MYDATA_NOTICE--}
{--PASS_1--}:
{--PASS_2--}: