<?php
session_start();
require('../functions.php');
if(o_login_check($_SESSION['user'],$_SESSION['password'])) {
	$d = unserialize(file_get_contents('sb-service-conf.psr'));
	$services = array_keys($d);
	$order = json_decode($_POST['data'],true);
	$i = 0;
	foreach($services AS $service) {
		if(in_array($service,$order)) {
			$d[$service]['index'] = array_search($service,$order);
		}
		else {
			$d[$service]['index'] = count($order) + $i;
			$i++;
		}
	}
	file_put_contents('sb-service-conf.psr',serialize($d));
} else echo 'Could not update order. Wrong credentials.';
?>