Exemplo n.º 1
0
 public function install()
 {
     $id = $this->xGetString('id');
     $name = $this->xGetString('name');
     if (SPLoader::dirPath('usr.templates.' . $id) && !SPRequest::bool('force')) {
         throw new SPException(SPLang::e('TEMPLATE_INST_DUPLICATE', $name) . ' ' . Sobi::Txt('FORCE_TPL_UPDATE', Sobi::Url(array('task' => 'extensions.install', 'force' => 1, 'root' => basename($this->root) . '/' . basename($this->xmlFile)))));
     }
     $requirements = $this->xGetChilds('requirements/*');
     if ($requirements && $requirements instanceof DOMNodeList) {
         SPFactory::Instance('services.installers.requirements')->check($requirements);
     }
     $language = $this->xGetChilds('language/file');
     $folder = @$this->xGetChilds('language/@folder')->item(0)->nodeValue;
     if ($language && $language instanceof DOMNodeList && $language->length) {
         $langFiles = array();
         foreach ($language as $file) {
             $adm = false;
             if ($file->attributes->getNamedItem('admin')) {
                 $adm = $file->attributes->getNamedItem('admin')->nodeValue == 'true' ? true : false;
             }
             $langFiles[$file->attributes->getNamedItem('lang')->nodeValue][] = array('path' => Sobi::FixPath("{$this->root}/{$folder}/" . trim($file->nodeValue)), 'name' => $file->nodeValue, 'adm' => $adm);
         }
         SPFactory::CmsHelper()->installLang($langFiles, false, true);
     }
     $path = SPLoader::dirPath('usr.templates.' . $id, 'front', false);
     if (SPRequest::bool('force')) {
         /** @var $from SPDirectory */
         $from = SPFactory::Instance('base.fs.directory', $this->root);
         $from->moveFiles($path);
     } else {
         if (!SPFs::move($this->root, $path)) {
             throw new SPException(SPLang::e('CANNOT_MOVE_DIRECTORY', $this->root, $path));
         }
     }
     if (!SPRequest::bool('force')) {
         $section = $this->xGetChilds('install');
         if ($section instanceof DOMNodeList && $section->length) {
             $this->section($id);
         }
     }
     //05 Oct 2015 Kishore
     $exec = $this->xGetString('exec');
     if ($exec && SPFs::exists($path . DS . $exec)) {
         include_once "{$path}/{$exec}";
     }
     /** @var $dir SPDirectory */
     $dir =& SPFactory::Instance('base.fs.directory', $path);
     $zip = array_keys($dir->searchFile('.zip', false));
     if (count($zip)) {
         foreach ($zip as $file) {
             SPFs::delete($file);
         }
     }
     Sobi::Trigger('After', 'InstallTemplate', array($id));
     $dir =& SPFactory::Instance('base.fs.directory', SPLoader::dirPath('tmp.install'));
     $dir->deleteFiles();
     return Sobi::Txt('TP.TEMPLATE_HAS_BEEN_INSTALLED', array('template' => $name));
 }
Exemplo n.º 2
0
 public function execute()
 {
     $this->start = microtime(true);
     $sites = $this->getSites();
     $responses = array();
     $status = 'working';
     $message = null;
     $this->format = SPRequest::bool('fullFormat') ? self::FORMAT_FULL : self::FORMAT;
     //		$this->format = SPRequest::bool( 'fullFormat' ) ? self::FORMAT_FULL : self::FORMAT_FULL;
     $task = SPRequest::task();
     if (in_array($task, array('crawler.init', 'crawler.restart'))) {
         if ($task == 'crawler.restart') {
             SPFactory::cache()->cleanSection(Sobi::Section());
         }
         SPFactory::db()->truncate(self::DB_TABLE);
         $multiLang = Sobi::Cfg('lang.multimode', false);
         if ($multiLang) {
             $langs = SPFactory::CmsHelper()->getLanguages();
             if ($multiLang && $langs) {
                 foreach ($langs as $lang) {
                     $responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section() . '&lang=' . $lang);
                 }
             }
         }
         $responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section());
         $sites = $this->getSites();
     }
     if (!count($sites) && !in_array($task, array('crawler.init', 'crawler.restart'))) {
         $message = Sobi::Txt('CRAWL_URL_PARSED_DONE', SPFactory::db()->select('count(*)', self::DB_TABLE)->loadResult());
         SPFactory::db()->truncate(self::DB_TABLE);
         $this->response(array('status' => 'done', 'data' => array(), 'message' => $message));
     }
     if (count($sites)) {
         $i = 0;
         $timeLimit = SPRequest::int('timeLimit', self::TIME_LIMIT, 'get', true);
         foreach ($sites as $site) {
             if (!strlen($site)) {
                 continue;
             }
             $responses[] = $this->getResponse($site);
             $i++;
             if (microtime(true) - $this->start > $timeLimit) {
                 break;
             }
         }
         $message = Sobi::Txt('CRAWL_URL_PARSED_WORKING', $i, count($sites));
     }
     $this->response(array('status' => $status, 'data' => $responses, 'message' => $message));
 }
