// Set content type, this is required for search engines
setContentType('text/html');
-// 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", array(bigintval(getRequestElement('banner'))), __FILE__, __LINE__);
-
- // A line has been updated?
- if ((!SQL_HASZEROAFFECTED()) && (isGetRequestElementSet('user'))) {
- // Redirect to the user's referral link
- redirectToUrl('ref.php?refid=' . bigintval(getRequestElement('user')));
- } // END - if
-} // END - if
+// Run filter chain
+runFilterChain('handle_click_php');
// Load index page
redirectToUrl('modules.php?module=index');
-// Shutdown
+// Shutdown (if reached)
doShutdown();
// [EOF]
registerFilter(__FILE__, __LINE__, 'member_earning_table_data', 'FORCED_POPUP_TABLE_DATA', FALSE, TRUE, isExtensionDryRun());
registerFilter(__FILE__, __LINE__, 'post_change_forced_campaign_status', 'FORCED_CHANGE_CAMPAIGN_STATUS', FALSE, TRUE, isExtensionDryRun());
registerFilter(__FILE__, __LINE__, 'pre_change_forced_campaign_status', 'FORCED_CHANGE_CAMPAIGN_VALIDATE_DATA', FALSE, TRUE, isExtensionDryRun());
+ registerFilter(__FILE__, __LINE__, 'handle_click_php', 'HANDLE_FORCED_AD_CLICK', FALSE, TRUE, isExtensionDryRun());
+ registerFilter(__FILE__, __LINE__, 'handle_view_php', 'HANDLE_FORCED_AD_VIEW', FALSE, TRUE, isExtensionDryRun());
break;
case 'remove': // Do stuff when removing extension
unregisterFilter(__FILE__, __LINE__, 'member_earning_table_data', 'FORCED_POPUP_TABLE_DATA', TRUE, isExtensionDryRun());
unregisterFilter(__FILE__, __LINE__, 'post_change_forced_campaign_status', 'FORCED_CHANGE_CAMPAIGN_STATUS', TRUE, isExtensionDryRun());
unregisterFilter(__FILE__, __LINE__, 'pre_change_forced_campaign_status', 'FORCED_CHANGE_CAMPAIGN_VALIDATE_DATA', TRUE, isExtensionDryRun());
+ unregisterFilter(__FILE__, __LINE__, 'handle_click_php', 'HANDLE_FORCED_AD_CLICK', TRUE, isExtensionDryRun());
+ unregisterFilter(__FILE__, __LINE__, 'handle_view_php', 'HANDLE_FORCED_AD_VIEW', TRUE, isExtensionDryRun());
break;
case 'activate': // Do stuff when admin activates this extension
// Build mails
registerFilter(__FUNCTION__, __LINE__, 'send_build_mail', 'SEND_BUILD_MAIL');
+
+ // Handle referral banner click/view
+ registerFilter(__FUNCTION__, __LINE__, 'handle_click_php', 'HANDLE_REFERRER_BANNER_CLICK');
+ registerFilter(__FUNCTION__, __LINE__, 'handle_view_php', 'HANDLE_REFERRER_BANNER_VIEW');
}
// "Registers" a new filter function
return $filterData;
}
+// Filter for handling click on forced ad
+function FILTER_HANDLE_FORCED_AD_CLICK ($filterData) {
+ // Are all required parameters set?
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
+ die(__FUNCTION__.': CALLED!');
+
+ // Return filter data
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
+ return $filterData;
+}
+
+// Filter for handling viewing forced banner
+function FILTER_HANDLE_FORCED_AD_VIEW ($filterData) {
+ // Are all required parameters set?
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
+ die(__FUNCTION__.': CALLED!');
+
+ // Return filter data
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
+ return $filterData;
+}
+
// [EOF]
?>
return $filterData;
}
+// Handles click on referral banner
+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",
+ array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__);
+
+ // A line has been updated?
+ if ((!SQL_HASZEROAFFECTED()) && (isGetRequestElementSet('user'))) {
+ // Redirect to the user's referral link
+ redirectToUrl('ref.php?refid=' . bigintval(getRequestElement('user')));
+ } // END - if
+ } // END - if
+
+ // Return filter data
+ return $filterData;
+}
+
+// Filter for handling viewing of a referral banner
+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",
+ array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__);
+
+ // Is there the banner?
+ if (SQL_NUMROWS($result) == 1) {
+ // Load the URL
+ $data = SQL_FETCHARRAY($result);
+
+ // Update counter
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `counter`=`counter`+1 WHERE `id`=%s LIMIT 1",
+ array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__);
+
+ // Set header and ...
+ setContentType('image/' . substr($data['url'], -3, 3));
+
+ // Redirect
+ redirectToUrl($data['url'], FALSE);
+ } else {
+ // @TODO No banner found, output some default banner
+ logDebugMessage(__FUNCTION__, __LINE__, 'Banner ' . bigintval(getRequestElement('banner')) . ' not dound.');
+ }
+
+ // Free memory
+ SQL_FREERESULT($result);
+ } else {
+ // Do nothing for now
+ redirectToUrl('modules.php?module=index');
+ }
+}
+
// [EOF]
?>
die();
} // END - if
+// Init XML system
+function initXml () {
+ // All conditions
+ $GLOBALS['__XML_CONDITIONS'] = array(
+ // Equals not
+ 'NOT-EQUALS' => ' != ',
+ // Is not
+ 'IS-NOT' => ' IS NOT ',
+ // Is
+ 'IS' => ' IS ',
+ // Equals
+ 'EQUALS' => ' = ',
+ );
+}
+
// Calls back a function based on given XML template data
function showEntriesByXmlCallback ($template, $content = array(), $compileCode = TRUE) {
+ // Init XML system as sch calls will be only used once per run
+ initXml();
+
// Generate FQFN for with special path
$FQFN = sprintf("%stemplates/xml/%s%s.xml",
getPath(),
// Converts given condition into a symbol
function convertXmlContion ($condition) {
- // Default is an invalid one
- $return = '???';
-
// Detect the condition again
- switch ($condition) {
- case 'EQUALS': // Equals
- $return = '=';
- break;
-
- default: // Unknown condition
- reportBug(__FUNCTION__, __LINE__, 'Condition ' . $condition . ' is unknown/unsupported.');
- break;
- } // END - switch
+ if (!isset($GLOBALS['__XML_CONDITIONS'][$condition])) {
+ reportBug(__FUNCTION__, __LINE__, 'Condition ' . $condition . ' is unknown/unsupported.');
+ } // END - if
// Return it
- return $return;
+ return $GLOBALS['__XML_CONDITIONS'][$condition];
}
// "Getter" for sql part back from given array
// Load the required file(s)
require('inc/config-global.php');
-if ((isGetRequestElementSet('user')) && (isGetRequestElementSet('banner'))) {
- // For later things... ;-)
- $result = SQL_QUERY_ESC("SELECT `url` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1",
- array(bigintval(getRequestElement('banner'))), __FILE__, __LINE__);
-
- // Is there the banner?
- if (SQL_NUMROWS($result) == 1) {
- // Load the URL
- $data = SQL_FETCHARRAY($result);
-
- // Update counter
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `counter`=`counter`+1 WHERE `id`=%s LIMIT 1",
- array(bigintval(getRequestElement('banner'))), __FILE__, __LINE__);
-
- // Set header and ...
- setContentType('image/' . substr($data['url'], -3, 3));
-
- // Redirect
- redirectToUrl($data['url'], FALSE);
- } else {
- // @TODO No banner found, output some default banner
- logDebugMessage(__FILE__, __LINE__, 'Banner ' . bigintval(getRequestElement('banner')) . ' not dound.');
- }
-
- // Free memory
- SQL_FREERESULT($result);
-} else {
- // Do nothing for now
- redirectToUrl('modules.php?module=index');
-}
+// Run filter chain
+runFilterChain('handle_view_php');
// Shutdown
doShutdown();