HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers64/klimroosbudel.nl/wwwroot/kms/app/controllers/js_update_images_order.php
<?php

// Start the session
session_start();

$action = $_GET['action'];
switch($action) {
    case 'update-order':
        // What session do we need to update
        $sessionName = $_GET['sessionName'];

        // Get new order en put it into an array
        $order = explode(',', $_GET['order']);

        // Save old array to retrieve data from
        $oldArray = $_SESSION[$sessionName];

        // We need to check if thumb key is updated, get the current key
        $thumbKey = $_GET['thumbKey'];

        // Update the array with new values
        foreach ($order as $key => $oldArrayKey) {
            // Update session value
            $value = $oldArray[$oldArrayKey];
            $_SESSION[$sessionName][$key] = $value;

            // Update thumbnail
            if ($oldArrayKey == $thumbKey) {
                $newThumb = $key;
            }
        }

        // Set the updated thumb key
        $_SESSION[str_replace('_images', '', $sessionName)]['thumb'] = $newThumb;
        break;
}