Exemplo n.º 3
0
 public function install()
 {
     $id = $this->xGetString('id');
     $name = $this->xGetString('name');
     if (SPLoader::dirPath('usr.templates.' . $id) && !SPRequest::bool('force')) {
         throw new SPException(SPLang::e('TEMPLATE_INST_DUPLICATE', $name) . ' ' . Sobi::Txt('FORCE_TPL_UPDATE', Sobi::Url(array('task' => 'extensions.install', 'force' => 1, 'root' => basename($this->root) . '/' . basename($this->xmlFile)))));
     }
     $requirements = $this->xGetChilds('requirements/*');
     if ($requirements && $requirements instanceof DOMNodeList) {
         SPFactory::Instance('services.installers.requirements')->check($requirements);
     }
     $path = SPLoader::dirPath('usr.templates.' . $id, 'front', false);
     if (SPRequest::bool('force')) {
         /** @var $from SPDirectory */
         $from = SPFactory::Instance('base.fs.directory', $this->root);
         $from->moveFiles($path);
     } else {
         if (!SPFs::move($this->root, $path)) {
             throw new SPException(SPLang::e('CANNOT_MOVE_DIRECTORY', $this->root, $path));
         }
     }
     if (!SPRequest::bool('force')) {
         $section = $this->xGetChilds('install');
         if ($section instanceof DOMNodeList && $section->length) {
             $this->section($id);
         }
     }
     $exec = $this->xGetString('exec');
     if ($exec && SPFs::exists($this->root . DS . $exec)) {
         include_once "{$this->root}/{$exec}";
     }
     /** @var $dir SPDirectory */
     $dir =& SPFactory::Instance('base.fs.directory', $path);
     $zip = array_keys($dir->searchFile('.zip', false));
     if (count($zip)) {
         foreach ($zip as $file) {
             SPFs::delete($file);
         }
     }
     Sobi::Trigger('After', 'InstallTemplate', array($id));
     $dir =& SPFactory::Instance('base.fs.directory', SPLoader::dirPath('tmp.install'));
     $dir->deleteFiles();
     return Sobi::Txt('TP.TEMPLATE_HAS_BEEN_INSTALLED', array('template' => $name));
 }
