X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffilters.php;h=bbac2082ad12bd014289735b4f25a857a254a847;hb=ec3907de5b6c1ca85da82232707c85d22e197c11;hp=c1e54c7c7de609f3f3dd569dc73e194c99ae71c9;hpb=00790481119eefa7a54a8dda1cb191fdf4f29226;p=mailer.git diff --git a/inc/filters.php b/inc/filters.php index c1e54c7c7d..bbac2082ad 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2012 by Mailer Developer Team * + * Copyright (c) 2009 - 2013 by Mailer Developer Team * * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -46,10 +46,10 @@ function FILTER_FLUSH_FILTERS () { initSqls(); // Is a database link here and not in installation mode? - if ((!SQL_IS_LINK_UP()) && (!isInstallationPhase())) { + if ((!isSqlLinkUp()) && (!isInstallationPhase())) { // Abort here reportBug(__FUNCTION__, __LINE__, 'No database link is up. Cannot flush filters.'); - } elseif ((isInstallationPhase()) && (!SQL_IS_LINK_UP())) { + } elseif ((isInstallationPhase()) && (!isSqlLinkUp())) { // If the link is not up in installation phase, skip flushing filters //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters: No link is up.'); return; @@ -82,7 +82,7 @@ function FILTER_FLUSH_FILTERS () { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'FOUND:'.$filterName.'/'.$filterFunction.'='.$active); if (((!isset($GLOBALS['cache_array']['filter']['loaded'][$filterName][$filterFunction])) && ($active != 'R')) || ($active == 'A')) { // Is this filter already in database? - if (countSumTotalData($filterFunction, 'filters', 'filter_name', 'filter_function', TRUE, sprintf(" AND `filter_name`='%s'", SQL_ESCAPE($filterName))) == 0) { + if (countSumTotalData($filterFunction, 'filters', 'filter_name', 'filter_function', TRUE, sprintf(" AND `filter_name`='%s'", sqlEscapeString($filterName))) == 0) { // Add this filter (all filters are active by default) //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ADD:'.$filterName.'/'.$filterFunction); $insertSQL .= sprintf("('%s','%s','Y'),", $filterName, $filterFunction); @@ -270,17 +270,17 @@ function FILTER_RUN_SQLS ($filterData) { if ((substr(strtolower($sql), 0, 11) == 'alter table') && (!isset($filterData['ext_installing']))) { // Analyse the alteration command //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Alterting table: ' . $sql . ',enable_codes=' . intval($filterData['enable_codes'])); - SQL_ALTER_TABLE($sql, __FUNCTION__, __LINE__, $filterData['enable_codes']); + sqlQueryAlterTable($sql, __FUNCTION__, __LINE__, $filterData['enable_codes']); } else { // Run regular SQL command //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Running regular query: ' . $sql . ',enable_codes=' . intval($filterData['enable_codes'])); - SQL_QUERY($sql, __FUNCTION__, __LINE__, $filterData['enable_codes']); + sqlQuery($sql, __FUNCTION__, __LINE__, $filterData['enable_codes']); } // Has a line changed? - if (!SQL_HASZEROAFFECTED()) { + if (!ifSqlHasZeroAffectedRows()) { // Add it to total account - $count += SQL_AFFECTEDROWS(); + $count += sqlAffectedRows(); } // END - if } // END - if } // END - foreach @@ -567,10 +567,10 @@ function FILTER_COMPILE_EXPRESSION_CODE ($filterData) { // Runs some generic filter update steps function FILTER_UPDATE_EXTENSION_DATA ($ext_name) { // Create task (we ignore the task id here) - createExtensionUpdateTask(getCurrentAdminId(), $ext_name, $GLOBALS['update_ver'][$ext_name], SQL_ESCAPE(getExtensionNotes(getExtensionNotes()))); + createExtensionUpdateTask(getCurrentAdminId(), $ext_name, $GLOBALS['update_ver'][$ext_name], sqlEscapeString(getExtensionNotes(getExtensionNotes()))); // Update extension's version - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_version`='%s' WHERE `ext_name`='%s' LIMIT 1", + sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_version`='%s' WHERE `ext_name`='%s' LIMIT 1", array($GLOBALS['update_ver'][$ext_name], $ext_name), __FUNCTION__, __LINE__); // Remove arrays @@ -581,23 +581,21 @@ function FILTER_UPDATE_EXTENSION_DATA ($ext_name) { // Load more hourly reset scripts function FILTER_RUN_HOURLY_INCLUDES () { // Is the reset set or old sql_patches? - if (((!isHourlyResetEnabled()) || (!isExtensionInstalledAndNewer('sql_patches', '0.7.5'))) && (isHtmlOutputMode())) { + if (((!isHourlyResetEnabled()) || (!isExtensionInstalledAndNewer('sql_patches', '0.9.8'))) && (isHtmlOutputMode())) { // Then abort here - reportBug(__FUNCTION__, __LINE__, 'Cannot run hourly reset! enabled='.intval(isHourlyResetEnabled()).',ext='.intval(isExtensionInstalledAndNewer('sql_patches', '0.9.8')).' Please report this bug. Thanks'); + reportBug(__FUNCTION__, __LINE__, 'Cannot run hourly reset! enabled='.intval(isHourlyResetEnabled()).',isExtensionInstalledAndNewer='.intval(isExtensionInstalledAndNewer('sql_patches', '0.9.8')).' Please report this bug. Thanks'); } // END - if - // Is the config entry set? - if (isExtensionInstalledAndNewer('sql_patches', '0.7.5')) { - // Get more hourly reset scripts - setIncludePool('hourly', getArrayFromDirectory('inc/hourly/', 'hourly_')); - - // Update database - if ((!isConfigEntrySet('DEBUG_HOURLY')) || (!isDebugHourlyEnabled())) { - updateConfiguration('last_hourly', getHour()); - } // END - if + // Is ext-sql_patches at least 0.9.8? + if (isExtensionInstalledAndNewer('sql_patches', '0.9.8')) { + // Has it changed? + if ((getLastHourly() != getHour()) || (isDebugHourlyEnabled())) { + // Get more hourly reset scripts + setIncludePool('hourly', getArrayFromDirectory('inc/hourly/', 'hourly_')); // Run the filter runFilterChain('load_includes', 'hourly'); + } // END - if } // END - if } @@ -606,80 +604,68 @@ function FILTER_RUN_DAILY_INCLUDES () { // Is the reset set or old sql_patches? if (((!isDailyResetEnabled()) || (!isExtensionInstalledAndNewer('sql_patches', '0.9.8'))) && (isHtmlOutputMode())) { // Then abort here - reportBug(__FUNCTION__, __LINE__, 'Cannot run daily reset! enabled='.intval(isDailyResetEnabled()).',ext='.intval(isExtensionInstalledAndNewer('sql_patches', '0.9.8')).' Please report this bug. Thanks'); + reportBug(__FUNCTION__, __LINE__, 'Cannot run daily reset! enabled='.intval(isDailyResetEnabled()).',isExtensionInstalledAndNewer='.intval(isExtensionInstalledAndNewer('sql_patches', '0.9.8')).' Please report this bug. Thanks'); } // END - if - // Get more daily reset scripts - setIncludePool('daily', getArrayFromDirectory('inc/daily/', 'daily_')); + // Is ext-sql_patches at least 0.9.8? + if (isExtensionInstalledAndNewer('sql_patches', '0.9.8')) { + // Has it changed? + if ((getLastDaily() != getDay()) || (isDebugDailyEnabled())) { + // Get more daily reset scripts + setIncludePool('daily', getArrayFromDirectory('inc/daily/', 'daily_')); - // Update configuration if this reset is not being debugged - if (!isDebugDailyEnabled()) { - updateConfiguration('last_daily', getDay()); + // Run the filter + runFilterChain('load_includes', 'daily'); + } // END - if } // END - if - - // Run the filter - runFilterChain('load_includes', 'daily'); } // Load more weeklt scripts function FILTER_RUN_WEEKLY_INCLUDES () { // Is the reset set or old sql_patches? - if (((!isWeeklyResetDebugEnabled()) || (!isExtensionInstalledAndNewer('sql_patches', '0.9.8'))) && (isHtmlOutputMode())) { + if (((!isWeeklyResetEnabled()) || (!isExtensionInstalledAndNewer('sql_patches', '0.9.8'))) && (isHtmlOutputMode())) { // Then abort here - reportBug(__FUNCTION__, __LINE__, 'Cannot run weekly reset! enabled='.intval(isWeeklyResetDebugEnabled()).',ext='.intval(isExtensionInstalledAndNewer('sql_patches', '0.9.8')).' Please report this bug. Thanks'); + reportBug(__FUNCTION__, __LINE__, 'Cannot run weekly reset! enabled='.intval(isWeeklyResetEnabled()).',isExtensionInstalledAndNewer()='.intval(isExtensionInstalledAndNewer('sql_patches', '0.9.8')).' Please report this bug. Thanks'); } // END - if - // Is the config entry set? - if (isExtensionInstalledAndNewer('sql_patches', '0.4.2')) { + // Is ext-sql_patches at least 0.9.8? + if (isExtensionInstalledAndNewer('sql_patches', '0.9.8')) { // Has it changed? - if (((isConfigEntrySet('last_weekly')) && (getLastWeekly() != getWeek())) || (isWeeklyResetDebugEnabled())) { + if ((getLastWeekly() != getWeek()) || (isDebugWeeklyEnabled())) { // Include weekly reset scripts setIncludePool('weekly', getArrayFromDirectory('inc/weekly/', 'weekly_')); - // Update configuration if this reset is not being debugged - if (!isWeeklyResetDebugEnabled()) { - updateConfiguration('last_weekly', getWeek()); - } // END - if + // Run the filter + runFilterChain('load_includes', 'weekly'); } // END - if - - // Run the filter - runFilterChain('load_includes', 'weekly'); } // END - if } // Load more monthly scripts function FILTER_RUN_MONTHLY_INCLUDES () { // Is the reset set or old sql_patches? - if (((!isMonthlyResetDebugEnabled()) || (!isExtensionInstalledAndNewer('sql_patches', '0.9.8'))) && (isHtmlOutputMode())) { + if (((!isMonthlyResetEnabled()) || (!isExtensionInstalledAndNewer('sql_patches', '0.9.8'))) && (isHtmlOutputMode())) { // Then abort here - reportBug(__FUNCTION__, __LINE__, 'Cannot run monthly reset! enabled='.intval(isMonthlyResetDebugEnabled()).',ext='.intval(isExtensionInstalledAndNewer('sql_patches', '0.9.8')).' Please report this bug. Thanks'); + reportBug(__FUNCTION__, __LINE__, 'Cannot run monthly reset! enabled='.intval(isMonthlyResetEnabled()).',isExtensionInstalledAndNewer='.intval(isExtensionInstalledAndNewer('sql_patches', '0.9.8')).' Please report this bug. Thanks'); } // END - if - // Is the config entry set? - if (isExtensionInstalledAndNewer('sql_patches', '0.4.2')) { - // Create current month mark - $currMonth = getMonth(); - + // Is ext-sql_patches at least 0.9.8? + if (isExtensionInstalledAndNewer('sql_patches', '0.9.8')) { // Has it changed? - if ((getLastMonthly() != $currMonth) || (isMonthlyResetDebugEnabled())) { + if ((getLastMonthly() != getMonth()) || (isDebugMonthlyEnabled())) { // Include monthly reset scripts setIncludePool('monthly', getArrayFromDirectory('inc/monthly/', 'monthly_')); - // Update configuration if this reset is not being debugged - if (!isMonthlyResetDebugEnabled()) { - updateConfiguration('last_monthly', $currMonth); - } // END - if + // Run the filter + runFilterChain('load_includes', 'monthly'); } // END - if } // END - if - - // Run the filter - runFilterChain('load_includes', 'monthly'); } // Filter for removing the given extension function FILTER_REMOVE_EXTENSION () { // Delete this extension (remember to remove it from your server *before* you click on welcome! - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", + sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", array(getCurrentExtensionName()), __FUNCTION__, __LINE__); // Remove the extension from cache array as well @@ -843,6 +829,7 @@ function FILTER_RUN_HOURLY_RESET () { } // END - if // Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getLastHourly()=' . getLastHourly() . ',getHour()=' . getHour()); if (((getLastHourly() != getHour()) || (isDebugHourlyEnabled())) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestElementSet('setup')) && (!isCssOutputMode())) { // Tell every module we are in reset-mode! doHourly(); @@ -857,6 +844,7 @@ function FILTER_RUN_DAILY_RESET () { } // END - if // Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getLastDaily()=' . getLastDaily() . ',getDay()=' . getDay()); if (((getLastDaily() != getDay()) || (isDebugDailyEnabled())) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestElementSet('setup')) && (!isCssOutputMode())) { // Tell every module we are in reset-mode! doDaily(); @@ -871,6 +859,7 @@ function FILTER_RUN_WEEKLY_RESET () { } // END - if // Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getLastWeekly()=' . getLastWeekly() . ',getWeek()=' . getWeek()); if (((getLastWeekly() != getWeek()) || (isDebugWeeklyEnabled())) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestElementSet('setup')) && (!isCssOutputMode())) { // Tell every module we are in reset-mode! doWeekly(); @@ -885,6 +874,7 @@ function FILTER_RUN_MONTHLY_RESET () { } // END - if // Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getLastMonthly()=' . getLastMonthly() . ',getMonth()=' . getMonth()); if (((getLastMonthly() != getMonth()) || (isDebugMonthlyEnabled())) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestElementSet('setup')) && (!isCssOutputMode())) { // Tell every module we are in reset-mode! doMonthly(); @@ -953,9 +943,9 @@ function FILTER_COUNT_MODULE () { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getModule()=' . getModule() . ' - ENTERED!'); // Count module click - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `clicks`=`clicks`+1 WHERE `module`='%s' LIMIT 1", + sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `clicks`=`clicks`+1 WHERE `module`='%s' LIMIT 1", array(getModule()), __FUNCTION__, __LINE__); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getModule()=' . getModule() . ',SQL_AFFECTEDROWS()=' . SQL_AFFECTEDROWS() . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getModule()=' . getModule() . ',sqlAffectedRows()=' . sqlAffectedRows() . ' - EXIT!'); } // Handles fatal errors @@ -1117,7 +1107,7 @@ function FILTER_RESET_USER_LOGIN_FAILURE () { // Remmeber login failures if available if (isExtensionInstalledAndNewer('user', '0.3.7')) { // Reset login failures - SQL_QUERY_ESC("UPDATE + sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `login_failures`=0, @@ -1159,7 +1149,7 @@ function FILTER_LOAD_PAGE_HEADER () { $GLOBALS['__page_header'] .= loadTemplate(getMenuModeFromModule() . '_metadata', TRUE); // Add meta description to header - if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP()) && (getModule() == 'index')) { + if ((isInstalled()) && (isAdminRegistered()) && (isSqlLinkUp()) && (getModule() == 'index')) { // Add meta description not in admin and login module and when the script is installed generateMetaDescriptionCode(); } // END - if @@ -1263,12 +1253,12 @@ function FILTER_HANDLE_HOME_IN_INDEX_SETTING ($filterData) { // Filter to add history entry function FILTER_ADD_HISTORY_ENTRY ($filterData) { // Add the entry - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_history` (`history_subject`, `history_userid`, `history_value`) VALUES ('%s',%s,'%s')", + sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_history` (`history_subject`, `history_userid`, `history_value`) VALUES ('%s',%s,'%s')", $filterData, __FUNCTION__, __LINE__); // Remember insert id for other filters - $filterData['history_id'] = SQL_INSERTID(); + $filterData['history_id'] = getSqlInsertId(); // Return data return $filterData; @@ -1339,11 +1329,11 @@ function FILTER_HANDLE_REFERRER_BANNER_CLICK ($filterData) { // Check required parameters if ((isGetRequestElementSet('user')) && (isGetRequestElementSet('banner'))) { // Update clicks counter... - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1", + sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1", array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__); // A line has been updated? - if ((!SQL_HASZEROAFFECTED()) && (isGetRequestElementSet('user'))) { + if ((!ifSqlHasZeroAffectedRows()) && (isGetRequestElementSet('user'))) { // Redirect to the user's referral link redirectToUrl('ref.php?refid=' . bigintval(getRequestElement('user'))); } // END - if @@ -1358,16 +1348,16 @@ function FILTER_HANDLE_REFERRER_BANNER_VIEW ($filterData) { // Are all required parameters set if ((isGetRequestElementSet('user')) && (isGetRequestElementSet('banner'))) { // For later things... ;-) - $result = SQL_QUERY_ESC("SELECT `url` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1", + $result = sqlQueryEscaped("SELECT `url` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1", array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__); // Is there the banner? - if (SQL_NUMROWS($result) == 1) { + if (sqlNumRows($result) == 1) { // Load the URL - $data = SQL_FETCHARRAY($result); + $data = sqlFetchArray($result); // Update counter - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `counter`=`counter`+1 WHERE `id`=%s LIMIT 1", + sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `counter`=`counter`+1 WHERE `id`=%s LIMIT 1", array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__); // Set header and ... @@ -1381,7 +1371,7 @@ function FILTER_HANDLE_REFERRER_BANNER_VIEW ($filterData) { logDebugMessage(__FUNCTION__, __LINE__, 'Banner ' . bigintval(getRequestElement('banner')) . ' not found.'); // Free memory - SQL_FREERESULT($result); + sqlFreeResult($result); } // END - if // Do nothing for now @@ -1423,16 +1413,16 @@ function FILTER_SERVER_NAME_EXTRA_AUTOPURGE ($filterData) { // Is purging configured? if ((isApServerNameEnabled()) && (getApServerNameSince() > 0)) { // Then start purging - SQL_QUERY('DELETE LOW_PRIORITY FROM + sqlQuery('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_server_name_log` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`server_name_added`)) >= {?ap_server_name_since?}', __FILE__, __LINE__); // Are some entries deleted? - if (SQL_AFFECTEDROWS() > 0) { + if (sqlAffectedRows() > 0) { // Okay, then send an email to the admin - sendAdminNotification('{--ADMIN_PURGE_USER_SERVER_NAME_LOG_SUBJECT--}', 'admin_purge_user_server_name_log', SQL_AFFECTEDROWS()); + sendAdminNotification('{--ADMIN_PURGE_USER_SERVER_NAME_LOG_SUBJECT--}', 'admin_purge_user_server_name_log', sqlAffectedRows()); } // END - if } // END - if