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;
}