Exemplo n.º 4
0
 /**
  * Gets the data for a field and save it in the database
  * @param SPEntry $entry
  * @param string $request
  * @param bool $clone
  * @throws SPException
  * @return bool
  */
 public function saveData(&$entry, $request = 'POST', $clone = false)
 {
     if (!$this->enabled) {
         return false;
     }
     $del = SPRequest::bool($this->nid . '_delete', false, $request);
     if ($clone) {
         $orgSid = SPRequest::sid();
         $this->loadData($orgSid);
         $files = $this->getExistingFiles();
         $cloneFiles = array();
         if (isset($files['original']) && file_exists(SOBI_ROOT . '/' . $files['original'])) {
             return $this->cloneFiles($entry, $request, $files, $cloneFiles);
         }
     }
     $fileSize = SPRequest::file($this->nid, 'size');
     $cropped = null;
     static $store = null;
     $cache = false;
     if ($store == null) {
         $store = SPFactory::registry()->get('requestcache_stored');
     }
     if (is_array($store) && isset($store[$this->nid])) {
         if (!strstr($store[$this->nid], 'file://') && !strstr($store[$this->nid], 'directory://')) {
             $data = $store[$this->nid];
             $cache = true;
             $orgName = SPRequest::file($this->nid, 'name', $request);
         } else {
             SPRequest::set($this->nid, $store[$this->nid]);
             $orgName = SPRequest::file($this->nid, 'name');
             $data = SPRequest::file($this->nid, 'tmp_name');
         }
     } else {
         $data = SPRequest::file($this->nid, 'tmp_name');
         $orgName = SPRequest::file($this->nid, 'name');
     }
     $sPath = $this->parseName($entry, $orgName, $this->savePath);
     $path = SPLoader::dirPath($sPath, 'root', false);
     /** Wed, Oct 15, 2014 13:51:03
      * Implemented a cropper with Ajax checker.
      * This is the actual method to get those files
      * Other methods left for BC
      * */
     if (!$data) {
         $directory = SPRequest::string($this->nid, $store[$this->nid], false, $request);
         if (strlen($directory)) {
             list($data, $dirName, $files, $coordinates) = $this->getAjaxFiles($directory);
             if (count($files)) {
                 foreach ($files as $file) {
                     if ($file == '.') {
                         continue;
                     }
                     if ($file == '..') {
                         continue;
                     }
                     if (strpos($file, 'icon_') !== false) {
                         continue;
                     }
                     if (strpos($file, 'resized_') !== false) {
                         continue;
                     }
                     if (strpos($file, 'cropped_') !== false) {
                         $cropped = $dirName . $file;
                         SPFs::upload($cropped, $path . basename($cropped));
                         continue;
                     }
                     if (strpos($file, '.var') !== false) {
                         continue;
                     }
                     $fileSize = filesize($dirName . $file);
                     $orgName = $file;
                 }
             }
             if (strlen($coordinates)) {
                 $coordinates = json_decode(SPLang::clean($coordinates), true);
                 /** @var SPImage $croppedImage */
                 $croppedImage = SPFactory::Instance('base.fs.image', $dirName . $orgName);
                 $croppedImage->crop($coordinates['width'], $coordinates['height'], $coordinates['x'], $coordinates['y']);
                 $cropped = 'cropped_' . $orgName;
                 $croppedImage->saveAs($path . $cropped);
             }
             $data = strlen($cropped) ? $cropped : $dirName . $file;
         }
     }
     $files = array();
     /* if we have an image */
     if ($data && $orgName) {
         if ($fileSize > $this->maxSize) {
             throw new SPException(SPLang::e('FIELD_IMG_TOO_LARGE', $this->name, $fileSize, $this->maxSize));
         }
         if ($cropped) {
             SPFs::upload($dirName . $orgName, $path . $orgName);
         }
         /**
          * @var SPImage $orgImage
          */
         if ($cache) {
             $orgImage = SPFactory::Instance('base.fs.image', $data);
             $orgImage->move($path . $orgName);
         } else {
             $orgImage = SPFactory::Instance('base.fs.image');
             $nameArray = explode('.', $orgName);
             $ext = strtolower(array_pop($nameArray));
             $nameArray[] = $ext;
             $orgName = implode('.', $nameArray);
             if ($cropped) {
                 // Fri, Jul 3, 2015 17:15:05
                 // it has been actually uploaded at ~425
                 // not sure why we are trying to upload it again
                 if (SPFs::exists($dirName . $data)) {
                     $orgImage->upload($dirName . $data, $path . basename($data));
                 } else {
                     $orgImage->setFile($path . basename($data));
                 }
             } else {
                 $orgImage->upload($dirName . $orgName, $path . $orgName);
             }
         }
         $files['data']['exif'] = $orgImage->exif();
         $this->cleanExif($files['data']['exif']);
         if (Sobi::Cfg('image_field.fix_rotation', true)) {
             if ($orgImage->fixRotation()) {
                 $orgImage->save();
             }
         }
         if ($this->resize) {
             $image = clone $orgImage;
             try {
                 $image->resample($this->resizeWidth, $this->resizeHeight, false);
                 $files['image'] = $this->parseName($entry, $orgName, $this->imageName, true);
                 $image->saveAs($path . $files['image']);
             } catch (SPException $x) {
                 Sobi::Error($this->name(), SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
                 $image->delete();
                 throw new SPException(SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()));
             }
         }
         if ($this->generateThumb) {
             $thumb = clone $orgImage;
             try {
                 $thumb->resample($this->thumbWidth, $this->thumbHeight, false);
                 $files['thumb'] = $this->parseName($entry, $orgName, $this->thumbName, true);
                 $thumb->saveAs($path . $files['thumb']);
             } catch (SPException $x) {
                 Sobi::Error($this->name(), SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
                 $thumb->delete();
                 throw new SPException(SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()));
             }
         }
         $ico = clone $orgImage;
         try {
             $icoSize = explode(':', Sobi::Cfg('image.ico_size', '80:80'));
             $ico->resample($icoSize[0], $icoSize[1], false);
             $files['ico'] = $this->parseName($entry, strtolower($orgName), 'ico_{orgname}_' . $this->nid, true);
             $ico->saveAs($path . $files['ico']);
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
             $ico->delete();
             throw new SPException(SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()));
         }
         if (!$this->keepOrg) {
             $orgImage->delete();
         } else {
             $files['original'] = $this->parseName($entry, $orgName, '{orgname}', true);
         }
         foreach ($files as $i => $file) {
             if ($i == 'data') {
                 continue;
             }
             $files[$i] = $sPath . $file;
         }
     } elseif ($del) {
         $this->delImgs();
         $files = array();
     } else {
         return true;
     }
     $this->storeData($entry, $request, $files);
 }
