public function ProxyCount() { SPLoader::loadClass('env.browser'); SPLoader::loadClass('env.cookie'); $browser = SPBrowser::getInstance(); $this->nid = str_replace(array('.count', '.'), array(null, '_'), SPRequest::task()); $ident = $this->nid . '_' . SPRequest::int('eid'); $check = SPRequest::cmd('count_' . $ident, null, 'cookie'); if (!$check) { $data = array('date' => 'FUNCTION:NOW()', 'uid' => Sobi::My('id'), 'sid' => SPRequest::int('eid'), 'fid' => $this->nid, 'ip' => SPRequest::ip('REMOTE_ADDR', 0, 'SERVER'), 'section' => Sobi::Section(), 'browserData' => $browser->get('browser'), 'osData' => $browser->get('system'), 'humanity' => $browser->get('humanity')); SPCookie::set('count_' . $ident, 1, SPCookie::hours(2)); SPFactory::db()->insert('spdb_field_url_clicks', $data); } }
/** * pre-save an entry */ protected function submit() { if (!SPFactory::mainframe()->checkToken()) { Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); } if (!$this->_model) { $this->setModel(SPLoader::loadModel($this->_type)); } else { if ($this->_model->get('oType') != 'entry') { Sobi::Error('Entry', sprintf('Serious security violation. Trying to save an object which claims to be an entry but it is a %s. Task was %s', $this->_model->get('oType'), SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); exit; } } $ajax = SPRequest::cmd('method', 'html') == 'xhr'; /** let's create a simple plug-in method from the template to allow to modify the request */ $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE); $this->tplCfg($tplPackage); $customClass = null; if (isset($this->_tCfg['general']['functions']) && $this->_tCfg['general']['functions']) { $customClass = SPLoader::loadClass('/' . str_replace('.php', null, $this->_tCfg['general']['functions']), false, 'templates'); if (method_exists($customClass, 'BeforeSubmitEntry')) { $customClass::BeforeSubmitEntry($this->_model); } } $sid = $this->_model->get('id'); $this->_model->init(SPRequest::sid()); $this->_model->getRequest($this->_type); Sobi::Trigger($this->name(), __FUNCTION__, array(&$this->_model)); if ($sid) { if (Sobi::My('id') && Sobi::My('id') == $this->_model->get('owner')) { $this->authorise('edit', 'own'); } else { $this->authorise('edit', '*'); } } else { $this->authorise('add', 'own'); } if (Sobi::Cfg('legacy.sigsiutree', false) && !SPRequest::int('entry_parent', 0)) { $this->response(Sobi::Back(), Sobi::Txt('CAT.SELECT_ONE'), true, SPC::ERROR_MSG); } $this->_model->loadFields(Sobi::Reg('current_section')); $fields = $this->_model->get('fields'); $tsId = SPRequest::string('editentry', null, false, 'cookie'); $tsIdToRequest = false; if (!strlen($tsId)) { // $tsId = date( 'Y-m-d_H-m-s_' ) . str_replace( array( '.', ':' ), array( '-', null ), SPRequest::ip( 'REMOTE_ADDR', 0, 'SERVER' ) ); $tsId = microtime(true) * 100 . '.' . rand(0, 99) . '.' . str_replace(array(':', '.'), null, SPRequest::ip('REMOTE_ADDR', 0, 'SERVER')); SPLoader::loadClass('env.cookie'); // in case we wre not able for some reason to set the cookie - we are going to pass this id into the URL if (!SPCookie::set('editentry', $tsId, SPCookie::hours(48))) { $tsIdToRequest = true; } } $store = array(); if (count($fields)) { foreach ($fields as $field) { $field->enabled('form'); try { $request = $field->submit($this->_model, $tsId); if (is_array($request) && count($request)) { $store = array_merge($store, $request); } } catch (SPException $x) { $this->response(Sobi::Back(), $x->getMessage(), !$ajax, SPC::ERROR_MSG, array('error' => $field->get('nid'))); } } } /* try in Sobi Cache first */ if (Sobi::Cfg('cache.l3_enabled', true)) { SPFactory::cache()->addVar(array('post' => $_POST, 'files' => $_FILES, 'store' => $store), 'request_cache_' . $tsId); } else { $file = str_replace('.', '-', $tsId); SPFs::write(SPLoader::path('tmp.edit.' . $file . '.post', 'front', false, 'var'), SPConfig::serialize($_POST)); SPFs::write(SPLoader::path('tmp.edit.' . $file . '.files', 'front', false, 'var'), SPConfig::serialize($_FILES)); SPFs::write(SPLoader::path('tmp.edit.' . $file . '.store', 'front', false, 'var'), SPConfig::serialize($store)); } if (!Sobi::Can('entry.payment.free') && SPFactory::payment()->count($this->_model->get('id'))) { $this->paymentView($tsId); } else { if ($customClass && method_exists($customClass, 'AfterSubmitEntry')) { $customClass::AfterSubmitEntry($this->_model); } $url = array('task' => 'entry.save', 'pid' => Sobi::Reg('current_section'), 'sid' => $sid); if ($tsIdToRequest) { $url['ssid'] = $tsId; } $this->response(Sobi::Url($url, false, false)); } }