<?php 
require("common_begin.php");

$authKey = $_POST['auth'];
$imageData = $_POST['imgdata'];
if (!isset($imageData))
{
  die("new image data not found");
}
else if (!isset($authKey) || $authKey != $_COOKIE[__LAUTH_KEY__])
{
  die("incorrect auth key");
}
  
$lst = Listopia::getInstance();

if ($lst->isLoggedIn())
{
  $userID = Session::getInstance()->gl_userid;
  
  if ($lst->isAdminUser() || $lst->isBannedUser($_POST['userid']))
    $userID = $_POST['userid'];
  
  $ok = $lst->setOrUpdateUserAvatar($userID, $imageData);
}

require("common_end.php");