Exemplo n.º 5
0
 public static function fields($sid = 0, $types = null)
 {
     if (!$sid) {
         $sid = SPRequest::sid('request', Sobi::Section(), false);
     }
     if (!$types) {
         $types = SPRequest::string('types', null);
         $types = SPFactory::config()->structuralData($types, true);
     }
     $fields = SPConfig::fields($sid, $types);
     if (SPRequest::bool('fields-xhr')) {
         SPFactory::mainframe()->cleanBuffer()->customHeader();
         exit(json_encode($fields));
     } else {
         return $fields;
     }
 }
Exemplo n.º 6
0
 protected function reject()
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     if ($this->authorise('manage')) {
         $changes = array();
         $objects = array('entry' => $this->_model, 'user' => SPFactory::user(), 'author' => SPFactory::Instance('cms.base.user', $this->_model->get('owner')));
         $messages =& SPFactory::registry()->get('messages');
         $reason = SPLang::replacePlaceHolders(SPRequest::string('reason', null, true, 'post'), $objects);
         $objects['reason'] = nl2br($reason);
         $messages['rejection'] = $objects;
         SPFactory::registry()->set('messages', $messages);
         $this->_model->setMessage($reason, 'reason');
         if (SPRequest::bool('unpublish', false, 'post')) {
             $this->_model->changeState(0, $reason, false);
             $changes[] = 'unpublish';
         }
         if (SPRequest::bool('trigger_unpublish', false, 'post')) {
             Sobi::Trigger('Entry', 'AfterChangeState', array($this->_model, 0, 'messages' => $this->_model->get('messages')));
         }
         if (SPRequest::bool('discard', false, 'post')) {
             $changes[] = 'discard';
             $data = $this->_model->discard(false);
         }
         if (SPRequest::bool('trigger_unapprove', false, 'post')) {
             Sobi::Trigger('Entry', 'AfterUnapprove', array($this->_model, 0));
         }
         Sobi::Trigger('Entry', 'AfterReject', array($this->_model, 0));
         SPFactory::message()->logAction('reject', $this->_model->get('id'), $data, $reason);
         $this->response(Sobi::Back(), Sobi::Txt('ENTRY_REJECTED', $this->_model->get('name')), true, SPC::SUCCESS_MSG);
     }
 }
Exemplo n.º 7
0
 protected function template()
 {
     /* determine template file */
     $template = SPRequest::cmd('sptpl', $this->_task);
     if (strstr($template, '.')) {
         $template = explode('.', $template);
         $this->templateType = $template[0];
         $this->template = $template[1];
     } else {
         $this->templateType = $this->_type;
         $this->template = $template ? $template : $this->_task;
     }
     if (strlen($template && $template != $this->_task) && !SPRequest::bool('xmlc')) {
         $template = "/{$this->templateType}/{$this->template}.xsl";
         SPFactory::registry()->set('cache_view_template', $template);
     }
 }
