function update_user_pref($name, $val) { global $prefs, $txp_user; if (empty($txp_user)) { return; } if (empty($prefs[$name]) or $prefs[$name] != $val) { $GLOBALS[$name] = $prefs[$name] = $val; return safe_upsert('txp_prefs_user', "val='" . doSlash($val) . "'", array("user='******'", "name='" . doSlash($name) . "'")); } return true; }
function update_lastmod() { safe_upsert("txp_prefs", "val = now()", "name = 'lastmod'"); }
function update_lastmod() { safe_upsert("txp_prefs", "val = now()", "name = 'lastmod'"); flushcachedir(true); }
function update_version($version) { safe_upsert('txp_hak_tinymce', "pref_value = '" . $version . "'", "pref_name = 'version'"); }
/** * Updates site's last modification date. * * When this action is performed, it will trigger a * 'site.update > {event}' callback event and pass * any record set that triggered the update, along * with the exact time the update was triggered. * * @param $trigger Textpattern event or step that triggered the update * @param $rs Record set data at the time of update * @package Pref * @example * update_lastmod(); */ function update_lastmod($trigger = '', $rs = array()) { $whenStamp = time(); $whenDate = strftime('%Y-%m-%d %H:%M:%S', $whenStamp); safe_upsert("txp_prefs", "val = '{$whenDate}'", "name = 'lastmod'"); callback_event('site.update', $trigger, 0, $rs, compact('whenStamp', 'whenDate')); }
/** * Installs the element. * @return true if installation was carried out with no errors, else a string giving the reason why the install failed. **/ public static function install($element, $blobbed_element, $name) { $name = doSlash($name); $page = doSlash($element); safe_upsert('txp_page', "`user_html`='{$page}'", "`name`='{$name}'"); # TODO add error reporting return true; }
function sed_cleaner_setpref_action($args, $debug) { $key = doSlash(array_shift($args)); $args = join(' ', $args); $args = doSlash(trim($args, '" ')); safe_upsert('txp_prefs', "`val`='{$args}'", "`name`='{$key}'", $debug); }
/** Run the query. * Runs an UPDATE query if $where is set, otherwise INSERT * @return bool success or failure */ public function upsert() { $this->init_query(); if (count($this->where)) { return safe_upsert($this->table, $this->set_clause, $this->clause_string()); } if ($this->set_clause) { return safe_insert($this->table, $this->set_clause); } if ($this->values_clause) { return safe_query('insert into ' . safe_pfx($this->table) . $this->values_clause); } }
function _get_end_year($end_year, &$extra) { global $prefs; $result = ''; if (!empty($end_year)) { 'now' === $end_year ? $result = date('Y') : ($result = $end_year); $extra = '(from Tag Attr)'; } else { if (array_key_exists('sed_last_mod_year', $prefs) && !empty($prefs['sed_last_mod_year'])) { $result = $prefs['sed_last_mod_year']; $extra = '(end from cache)'; } else { if ($prefs['comment_means_site_updated']) { # Cannot rely of the $prefs['lastmod'] as even others' comments are updating that so pull from the DB instead... $last_mod = safe_field('lastmod', 'textpattern', SED_LAST_MOD_QUERY); if (!empty($last_mod)) { # Trim the date down to get the year... $result = substr($last_mod, 0, 4); $extra = '(end from Article Table)'; # Now store the result (we need to create the extra field to do this.) $rs = @safe_upsert('txp_prefs', "val='{$result}', prefs_id='1'", "name='sed_last_mod_year'"); } } else { # lastmod is tracking articles so pull it from the lastmod field of the $prefs... $result = substr($prefs['lastmod'], 0, 4); $extra = '(end from Global Prefs)'; } } } # sanity check the resulting date... if (!empty($result)) { $this_year = date('Y'); if ($result > $this_year) { $result = $this_year; } } return $result; }