+ // Is this entry valid?
+ if ($isValid) {
+ if (($time == '0') && ($payment > 0)) $time = '1';
+ if (($time > 0) && ($payment > 0)) {
+ if (!empty($code)) {
+ // Generate code
+ $img_code = generateRandomCode(getConfig('code_length'), $code, $url_uid, $urlId);
+ } // END - if
+
+ // @TODO Rewrite this to a filter
+ switch ($mode) {
+ case 'add':
+ // Init stats data
+ $stats_data = 0;
+
+ // Count clicks
+ // @TODO Rewrite this to a filter
+ switch ($ltype)
+ {
+ case 'NORMAL':
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_stats` SET clicks=clicks + 1 WHERE `id`=%s LIMIT 1",
+ array($url_mid), __FILE__, __LINE__);
+
+ // Update mediadata as well
+ if (GET_EXT_VERSION('mediadata') >= '0.0.4') {
+ // Update database
+ MEDIA_UPDATE_ENTRY(array('total_clicks', 'normal_clicks'), 'add', 1);
+ }
+ $stats_data = $url_mid;
+ break;
+
+ case 'BONUS':
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_bonus` SET clicks=clicks + 1 WHERE `id`=%s LIMIT 1",
+ array($url_bid), __FILE__, __LINE__);
+
+ // Update mediadata as well
+ if (GET_EXT_VERSION('mediadata') >= '0.0.4') {
+ // Update database
+ MEDIA_UPDATE_ENTRY(array('total_clicks', 'bonus_clicks'), 'add', 1);
+ }
+ $stats_data = $url_bid;
+ break;
+
+ default: // Unknown type
+ debug_report_bug('Unknown mail type ' . $ltype . ' detected.');
+ break;
+ }
+
+ // Export data into constants for the template
+ // @TODO Rewrite these constants
+ define('_POINTS_VALUE' , translateComma($payment));
+ define('_TEMPLATE_BANNER', LOAD_TEMPLATE('mailid_banner', true));
+
+ // Only when user extension = v0.1.2: Update mails-confirmed counter
+ // @TODO Rewrite these blocks to filter
+ if (GET_EXT_VERSION('user') >= '0.1.2') {
+ // Update counter
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET mails_confirmed=mails_confirmed + 1 WHERE `userid`=%s LIMIT 1",
+ array($url_uid), __FILE__, __LINE__);
+
+ // Update random confirmed as well?
+ if (GET_EXT_VERSION('user') >= '0.3.4') {
+ // Update second counter
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET rand_confirmed=rand_confirmed + 1 WHERE `userid`=%s LIMIT 1",
+ array($url_uid), __FILE__, __LINE__);
+ } // END - if
+ } // END - if
+
+ // Insert stats record
+ insertUserStatsRecord($url_uid, $type, $stats_data);
+
+ // Right code entered?
+ if (bigintval(REQUEST_POST('gfx_check')) == $img_code) {
+ // Add points over referal system is the default
+ $locked = false;
+ $template = 'mailid_points_done';
+
+ // Right code entered add points and remove entry
+ if (($ref_pay > 0) && (getConfig('allow_direct_pay') != 'Y')) {
+ // Don't add points over the referal system
+ $locked = true;
+ $template = 'mailid_points_locked';