Exemplo n.º 8
0
 /**
  * Executes the controller task
  * @return void
  */
 public function execute()
 {
     if (!$this->_cache) {
         try {
             if (is_array($this->_ctrl)) {
                 foreach ($this->_ctrl as &$c) {
                     $c->execute();
                 }
             } else {
                 if ($this->_ctrl instanceof SPControl) {
                     $this->_ctrl->execute();
                 } else {
                     Sobi::Error('CoreCtrl', SPLang::e('No controller to execute'), SPC::ERROR, 500, __LINE__, __FILE__);
                 }
             }
         } catch (SPException $x) {
             Sobi::Error('CoreCtrl', SPLang::e('%s', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
     } else {
         /** @var $view SPFrontView */
         $view = SPFactory::View('cache');
         $view->cachedView($this->_cache['xml'], $this->_cache['template'], $this->_cache['cid'], $this->_cache['config']);
         $view->display();
     }
     /* send header data etc ...*/
     if (SPRequest::cmd('format') == 'raw' && SPRequest::bool('xmlc')) {
         SPFactory::cache()->storeView(array());
     }
     SPFactory::mainframe()->endOut();
     Sobi::Trigger('End');
     /* redirect if any redirect has been set */
     SPFactory::mainframe()->redirect();
     ini_set('display_errors', $this->_err);
     error_reporting($this->_deb);
     restore_error_handler();
 }
Exemplo n.º 9
0
 /**
  * Gets the data for a field and save it in the database
  * @param SPEntry $entry
  * @param string $request
  * @throws SPException
  * @return bool
  */
 public function saveData(&$entry, $request = 'POST')
 {
     if (!$this->enabled) {
         return false;
     }
     $del = SPRequest::bool($this->nid . '_delete', false, $request);
     $fileSize = SPRequest::file($this->nid, 'size');
     $cropped = null;
     static $store = null;
     $cache = false;
     if ($store == null) {
         $store = SPFactory::registry()->get('requestcache_stored');
     }
     if (is_array($store) && isset($store[$this->nid])) {
         if (!strstr($store[$this->nid], 'file://') && !strstr($store[$this->nid], 'directory://')) {
             $data = $store[$this->nid];
             $cache = true;
             $orgName = SPRequest::file($this->nid, 'name', $request);
         } else {
             SPRequest::set($this->nid, $store[$this->nid]);
             $orgName = SPRequest::file($this->nid, 'name');
             $data = SPRequest::file($this->nid, 'tmp_name');
         }
     } else {
         $data = SPRequest::file($this->nid, 'tmp_name');
         $orgName = SPRequest::file($this->nid, 'name');
     }
     $sPath = $this->parseName($entry, $orgName, $this->savePath);
     $path = SPLoader::dirPath($sPath, 'root', false);
     /** Wed, Oct 15, 2014 13:51:03
      * Implemented a cropper with Ajax checker.
      * This is the actual method to get those files
      * Other methods left for BC
      * */
     if (!$data) {
         $directory = SPRequest::string($this->nid, $store[$this->nid], false, $request);
         if (strlen($directory)) {
             list($data, $dirName, $files, $coordinates) = $this->getAjaxFiles($directory);
             if (count($files)) {
                 foreach ($files as $file) {
                     if ($file == '.') {
                         continue;
                     }
                     if ($file == '..') {
                         continue;
                     }
                     if (strpos($file, 'icon_') !== false) {
                         continue;
                     }
                     if (strpos($file, 'resized_') !== false) {
                         continue;
                     }
                     if (strpos($file, 'cropped_') !== false) {
                         $cropped = $dirName . $file;
                         SPFs::upload($cropped, $path . basename($cropped));
                         continue;
                     }
                     if (strpos($file, '.var') !== false) {
                         continue;
                     }
                     $fileSize = filesize($dirName . $file);
                     $orgName = $file;
                 }
             }
             if (strlen($coordinates)) {
                 $coordinates = json_decode(SPLang::clean($coordinates), true);
                 /** @var SPImage $croppedImage */
                 $croppedImage = SPFactory::Instance('base.fs.image', $dirName . $orgName);
                 $croppedImage->crop($coordinates['width'], $coordinates['height'], $coordinates['x'], $coordinates['y']);
                 $cropped = 'cropped_' . $orgName;
                 $croppedImage->saveAs($path . $cropped);
             }
             $data = strlen($cropped) ? $cropped : $dirName . $file;
         }
     }
     $files = array();
     /* if we have an image */
     if ($data && $orgName) {
         if ($fileSize > $this->maxSize) {
             throw new SPException(SPLang::e('FIELD_IMG_TOO_LARGE', $this->name, $fileSize, $this->maxSize));
         }
         if ($cropped) {
             SPFs::upload($dirName . $orgName, $path . $orgName);
         }
         /**
          * @var SPImage $orgImage
          */
         if ($cache) {
             $orgImage = SPFactory::Instance('base.fs.image', $data);
             $orgImage->move($path . $orgName);
         } else {
             $orgImage = SPFactory::Instance('base.fs.image');
             $nameArray = explode('.', $orgName);
             $ext = strtolower(array_pop($nameArray));
             $nameArray[] = $ext;
             $orgName = implode('.', $nameArray);
             if ($cropped) {
                 $orgImage->upload($dirName . $data, $path . basename($data));
             } else {
                 $orgImage->upload($dirName . $orgName, $path . $orgName);
             }
         }
         $files['data']['exif'] = $orgImage->exif();
         $this->cleanExif($files['data']['exif']);
         if (Sobi::Cfg('image_field.fix_rotation', true)) {
             if ($orgImage->fixRotation()) {
                 $orgImage->save();
             }
         }
         if ($this->resize) {
             $image = clone $orgImage;
             try {
                 $image->resample($this->resizeWidth, $this->resizeHeight, false);
                 $files['image'] = $this->parseName($entry, $orgName, $this->imageName, true);
                 $image->saveAs($path . $files['image']);
             } catch (SPException $x) {
                 Sobi::Error($this->name(), SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
                 $image->delete();
                 throw new SPException(SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()));
             }
         }
         if ($this->generateThumb) {
             $thumb = clone $orgImage;
             try {
                 $thumb->resample($this->thumbWidth, $this->thumbHeight, false);
                 $files['thumb'] = $this->parseName($entry, $orgName, $this->thumbName, true);
                 $thumb->saveAs($path . $files['thumb']);
             } catch (SPException $x) {
                 Sobi::Error($this->name(), SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
                 $thumb->delete();
                 throw new SPException(SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()));
             }
         }
         $ico = clone $orgImage;
         try {
             $icoSize = explode(':', Sobi::Cfg('image.ico_size', '80:80'));
             $ico->resample($icoSize[0], $icoSize[1], false);
             $files['ico'] = $this->parseName($entry, strtolower($orgName), 'ico_{orgname}', true);
             $ico->saveAs($path . $files['ico']);
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
             $ico->delete();
             throw new SPException(SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()));
         }
         if (!$this->keepOrg) {
             $orgImage->delete();
         } else {
             $files['original'] = $this->parseName($entry, $orgName, '{orgname}', true);
         }
         foreach ($files as $i => $file) {
             if ($i == 'data') {
                 continue;
             }
             $files[$i] = $sPath . $file;
         }
     } elseif ($del) {
         $this->delImgs();
         $files = array();
     } else {
         return true;
     }
     /* @var SPdb $db */
     $db =& SPFactory::db();
     $this->verify($entry, $request);
     $time = SPRequest::now();
     $IP = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER');
     $uid = Sobi::My('id');
     /* if we are here, we can save these data */
     /* collect the needed params */
     $save = count($files) ? SPConfig::serialize($files) : null;
     $params = array();
     $params['publishUp'] = $entry->get('publishUp');
     $params['publishDown'] = $entry->get('publishDown');
     $params['fid'] = $this->fid;
     $params['sid'] = $entry->get('id');
     $params['section'] = Sobi::Reg('current_section');
     $params['lang'] = Sobi::Lang();
     $params['enabled'] = $entry->get('state');
     $params['baseData'] = $db->escape($save);
     $params['approved'] = $entry->get('approved');
     $params['confirmed'] = $entry->get('confirmed');
     /* if it is the first version, it is new entry */
     if ($entry->get('version') == 1) {
         $params['createdTime'] = $time;
         $params['createdBy'] = $uid;
         $params['createdIP'] = $IP;
     }
     $params['updatedTime'] = $time;
     $params['updatedBy'] = $uid;
     $params['updatedIP'] = $IP;
     $params['copy'] = !$entry->get('approved');
     if (Sobi::My('id') == $entry->get('owner')) {
         --$this->editLimit;
     }
     $params['editLimit'] = $this->editLimit;
     /* save it */
     try {
         $db->insertUpdate('spdb_field_data', $params);
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('CANNOT_SAVE_FIELDS_DATA_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
 }