CodeSOD: JaphpaScript

This post was originally published on this site

The Daily WTF

Let’s say you have a web application, and you need to transfer some data that exists in your backend, server-side, down to the front-end, client-side. If you’re a normal person, you have the client do an HTTP request and return the data in something like a JSON format.

You could certainly do that. Or, you could do what Alicia‘s predecessor did.

<script> var i; var j; var grpID; var group_Arr_<?php echo $varNamePrefix;?>= new Array(); var user_Arr_<?php echo $varNamePrefix;?>= new Array(); <?php $i = 0; if(is_array($groupArr)) { foreach($groupArr as $groupData) { $t_groupID = $groupData[0]; if(is_array($userArr[$t_groupID] ?? null)) { ?> i = ‘<?php echo $i; ?>’; grpID = ‘<?php echo $t_groupID; ?>’; group_Arr_<?php echo $varNamePrefix;?>[i] = ‘<?php echo $t_groupID; ?>’; user_Arr_<?php echo $varNamePrefix;?>[grpID] = new Array(); <?php for($j = 0,$jMax = count($userArr[$t_groupID]); $j < $jMax; $j++) { ?> j = ‘<?php echo $j; ?>’; user_Arr_<?php echo $varNamePrefix;?>[grpID][j] = ‘<?php echo $userArr[$t_groupID][$j][0]; ?>’;

To read the full article click on the 'post' link at the top.