<?php

/**
 * mavatars for Cotonti CMF
 *
 * @version 1.00
 * @author	esclkm
 * @copyright (c) 2013 esclkm
 */
defined('COT_CODE') or die('Wrong URL');

$ext = cot_import('ext', 'G', 'TXT');
$cat = cot_import('cat', 'G', 'TXT');
$code = cot_import('code', 'G', 'TXT');
$lite = cot_import('lite', 'G', 'INT');

$mavatar = new mavatar($ext, $cat, $code, 'edit');

$array = $mavatar->ajax_upload();

if($lite) {
  $tarray = array(
    'result' => "error"
  );
  if($array['id'] > 0) {
    $tarray = array(
      'file_extension' => '.'.$array['fileext'],
      'file_id' => $array['id'],
      'file_name' => $array['fileorigname'],
      'file_path' => COT_ABSOLUTE_URL . $array['filepath'] . $array['filename'] . '.' .$array['fileext'],
      'result' => "success"
    );
  }
  $array = $tarray;
}

echo(json_encode($array));