本文整理汇总了PHP中SPRequest::string方法的典型用法代码示例。如果您正苦于以下问题:PHP SPRequest::string方法的具体用法?PHP SPRequest::string怎么用?PHP SPRequest::string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPRequest
的用法示例。
在下文中一共展示了SPRequest::string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
protected function save()
{
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
$id = SPRequest::cmd('filter_id');
if ($id) {
$this->validate('field.filter', 'filter');
$filters = $this->getFilters();
$name = SPRequest::string('filter_name', 'Filter Name');
$msg = str_replace(array("\n", "\t", "\r"), null, SPLang::clean(SPRequest::string('filter_message', 'The data entered in the $field field contains not allowed characters')));
$regex = SPLang::clean(SPRequest::raw('filter_regex', '/^[\\.*]+$/'));
$regex = str_replace('[:apostrophes:]', '\\"' . "\\'", $regex);
$regex = base64_encode(str_replace(array("\n", "\t", "\r"), null, $regex));
$custom = 'custom';
if (isset($filters[$id]) && !strlen($filters[$id]['options'])) {
$regex = $filters[$id]['params'];
$custom = null;
}
$filters[$id] = array('params' => $regex, 'key' => $id, 'value' => $name, 'description' => $msg, 'options' => $custom);
SPFactory::registry()->saveDBSection($filters, 'fields_filter');
$this->response(Sobi::Url('filter'), Sobi::Txt('FLR.MSG_FILTER_SAVED'), false, 'success');
} else {
$this->response(Sobi::Url('filter'), SPLang::e('FILTER_NOT_FOUND'), true, SPC::ERROR_MSG);
}
}
示例2: search
protected function search()
{
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
// $selected = SPRequest::int( 'selected', 0 );
$ssid = SPRequest::base64('ssid');
$query = SPRequest::string('q', null);
$session = SPFactory::user()->getUserState('userSelector', null, array());
$setting = $session[$ssid];
/* get the site to display */
$site = SPRequest::int('site', 1);
$eLim = Sobi::Cfg('user_selector.entries_limit', 18);
$eLimStart = ($site - 1) * $eLim;
$params = array();
if ($query) {
$q = '%' . $query . '%';
$params = SPFactory::db()->where(array('name' => $q, 'username' => $q, 'email' => $q), 'OR');
}
try {
$count = SPFactory::db()->select('COUNT(*)', '#__users', $params, $setting['ordering'])->loadResult();
$data = SPFactory::db()->select(array('id', 'name', 'username', 'email', 'registerDate', 'lastvisitDate'), '#__users', $params, $setting['ordering'], $eLim, $eLimStart)->loadAssocList();
} catch (SPException $x) {
echo $x->getMessage();
exit;
}
$response = array('sites' => ceil($count / $eLim), 'site' => $site);
if (count($data)) {
$replacements = array();
preg_match_all('/\\%[a-z]*/', $setting['format'], $replacements);
$placeholders = array();
if (isset($replacements[0]) && count($replacements[0])) {
foreach ($replacements[0] as $placeholder) {
$placeholders[] = str_replace('%', null, $placeholder);
}
}
if (count($replacements)) {
foreach ($data as $index => $user) {
$txt = $setting['format'];
foreach ($placeholders as $attribute) {
if (isset($user[$attribute])) {
$txt = str_replace('%' . $attribute, $user[$attribute], $txt);
}
}
$data[$index]['text'] = $txt;
}
}
$response['users'] = $data;
}
SPFactory::mainframe()->cleanBuffer();
echo json_encode($response);
exit;
}
示例3: save
protected function save()
{
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
$data = SPRequest::string('bankdata', null, true);
$data = array('key' => 'bankdata', 'value' => $data, 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section());
try {
SPLang::saveValues($data);
} catch (SPException $x) {
$message = SPLang::e('DB_REPORTS_ERR', $x->getMessage());
Sobi::Error('SPPaymentBt', $message, SPC::WARNING, 0, __LINE__, __FILE__);
$this->response(Sobi::Back(), $message, false, 'error');
}
$this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'), false, 'success');
}
示例4: save
protected function save()
{
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
$this->validate('extensions.paypal', array('task' => 'paypal', 'pid' => Sobi::Section()));
SPFactory::registry()->saveDBSection(array(array('key' => 'ppurl', 'value' => SPRequest::string('ppurl')), array('key' => 'ppemail', 'value' => SPRequest::string('ppemail')), array('key' => 'ppcc', 'value' => SPRequest::string('ppcc')), array('key' => 'pprurl', 'value' => SPRequest::string('pprurl'))), 'paypal_' . Sobi::Section());
$data = array('key' => 'ppexpl', 'value' => SPRequest::string('ppexpl', null, true), 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section());
try {
SPLang::saveValues($data);
$data['key'] = 'ppsubject';
$data['value'] = SPRequest::string('ppsubject', true);
SPLang::saveValues($data);
} catch (SPException $x) {
$message = SPLang::e('DB_REPORTS_ERR', $x->getMessage());
Sobi::Error('SPPaymentBt', $message, SPC::WARNING, 0, __LINE__, __FILE__);
$this->response(Sobi::Back(), $message, false, 'error');
}
$this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'), false, 'success');
}
示例5: ProxyDependency
/**
* */
public function ProxyDependency()
{
$path = json_decode(Sobi::Clean(SPRequest::string('path')), true);
$values = $this->loadDependencyDefinition($path);
SPFactory::mainframe()->cleanBuffer()->customHeader();
exit(json_encode(array('options' => $values, 'path' => json_encode($path))));
}
示例6: webServer
private function webServer()
{
$server = SPRequest::string('SERVER_SOFTWARE', getenv('SERVER_SOFTWARE'), null, 'server');
// $server = 'Apache';
$server = preg_split('/[\\/ ]/', $server);
$soft = isset($server[0]) ? $server[0] : 'Unknown';
$ver = isset($server[1]) ? preg_replace('/[^0-9\\.]/i', null, $server[1]) : '0.0.0';
$ver = explode('.', $ver);
$sapi = function_exists('php_sapi_name') ? php_sapi_name() : 'Unknown';
if (strtolower($soft) != 'apache') {
echo $this->warning($this->txt('REQ.WS_WRONG_SOFTWARE', array('webserver' => SPRequest::string('SERVER_SOFTWARE', getenv('SERVER_SOFTWARE'), null, 'server'))), __FUNCTION__);
} else {
$minVer = array('major' => 2, 'minor' => 0, 'build' => 0);
$rVer = array('major' => 2, 'minor' => 2, 'build' => 0);
if (!(isset($ver[0]) && isset($ver[1]) && isset($ver[2])) || !($ver[0] && $ver[1])) {
echo $this->warning($this->txt('REQ.WS_NO_APACHE_VER', array('required' => implode('.', $minVer), 'sapi' => $sapi)), __FUNCTION__);
exit;
}
$ver = array('major' => $ver[0], 'minor' => $ver[1], 'build' => isset($ver[2]) ? $ver[2] : 0);
if (!$this->compareVersion($minVer, $ver)) {
echo $this->error($this->txt('REQ.WS_WRONG_VER', array('required' => implode('.', $minVer), 'installed' => implode('.', $ver), 'sapi' => $sapi)), __FUNCTION__);
} else {
echo $this->ok($this->txt('REQ.WS_VERSION_OK', array('installed' => implode('.', $ver), 'sapi' => $sapi)), __FUNCTION__);
}
}
}
示例7: fields
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;
}
}
示例8: save
/**
* (non-PHPdoc)
* @see Site/lib/models/SPDBObject#save()
*/
public function save($request = 'post')
{
$this->loadFields(Sobi::Section(), true);
// Thu, Feb 19, 2015 12:12:47 - it should be actually "beforeSave"
Sobi::Trigger($this->name(), 'Before' . ucfirst(__FUNCTION__), array($this->id));
/* save the base object data */
/* @var SPdb $db */
$db = SPFactory::db();
$db->transaction();
if (!$this->nid || SPRequest::task() == 'entry.clone') {
$this->nid = SPRequest::string($this->nameField, null, false, $request);
$this->nid = $this->createAlias();
$this->name = $this->nid;
}
if (Sobi::Cfg('entry.publish_limit', 0) && !defined('SOBI_ADM_PATH')) {
SPRequest::set('entry_createdTime', 0, $request);
SPRequest::set('entry_validSince', 0, $request);
SPRequest::set('entry_validUntil', 0, $request);
$this->validUntil = gmdate('Y-m-d H:i:s', time() + Sobi::Cfg('entry.publish_limit', 0) * 24 * 3600);
}
$preState = Sobi::Reg('object_previous_state');
parent::save($request);
$nameField = $this->nameField();
/* get the fields for this section */
foreach ($this->fields as $field) {
/* @var $field SPField */
try {
if ($field->enabled('form', $preState['new'])) {
$field->saveData($this, $request);
} else {
$field->finaliseSave($this, $request);
}
if ($field->get('id') == $nameField) {
/* get the entry name */
$this->name = $field->getRaw();
/* save the nid (name id) of the field where the entry name is saved */
$this->nameField = $field->get('nid');
}
} catch (SPException $x) {
if (SPRequest::task() != 'entry.clone') {
$db->rollback();
throw new SPException(SPLang::e('CANNOT_SAVE_FIELS_DATA', $x->getMessage()));
} else {
Sobi::Error($this->name(), SPLang::e('CANNOT_SAVE_FIELS_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
}
$values = array();
/* get categories */
$cats = Sobi::Reg('request_categories');
if (!count($cats)) {
$cats = SPRequest::arr('entry_parent', SPFactory::registry()->get('request_categories', array()), $request);
}
/* by default it should be comma separated string */
if (!count($cats)) {
$cats = SPRequest::string('entry_parent', null, $request);
if (strlen($cats) && strpos($cats, ',')) {
$cats = explode(',', $cats);
foreach ($cats as $i => $cat) {
$c = (int) trim($cat);
if ($c) {
$cats[$i] = $c;
} else {
unset($cats[$i]);
}
}
} elseif (strlen($cats)) {
$cats = array((int) $cats);
}
}
if (is_array($cats) && count($cats)) {
foreach ($cats as $i => $v) {
if (!$v) {
unset($cats[$i]);
}
}
}
if (is_array($cats) && count($cats)) {
/* get the ordering in these categories */
try {
$db->select('pid, MAX(position)', 'spdb_relations', array('pid' => $cats, 'oType' => 'entry'), null, 0, 0, false, 'pid');
$cPos = $db->loadAssocList('pid');
$currPos = $db->select(array('pid', 'position'), 'spdb_relations', array('id' => $this->id, 'oType' => 'entry'))->loadAssocList('pid');
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
/* set the right position */
foreach ($cats as $i => $cat) {
$copy = 0;
if (!$this->approved) {
$copy = isset($this->categories[$cats[$i]]) ? 0 : 1;
} else {
$db->delete('spdb_relations', array('id' => $this->id, 'oType' => 'entry'));
}
if (isset($currPos[$cat])) {
$pos = $currPos[$cat]['position'];
//.........这里部分代码省略.........
示例9: save
protected function save($apply, $clone = false)
{
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
$sets = array();
if (!$clone) {
$sid = SPRequest::sid() ? SPRequest::sid() : SPRequest::int('entry_id');
} else {
$sid = 0;
}
$apply = (int) $apply;
if (!$this->_model) {
$this->setModel(SPLoader::loadModel($this->_type));
}
$this->_model->init($sid);
$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, 'BeforeStoreEntry')) {
$customClass::BeforeStoreEntry($this->_model, $_POST);
}
}
$preState = array('approved' => $this->_model->get('approved'), 'state' => $this->_model->get('state'), 'new' => !$this->_model->get('id'));
SPFactory::registry()->set('object_previous_state', $preState);
$this->_model->getRequest($this->_type);
$this->authorise($this->_model->get('id') ? 'edit' : 'add');
try {
$this->_model->validate('post');
} catch (SPException $x) {
$back = Sobi::GetUserState('back_url', Sobi::Url(array('task' => 'entry.add', 'sid' => Sobi::Section())));
$data = $x->getData();
$this->response($back, $x->getMessage(), false, 'error', array('required' => $data['field']));
}
try {
$this->_model->save();
} catch (SPException $x) {
$back = Sobi::GetUserState('back_url', Sobi::Url(array('task' => 'entry.add', 'sid' => Sobi::Section())));
$this->response($back, $x->getMessage(), false, 'error');
}
$sid = $this->_model->get('id');
$sets['sid'] = $sid;
$sets['entry.nid'] = $this->_model->get('nid');
$sets['entry.id'] = $sid;
if ($customClass && method_exists($customClass, 'AfterStoreEntry')) {
$customClass::AfterStoreEntry($this->_model);
}
if (SPRequest::string('history-note') || $this->_task == 'saveWithRevision' || Sobi::Cfg('entry.versioningAdminBehaviour', 1)) {
$this->logChanges('save', SPRequest::string('history-note'));
}
if ($apply || $clone) {
if ($clone) {
$msg = Sobi::Txt('MSG.OBJ_CLONED', array('type' => Sobi::Txt($this->_model->get('oType'))));
$this->response(Sobi::Url(array('task' => $this->_type . '.edit', 'sid' => $sid)), $msg);
} else {
$msg = Sobi::Txt('MSG.OBJ_SAVED', array('type' => Sobi::Txt($this->_model->get('oType'))));
$this->response(Sobi::Url(array('task' => $this->_type . '.edit', 'sid' => $sid)), $msg, false, 'success', array('sets' => $sets));
}
} elseif ($this->_task == 'saveAndNew') {
$msg = Sobi::Txt('MSG.ALL_CHANGES_SAVED');
$sid = $this->_model->get('parent');
if (!$sid) {
$sid = Sobi::Section();
}
$this->response(Sobi::Url(array('task' => $this->_type . '.add', 'sid' => $sid)), $msg, true, 'success', array('sets' => $sets));
} else {
$this->response(Sobi::Back(), Sobi::Txt('MSG.OBJ_SAVED', array('type' => Sobi::Txt($this->_model->get('oType')))));
}
}
示例10: set
/**
* @param string $name - The name of the cookie.
* @param string $value - The value of the cookie
* @param int $expire - The time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch
* @param bool $httponly - When true the cookie will be made accessible only through the HTTP protocol.
* @param bool $secure - Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client
* @param string $path - The path on the server in which the cookie will be available on
* @param string $domain - The domain that the cookie is available
* @return bool
*/
public static function set($name, $value, $expire = 0, $httponly = false, $secure = false, $path = '/', $domain = null)
{
$name = self::prefix . $name;
$expire = $expire == 0 ? $expire : time() + $expire;
return SPFactory::mainframe()->setCookie($name, $value, $expire, $httponly, $secure, $path, $domain) && SPRequest::string($name, null, false, 'cookie');
}
示例11: addView
/**
* @param $xml DOMDocument
* @param $template string
* @param array $data
* @return bool
*/
public function addView($xml, $template, $data = array())
{
if (!Sobi::Cfg('cache.xml_enabled') || $this->_cachedView || Sobi::Reg('break_cache_view') || Sobi::My('id') && Sobi::Cfg('cache.xml_no_reg')) {
return false;
}
if (!in_array(SPRequest::task('get'), $this->_disableViewCache)) {
foreach ($this->_disableObjectCache as $task) {
if (strstr(SPRequest::task(), $task)) {
return false;
}
}
if (count($_REQUEST)) {
foreach ($_REQUEST as $k => $v) {
if (!isset($this->requestStore[$k])) {
$data['request'][$k] = SPRequest::string($k);
}
}
}
$data['pathway'] = SPFactory::mainframe()->getPathway();
$this->view['xml'] = $xml;
$this->view['template'] = $template;
$this->view['data'] = $data;
}
}
示例12: save
/**
* Save a rule
*
* @param bool $apply
*/
protected function save($apply)
{
Sobi::Trigger('Save', 'Acl', array(&$this));
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
$rid = SPRequest::int('rid', 'null');
$this->validate('acl.edit', array('task' => 'acl.edit', 'rid' => $rid));
if ($rid) {
$this->remove($rid);
}
$vs = SPRequest::timestamp('set_validSince');
$vu = SPRequest::timestamp('set_validUntil');
$vs = $vs ? date(Sobi::Cfg('db.date_format', 'Y-m-d H:i:s'), $vs) : null;
$vu = $vu ? date(Sobi::Cfg('db.date_format', 'Y-m-d H:i:s'), $vu) : null;
$name = SPRequest::string('set_name');
$nid = SPRequest::cmd('set_nid');
$note = SPRequest::string('set_note');
$state = SPRequest::int('set_state', 1);
$gids = SPRequest::arr('set_groups');
$sids = SPRequest::arr('set_sections');
$pf = SPRequest::arr('set_permissions', array());
$pa = SPRequest::arr('set_adm_permissions', array());
// if can publish any, then can see any unpublished
if (in_array(20, $pf)) {
$pf[] = 14;
}
// if can publish own, then can see own unpublished
if (in_array(21, $pf)) {
$pf[] = 12;
}
if (in_array(19, $pf)) {
$pf[] = 15;
}
$perms = array_merge($pf, $pa);
/* @var SPdb $db */
$db = SPFactory::db();
/* update or insert the rule definition */
try {
$db->insertUpdate('spdb_permissions_rules', array('rid' => $rid, 'name' => $name, 'nid' => $nid, 'validSince' => $vs, 'validUntil' => $vu, 'note' => $note, 'state' => $state));
} catch (SPException $x) {
Sobi::Error('ACL', SPLang::e('CANNOT_CREATE_RULE_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
$rid = (int) $rid ? (int) $rid : $db->insertid();
/* insert the groups ids */
if (count($gids)) {
foreach ($gids as $i => $gid) {
$gids[$i] = array('rid' => $rid, 'gid' => $gid);
}
try {
$db->insertArray('spdb_permissions_groups', $gids);
} catch (SPException $x) {
Sobi::Error('ACL', SPLang::e('CANNOT_INSERT_GROUPS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
try {
$db->select('*', 'spdb_permissions', array('site' => 'adm', 'value' => 'global'));
$admPermissions = $db->loadResultArray();
} catch (SPException $x) {
Sobi::Error('ACL', SPLang::e('CANNOT_GET_PERMISSIONS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
/* create permission and section map */
if (count($sids) && count($perms)) {
$map = array();
/* travel the sections */
foreach ($sids as $sid) {
foreach ($perms as $pid) {
if (in_array($pid, $admPermissions)) {
$map[] = array('rid' => $rid, 'sid' => 0, 'pid' => $pid);
} else {
$map[] = array('rid' => $rid, 'sid' => $sid, 'pid' => $pid);
}
}
}
try {
$db->insertArray('spdb_permissions_map', $map, true);
} catch (SPException $x) {
Sobi::Error('ACL', SPLang::e('CANNOT_INSERT_GROUPS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
SPFactory::cache()->cleanAll();
/* trigger plugins */
Sobi::Trigger('AfterSave', 'Acl', array(&$this));
/* set redirect */
$this->response(Sobi::Url($apply ? array('task' => 'acl.edit', 'rid' => $rid) : 'acl'), Sobi::Txt('ACL_RULE_SAVED'), !$apply, SPC::SUCCESS_MSG, array('sets' => array('rid' => $rid)));
}
示例13: verify
/**
* @param SPEntry $entry
* @param string $request
* @throws SPException
* @return string
* @throw SPException
*/
private function verify($entry, $request)
{
$data = SPRequest::arr($this->nid, array(), $request);
if (!$data) {
$dataString = SPRequest::string($this->nid, null, false, $request);
if (strstr($dataString, '://')) {
$data = SPFactory::config()->structuralData($dataString);
} else {
$dataString = SPRequest::int($this->nid, 0, $request);
if ($dataString) {
$data = array($dataString);
}
}
} else {
if (count($data) > $this->catsMaxLimit && count($data) > 1) {
$data = array_slice($data, 0, $this->catsMaxLimit);
}
}
$dexs = count($data);
/* check if it was required */
if ($this->required && !$dexs && $this->method != 'fixed') {
throw new SPException(SPLang::e('FIELD_REQUIRED_ERR', $this->name));
}
/* check if there was an adminField */
if ($this->adminField && $dexs && $this->method != 'fixed') {
if (!Sobi::Can('entry.adm_fields.edit')) {
throw new SPException(SPLang::e('FIELD_NOT_AUTH', $this->name));
}
}
/* check if it was free */
if (!$this->isFree && $this->fee && $dexs) {
SPFactory::payment()->add($this->fee, $this->name, $entry->get('id'), $this->fid);
}
/* check if it was editLimit */
if ($this->editLimit == 0 && !Sobi::Can('entry.adm_fields.edit') && $dexs) {
throw new SPException(SPLang::e('FIELD_NOT_AUTH_EXP', $this->name));
}
/* check if it was editable */
if (!$this->editable && !Sobi::Can('entry.adm_fields.edit') && $dexs && $entry->get('version') > 1) {
throw new SPException(SPLang::e('FIELD_NOT_AUTH_NOT_ED', $this->name));
}
if (!$dexs) {
$data = array();
}
$this->setData($data);
return $data;
}
示例14: getBack
/**
* @return string
*/
public function getBack()
{
$r = Sobi::GetUserState('back_url', Sobi::Url());
if (!$r) {
$r = SPRequest::string('HTTP_REFERER', self::url(), false, 'SERVER');
}
return $r;
}
示例15: saveData
/**
* Gets the data for a field and save it in the database
* @param SPEntry $entry
* @param string $request
* @return bool
*/
public function saveData(&$entry, $request = 'POST')
{
if (!$this->enabled) {
return false;
}
$data = $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 */
/* @var SPdb $db */
$db =& SPFactory::db();
if ($this->allowHtml) {
/* filter data */
if (count($this->allowedAttributes)) {
SPRequest::setAttributesAllowed($this->allowedAttributes);
}
if (count($this->allowedTags)) {
SPRequest::setTagsAllowed($this->allowedTags);
}
$data = SPRequest::string($this->nid, null, $this->allowHtml, $request);
SPRequest::resetFilter();
if (!$this->editor && $this->maxLength && strlen($data) > $this->maxLength) {
$data = substr($data, 0, $this->maxLength);
}
} else {
$data = strip_tags($data);
}
/* collect the needed params */
$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['params'] = null;
$params['options'] = null;
$params['baseData'] = $data;
$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(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
/* if it wasn't edited in the default language, we have to try to insert it also for def lang */
if (Sobi::Lang() != Sobi::DefLang()) {
$params['lang'] = Sobi::DefLang();
try {
$db->insert('spdb_field_data', $params, true, true);
} catch (SPException $x) {
Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
}