<?php
/*******************************************************************************/
//                          InstantCMS v1.8                                    //
//                      http://www.instantcms.ru/                              //
//                         component "Poster"                                  //
//                       written by Marat Fatikhov                             //
//                      (nickname Марат on a site)                             //
//                       E-mail: f-marat@mail.ru                               //
//                                                                             //
//                      LICENSED BY GNU/GPL v2                                 //
//                                                                             //
/********************************************************************************/

header('Content-Type: text/html; charset=windows-1251');
session_start();

define("VALID_CMS", 1);
define('PATH', $_SERVER['DOCUMENT_ROOT']);

include(PATH.'/core/cms.php');

$inCore = cmsCore::getInstance();

$inCore->loadClass('db');
$inCore->loadClass('user');

$inDB   = cmsDatabase::getInstance();
$inUser = cmsUser::getInstance();

$inUser->update();

if (!$inUser->id) { die(); }

$item_id = $inCore->request('item_id', 'int', 0);
$photoname = $inCore->request('photoname', 'str', 0);


if(!$item_id || !$photoname){die();}


$table = '`cms_torg_items`'; 
$imageurl = $inDB->get_field($table, "id = '{$item_id}'", 'imageurl');

$inDB->query("UPDATE {$table}
              SET imageurl = '{$photoname}'
              WHERE id = '{$item_id}'");

echo $imageurl;

?>
