2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 07/16/2004 *
4 * =================== Last change: 10/27/2004 *
6 * -------------------------------------------------------------------- *
7 * File : user_functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Special functions for user extension *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Spezielle Funktionen fuer die user-Erweiterung *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
45 // Add links for selecting some users
46 function alpha ($sortby, $colspan, $return=false) {
47 if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', 0);
48 $add = '&page='.getRequestParameter('page').'&offset='.getRequestParameter('offset');
49 if (isGetRequestParameterSet('mode')) $add .= '&mode='.getRequestParameter('mode');
51 /* Creates the list of letters and makes them a link. */
52 $alphabet = explode(',', 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,');
53 $num = count($alphabet) - 1;
55 while (list($counter, $ltr) = each($alphabet)) {
56 if (getRequestParameter('letter') == $ltr) {
57 // Current letter is letter from URL
58 $OUT .= '<strong>' . $ltr . '</strong>';
60 // Output link to letter
61 $OUT .= '<a href="{%url=modules.php?module=admin&what=' . getWhat();
62 if (isGetRequestParameterSet('mode')) $OUT .= '&mode=' . getRequestParameter('mode');
63 $OUT .= '&letter=' . $ltr . '&sortby=' . $sortby . $add . '%}">' . $ltr . '</a>';
66 if ((($counter / getConfig('user_alpha')) == round($counter / getConfig('user_alpha'))) && ($counter > 0)) {
68 } elseif ( $counter != $num ) {
75 'colspan2' => $colspan,
76 'alpha_selection' => $OUT
80 $OUT = loadTemplate('admin_list_user_alpha', true, $content);
81 if ($return === true) {
82 // Return generated code
85 // Output generated code
90 // Add links for sorting
91 function addSortLinks ($letter, $sortby, $colspan, $return=false) {
93 if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', 0);
94 if (!isGetRequestParameterSet('page')) setGetRequestParameter('page' , 0);
96 // Add page and offset
97 $add = '&page=' . getRequestParameter('page') . '&offset=' . getRequestParameter('offset');
100 if (isGetRequestParameterSet('status')) $add .= '&mode=' . getRequestParameter('status');
101 elseif (isGetRequestParameterSet('mode')) $add .= '&mode=' . getRequestParameter('mode');
103 // Makes order by links..
104 if ($letter == 'front') $letter = '';
106 // Prepare array with all possible sorters
108 'userid' => '{--_UID--}',
109 'family' => '{--FAMILY--}',
110 'email' => '{--EMAIL--}',
111 'REMOTE_ADDR' => '{--REMOTE_IP--}'
114 // Add nickname if extension is installed
115 if (isExtensionActive('nickname')) {
116 $list['nickname'] = '{--NICKNAME--}';
119 foreach ($list as $sort => $title) {
120 if ($sortby == $sort) {
121 $OUT .= '<strong>' . $title . '</strong>|';
123 $OUT .= '<a href="{%url=modules.php?module=admin&what=list_user&letter=' . $letter . '&sortby=' . $sort . $add . '%}">' . $title . '</a>|';
127 // Add list and colspan
128 $content['list'] = substr($OUT, 0, -13);
129 $content['colspan2'] = $colspan;
132 $OUT = loadTemplate('admin_list_user_sort', true, $content);
134 // Should we return or output?
135 if ($return === true) {
144 // Add page navigation
145 function addPageNavigation ($numPages, $offset, $showForm, $colspan, $return=false) {
146 // @TODO These two constants are no longer used, maybe we reactivate this code?
147 //if ($showForm === true) {
148 // // Load form for changing number of lines
149 // define('__FORM_HEADER', loadTemplate('admin_list_user_sort_form', true));
150 // define('__FORM_FOOTER', '<tr><td colspan="'.$colspan.'" class="seperator bottom"> </td></tr>');
153 // define('__FORM_HEADER', '<tr><td colspan="' . $colspan . '" class="seperator"> </td></tr>');
154 // define('__FORM_FOOTER', '<tr><td colspan="' . $colspan . '" class="seperator bottom"> </td></tr>');
158 for ($page = 1; $page <= $numPages; $page++) {
159 if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
162 if (!isGetRequestParameterSet('letter')) setGetRequestParameter('letter', '');
163 if (!isGetRequestParameterSet('sortby')) setGetRequestParameter('sortby', 'userid');
166 $OUT .= '<a href="{%url=modules.php?module=admin&what=' . getWhat();
168 // Add status or mode
169 if (isGetRequestParameterSet('status')) $OUT .= '&mode=' . getRequestParameter('status');
170 elseif (isGetRequestParameterSet('mode')) $OUT .= '&mode=' . getRequestParameter('mode');
173 $OUT .= '&letter=' . getRequestParameter('letter') . '&sortby=' . getRequestParameter('sortby') . '&page=' . $page . '&offset=' . $offset . '%}">';
178 if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
179 $OUT .= '-</strong>';
184 if ($page < $numPages) $OUT .= '|';
187 // Remember the list and colspan
188 $content['list'] = $OUT;
189 $content['colspan2'] = $colspan;
192 $OUT = loadTemplate('admin_list_user_pagenav', true, $content);
193 if ($return === true) {
202 // Create email link to user's account
203 function generateUserEmailLink ($email, $mod = 'admin') {
204 // Show contact link only if user is confirmed by default
205 $locked = " AND `status`='CONFIRMED'";
207 // But admins shall always see it
208 if (isAdmin()) $locked = '';
210 $result = SQL_QUERY_ESC("SELECT
213 `{?_MYSQL_PREFIX?}_user_data`
215 `email`='%s'" . $locked."
217 array($email), __FUNCTION__, __LINE__);
218 if (SQL_NUMROWS($result) == 1) {
220 list($userid) = SQL_FETCHROW($result);
222 // Rewrite email address to contact link
223 $email = '{%url=modules.php?module=' . $mod . '&what=user_contct&userid=' . bigintval($userid) . '%}';
227 SQL_FREERESULT($result);
229 // Return rewritten (?) email address
233 // Selects a random user id as the new referal id if they have at least X confirmed mails in this run
234 // @TODO Double-check configuration entry here
235 function determineRandomReferalId () {
236 // Default is zero refid
239 // Is the extension version fine?
240 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
242 $totalUsers = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, " AND `rand_confirmed` >= {?user_min_confirmed?}");
244 // Do we have at least one?
245 if ($totalUsers > 0) {
246 // Then choose random number
247 $randNum = mt_rand(0, ($totalUsers - 1));
249 // Look for random user
250 $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' AND `rand_confirmed` >= {?user_min_confirmed?} ORDER BY `rand_confirmed` DESC LIMIT %s, 1",
251 array($randNum), __FUNCTION__, __LINE__);
253 // Do we have one entry there?
254 if (SQL_NUMROWS($result) == 1) {
255 // Use that userid as new referal id
256 list($refid) = SQL_FETCHROW($result);
258 // Reset this user's counter
259 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=0 WHERE `userid`=%s LIMIT 1",
260 array($refid), __FUNCTION__, __LINE__);
264 SQL_FREERESULT($result);
273 function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.php?module=index&what=login&login=') {
291 if ((isExtensionActive('nickname')) && (isNicknameUsed($userid))) {
293 fetchUserData($userid, 'nickname');
294 } elseif (isNicknameUsed($userid)) {
295 // No nickname installed
296 $errorCode = getCode('EXTENSION_PROBLEM');
299 // Direct userid entered
300 $isFound = fetchUserData($userid);
304 if (($errorCode == '0') && ($isFound === true)) {
305 // Get user data array and set userid (e.g. important if we login with nickname)
306 $content = getUserDataArray();
307 if (!empty($content['userid'])) $userid = bigintval($content['userid']);
310 // Is there an entry?
311 if ((isUserDataValid()) && (getUserData('status') == 'CONFIRMED') && (!empty($content['userid']))) {
312 // Check for old MD5 passwords
313 if ((strlen(getUserData('password')) == 32) && (md5($passwd) == getUserData('password'))) {
314 // Just set the hash to the password from DB... :)
315 $content['hash'] = getUserData('password');
317 // Hash password with improved way for comparsion
318 $content['hash'] = generateHash($passwd, substr(getUserData('password'), 0, -40));
321 // Does the password match the hash?
322 if ($content['hash'] == getUserData('password')) {
323 // New hashed password found so let's generate a new one
324 $content['hash'] = generateHash($passwd);
326 // ... and update database
327 // @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content);
328 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `password`='%s' WHERE `userid`=%s AND `status`='CONFIRMED' LIMIT 1",
329 array($content['hash'], $userid), __FUNCTION__, __LINE__);
331 // No login bonus by default
332 $GLOBALS['bonus_payed'] = false;
334 // Probe for last online timemark
335 $probe = time() - getUserData('last_online');
336 if (getUserData('last_login') > 0) $probe = time() - getUserData('last_login');
338 if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && ($probe >= getConfig('login_timeout'))) {
339 // Add login bonus to user's account
340 $add = ', `login_bonus`=`login_bonus`+{?login_bonus?}';
341 $GLOBALS['bonus_payed'] = true;
343 // Subtract login bonus from userid's account or jackpot
344 if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getConfig('bonus_mode') != 'ADD')) handleBonusPoints('login_bonus');
347 // @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON));
350 setMemberId($userid);
352 // Try to set session data (which shall normally always work!)
353 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',hash=' . $content['hash'] . '(' . strlen($content['hash']) . ')');
354 if ((setSession('userid', $userid )) && (setSession('u_hash', encodeHashForCookie($content['hash'])))) {
355 // Update database records
356 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `total_logins`=`total_logins`+1" . $add . " WHERE `userid`=%s LIMIT 1",
357 array($userid), __FUNCTION__, __LINE__);
358 if (SQL_AFFECTEDROWS() == 1) {
359 // Is a success URL set?
360 if (empty($successUrl)) {
361 // Procedure to checking for login data
362 if (($GLOBALS['bonus_payed'] === true) && (isExtensionActive('bonus'))) {
363 // Bonus added (just displaying!)
364 $url = 'modules.php?module=chk_login&mode=bonus';
367 $url = 'modules.php?module=chk_login&mode=login';
374 // Cannot update counter!
375 $errorCode = getCode('CNTR_FAILED');
378 // Cookies not setable!
379 $errorCode = getCode('COOKIES_DISABLED');
381 } elseif (isExtensionInstalledAndNewer('sql_patches', '0.6.1')) {
382 // Update failture counter
383 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `login_failures`=`login_failures`+1,`last_failure`=NOW() WHERE `userid`=%s LIMIT 1",
384 array($userid), __FUNCTION__, __LINE__);
387 $errorCode = getCode('WRONG_PASS');
389 } elseif ((isUserDataValid()) && (getUserData('status') != 'CONFIRMED')) {
390 // Create an error code from given status
391 $errorCode = generateErrorCodeFromUserStatus(getUserData('status'));
393 // Set userid in session
394 setSession('current_userid', getUserData('userid'));
395 } elseif (!isUserDataValid()) {
396 // User id not found!
397 $errorCode = getCode('WRONG_ID');
400 $errorCode = getCode('UNKNOWN_ERROR');
403 // Error code provided?
404 if ($errorCode > 0) {
405 // Then reconstruct the URL
406 $url = $errorUrl . $errorCode;
408 // Extension set? Then add it as well.
409 if (!empty($ext)) $url .= '&ext=' . $ext;
416 // Try to send a new password for the given user account
417 function doNewUserPassword ($email, $userid) {
418 // Init result and error
422 // Probe userid/nickname
423 // @TODO We should try to rewrite this to fetchUserData() somehow
424 if (!empty($email)) {
426 $result = SQL_QUERY_ESC("SELECT `userid`, `status` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `email`='%s' OR `email`='%s' LIMIT 1",
427 array($email, str_replace('.', '{DOT}', $email)), __FUNCTION__, __LINE__);
428 } elseif ((isExtensionActive('nickname')) && (isNicknameOrUserid($userid))) {
430 $result = SQL_QUERY_ESC("SELECT `userid`, `status` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `nickname`='%s' OR `userid`='%s' OR `email`='%s' LIMIT 1",
431 array($userid, $userid, $email), __FUNCTION__, __LINE__);
432 } elseif ((isValidUserId($userid)) && (empty($email))) {
433 // Direct userid entered
434 $result = SQL_QUERY_ESC("SELECT `userid`, `status` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
435 array(bigintval($userid)), __FUNCTION__, __LINE__);
438 logDebugMessage(__FUNCTION__, __LINE__, 'Userid is not set! BUG!');
439 $errorCode = getCode('WRONG_ID');
443 if (SQL_NUMROWS($result) == 1) {
444 // This data is valid, so we create a new pass... :-)
445 list($userid, $status) = SQL_FETCHROW($result);
447 if ($status == 'CONFIRMED') {
448 // Ooppps, this was missing! ;-) We should update the database...
449 $NEW_PASS = generatePassword();
450 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `password`='%s' WHERE `userid`=%s LIMIT 1",
451 array(generateHash($NEW_PASS), $userid), __FUNCTION__, __LINE__);
453 // Prepare data and message for email
454 $message = loadEmailTemplate('new-pass', array('new_pass' => $NEW_PASS, 'nickname' => $userid), $userid);
456 // ... and send it away
457 sendEmail($userid, '{--GUEST_NEW_PASSWORD--}', $message);
459 // Output note to user
460 loadTemplate('admin_settings_saved', false, '{--GUEST_NEW_PASSWORD_SEND--}');
462 // Account is locked or unconfirmed
463 $errorCode = generateErrorCodeFromUserStatus($status);
466 redirectToUrl('modules.php?module=index&what=login&login='.$errorCode);
469 // id or email is wrong
470 loadTemplate('admin_settings_saved', false, '<span class="notice">{--GUEST_WRONG_ID_EMAIL--}</span>');
473 // Return the error code
477 // Get timestamp for given stats type and data
478 function getTimestampFromUserStats ($statsType, $statsData, $userid = '0') {
479 // Default timestamp is zero
480 $data['inserted'] = '0';
483 if ((isMemberIdSet()) && ($userid == '0')) {
484 $userid = getMemberId();
487 // Is the extension installed and updated?
488 if ((!isExtensionActive('sql_patches')) || (isExtensionOlder('sql_patches', '0.5.6'))) {
490 return $data['inserted'];
493 // Try to find the entry
494 $result = SQL_QUERY_ESC("SELECT
495 UNIX_TIMESTAMP(`inserted`) AS inserted
497 `{?_MYSQL_PREFIX?}_user_stats_data`
500 `stats_type`='%s' AND
507 ), __FUNCTION__, __LINE__);
509 // Is the entry there?
510 if (SQL_NUMROWS($result) == 1) {
512 $data = SQL_FETCHARRAY($result);
516 SQL_FREERESULT($result);
519 return $data['inserted'];
522 // Inserts user stats
523 function insertUserStatsRecord ($userid, $statsType, $statsData) {
524 // Is the extension installed and updated?
525 if ((!isExtensionActive('sql_patches')) || (isExtensionOlder('sql_patches', '0.5.6'))) {
531 if ((!getTimestampFromUserStats($statsType, $statsData, $userid)) && (!is_array($statsData))) {
533 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_stats_data` (`userid`,`stats_type`,`stats_data`) VALUES (%s,'%s','%s')",
538 ), __FUNCTION__, __LINE__);
539 } elseif (is_array($statsData)) {
541 logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',type=' . $statsType . ',data=' . gettype($statsData) . ': Invalid statistics data type!');
545 // Confirms a user account
546 function doConfirmUserAccount ($hash) {
549 'message' => '{--GUEST_CONFIRMED_FAILED--}',
553 // Initialize the user id
556 // Search for an unconfirmed or confirmed account
557 $result = SQL_QUERY_ESC("SELECT `userid`, `email`, `refid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `user_hash`='%s' AND (`status`='UNCONFIRMED' OR `status`='CONFIRMED') LIMIT 1",
558 array($hash), __FILE__, __LINE__);
559 if (SQL_NUMROWS($result) == 1) {
560 // Ok, he want's to confirm now so we load some data
561 list($userid, $email, $refid) = SQL_FETCHROW($result);
564 if (!fetchUserData($userid)) {
565 // Not found, should not happen
566 debug_report_bug(__FILE__, __LINE__, 'User account ' . $userid . ' not found.');
569 // Load all data and add points
570 $content = getUserDataArray();
572 // Unlock his account (but only when it is on UNCONFIRMED!)
573 SQL_QUERY_ESC("UPDATE
574 `{?_MYSQL_PREFIX?}_user_data`
576 `status`='CONFIRMED',
577 `ref_payout`={?ref_payout?},
581 `status`='UNCONFIRMED'
583 array($hash), __FILE__, __LINE__);
586 if (SQL_AFFECTEDROWS() == 1) {
587 // Send email if updated
588 $message = loadEmailTemplate('confirm-member', $content, bigintval($userid));
590 // And send him right away the confirmation mail
591 sendEmail($email, '{--GUEST_THANX_CONFIRM--}', $message);
593 // Maybe he got "referaled"?
594 if (($refid > 0) && ($refid != $userid)) {
595 // Select the referal userid
596 if (fetchUserData($refid)) {
597 // Update ref counter...
598 updateReferalCounter($refid);
600 // If version matches add ref bonus to refid's account
601 if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (isBonusRallyeActive())) {
602 // Add points (directly only!)
603 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_ref`=`bonus_ref`+{?bonus_ref?} WHERE `userid`=%s LIMIT 1",
604 array(bigintval($refid)), __FILE__, __LINE__);
606 // Subtract points from system
607 handleBonusPoints(getConfig('bonus_ref'));
610 // Add one-time referal bonus over referal system or directly
611 // @TODO Try to rewrite the following unset()
612 unset($GLOBALS['ref_level']);
613 addPointsThroughReferalSystem('referal_bonus', $refid, getPointsRef(), true, bigintval($userid), getConfig('reg_points_mode'));
617 if (isExtensionActive('rallye')) {
618 // Add user to rallye (or not?)
619 addUserToReferalRallye(bigintval($userid));
622 // Account confirmed!
623 if (isExtensionActive('lead')) {
624 // Set special lead cookie
625 setSession('lead_userid', bigintval($userid));
627 // Lead-Code mode enabled
628 redirectToUrl('lead-confirm.php');
630 $content['message'] = '{--GUEST_CONFIRMED_DONE--}';
631 $content['userid'] = bigintval($userid);
633 } elseif (isExtensionActive('lead')) {
634 // Set special lead cookie
635 setSession('lead_userid', bigintval($userid));
637 // Lead-Code mode enabled
638 redirectToUrl('lead-confirm.php');
640 // Nobody was found unter this hash key... or our new member want's to confirm twice?
641 $content['message'] = '{--GUEST_CONFIRMED_TWICE--}';
644 // Nobody was found unter this hash key... or our new member want's to confirm twice?
645 $content['message'] = '{--GUEST_CONFIRMED_TWICE--}';
649 loadTemplate('admin_settings_saved', false, $content['message']);
652 // Does resend the user's confirmation link for given email address
653 function doResendUserConfirmationLink ($email) {
654 // Confirmation link requested
655 if (fetchUserData($email, 'email')) {
656 // Email address found
657 $content = getUserDataArray();
660 switch ($content['status']) {
661 case 'UNCONFIRMED': // Account not confirmed
662 // Load email template
663 $message = loadEmailTemplate('guest_request_confirm', array('hash' => $content['user_hash']), $content['userid']);
666 sendEmail($email, '{--REQUEST_CONFIRM_LINK_SUBJECT--}', $message);
669 $content['message'] = '{--CONFIRM_LINK_SENT--}';
672 case 'CONFIRMED': // Account already confirmed
673 $content['message'] = '{--LOGIN_ID_CONFIRMED--}';
676 case 'LOCKED': // Account is locked
677 $content['message'] = '{--LOGIN_ID_LOCKED--}';
681 // Email address not registered
682 $content['message'] = '{--EMAIL_404--}';
686 // Expression call-back function for fetching user data
687 function doExpressionUser ($data) {
688 // Use current userid by default
689 $functionName = 'getMemberId()';
691 // User-related data, so is there a userid?
692 if (!empty($data['matches'][4][$data['key']])) {
693 // Do we have a userid or $userid?
694 if ($data['matches'][4][$data['key']] == '$userid') {
696 $functionName = "getFetchedUserData('userid', \$userid, '" . $data['callback'] . "')";
697 } elseif (!empty($data['matches'][4][$data['key']])) {
699 $functionName = "getFetchedUserData('userid', " . $data['matches'][4][$data['key']] . ", '" . $data['callback'] . "')";
701 } elseif ((!empty($data['callback'])) && (isUserDataValid())) {
702 // "Call-back" alias column for current logged in user's data
703 $functionName = "getUserData('" . $data['callback'] . "')";
706 // Do we have another function to run (e.g. translations)
707 if (!empty($data['extra_func'])) {
708 // Surround the original function call with it
709 $functionName = $data['extra_func'] . '(' . $functionName . ')';
713 $replacer = '{DQUOTE} . ' . $functionName . ' . {DQUOTE}';
715 // Now replace the code
716 $code = replaceExpressionCode($data, $replacer);
718 // Return replaced code