/** * validateSession() * * Returns true if a session has already been created in an * attempt to prevent abuse of the listener. */ function validateSession() { global $A; // Activity object global $name; $name = getName(); if (cookieVar(LACE_SESSION_COOKIE) === false && !$A->keyExists($name)) { joinMessage($name); } $A->update($name); setcookie(LACE_SESSION_COOKIE, getCookieString(), time() + 600, LACE_URL_REL); setcookie(LACE_NAME_COOKIE, $name, time() + 2592000, LACE_URL_REL); return true; }
function showUsingQuery($templateName, $query, $highlight = '', $comments = 0, $dateheads = 1) { global $CONF, $manager; $lastVisit = cookieVar($CONF['CookiePrefix'] . 'lastVisit'); if ($lastVisit != 0) { $lastVisit = $this->getCorrectTime($lastVisit); } // set templatename as global variable (so plugins can access it) global $currentTemplateName; $currentTemplateName = $templateName; $template =& $manager->getTemplate($templateName); // create parser object & action handler $actions =& new ITEMACTIONS($this); $parser =& new PARSER($actions->getDefinedActions(), $actions); $actions->setTemplate($template); $actions->setHighlight($highlight); $actions->setLastVisit($lastVisit); $actions->setParser($parser); $actions->setShowComments($comments); // execute query $items = sql_query($query); // loop over all items $old_date = 0; while ($item = sql_fetch_object($items)) { $item->timestamp = strtotime($item->itime); // string timestamp -> unix timestamp // action handler needs to know the item we're handling $actions->setCurrentItem($item); // add date header if needed if ($dateheads) { $new_date = date('dFY', $item->timestamp); if ($new_date != $old_date) { // unless this is the first time, write date footer $timestamp = $item->timestamp; if ($old_date != 0) { $oldTS = strtotime($old_date); $manager->notify('PreDateFoot', array('blog' => &$this, 'timestamp' => $oldTS)); $tmp_footer = strftimejp(isset($template['DATE_FOOTER']) ? $template['DATE_FOOTER'] : '', $oldTS); $parser->parse($tmp_footer); $manager->notify('PostDateFoot', array('blog' => &$this, 'timestamp' => $oldTS)); } $manager->notify('PreDateHead', array('blog' => &$this, 'timestamp' => $timestamp)); // note, to use templatvars in the dateheader, the %-characters need to be doubled in // order to be preserved by strftime $tmp_header = strftimejp(isset($template['DATE_HEADER']) ? $template['DATE_HEADER'] : null, $timestamp); $parser->parse($tmp_header); $manager->notify('PostDateHead', array('blog' => &$this, 'timestamp' => $timestamp)); } $old_date = $new_date; } // parse item $parser->parse($template['ITEM_HEADER']); $manager->notify('PreItem', array('blog' => &$this, 'item' => &$item)); $parser->parse($template['ITEM']); $manager->notify('PostItem', array('blog' => &$this, 'item' => &$item)); $parser->parse($template['ITEM_FOOTER']); } $numrows = sql_num_rows($items); // add another date footer if there was at least one item if ($numrows > 0 && $dateheads) { $manager->notify('PreDateFoot', array('blog' => &$this, 'timestamp' => strtotime($old_date))); $parser->parse($template['DATE_FOOTER']); $manager->notify('PostDateFoot', array('blog' => &$this, 'timestamp' => strtotime($old_date))); } sql_free_result($items); // free memory return $numrows; }
function contributeTinymceContent(&$data) { global $member; if (cookieVar($CONF['CookiePrefix'] . 'loginkey') && $this->_memberCheck($member->getID()) == true) { $this->_suspendConvertBreaks($data); $this->_recoverTags($data); if ($this->getOption('trim_ptag') == 'yes') { return $this->_delP($data); } } }
function doSkinVar() { if (!$this->isSmartPhone()) { return; } $viewmode = getVar('viewmode'); if (is_null($viewmode)) { $viewmode = cookieVar('viewmode'); } if (is_null($viewmode)) { if ($this->isSmartPhone()) { $viewmode = 1; } else { $viewmode = 0; } } else { $viewmode = intval($viewmode); } $Url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if (strpos($Url, '?') === false) { $Url .= '?'; } else { $Url .= '&'; } $_ = strstr($Url, 'viewmode'); if (strpos($Url, $_) !== false) { $Url = str_replace($_, '', $Url); } $optionViewsp = htmlspecialchars($this->getOption('viewsp'), ENT_QUOTES, _CHARSET); $optionViewpc = htmlspecialchars($this->getOption('viewpc'), ENT_QUOTES, _CHARSET); $echo = '<div class="viewmode">'; if ($viewmode == 0) { $echo .= sprintf('<a href="%s">%s</a>', "{$Url}viewmode=1", $optionViewsp); } elseif ($viewmode == 1) { $echo .= sprintf('<a href="%s">%s</a>', "{$Url}viewmode=0", $optionViewpc); } $echo .= '</div>'; echo $echo; }
/** * getName() * * Attempt to find a user's name in the $_POST * and $_COOKIE variables */ function getName() { // Look for the name in $_POST then in // $_COOKIE, or give a new generic name if (array_key_exists('name', $_POST) && mb_strlen(trim($_POST['name'])) > 0) { $name = urldecode($_POST['name']); setcookie(LACE_NAME_COOKIE, $name, time() + 3600 * 24 * 30, LACE_URL_REL); } else { $name = cookieVar(LACE_NAME_COOKIE, 'Guest ' . mb_substr(rand(0, 9999), 0, 4)); } return $name; }
function intCookieVar($name) { return intval(cookieVar($name)); }
/** * Parse skinvar commentform */ function parse_commentform($destinationurl = '') { global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage; // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0) if (stristr($destinationurl, 'action.php')) { $args = func_get_args(); $destinationurl = $args[1]; ACTIONLOG::add(WARNING, _ACTIONURL_NOTLONGER_PARAMATER); } $actionurl = $CONF['ActionURL']; // if item is closed, show message and do nothing $item =& $manager->getItem($itemid, 0, 0); if ($item['closed'] || !$blog->commentsEnabled()) { $this->doForm('commentform-closed'); return; } if (!$blog->isPublic() && !$member->isLoggedIn()) { $this->doForm('commentform-closedtopublic'); return; } if (!$destinationurl) { $destinationurl = createLink('item', array('itemid' => $itemid, 'title' => $item['title'], 'timestamp' => $item['timestamp'], 'extra' => $this->linkparams)); // note: createLink returns an HTML encoded URL } else { // HTML encode URL $destinationurl = htmlspecialchars($destinationurl, ENT_QUOTES); } // values to prefill $user = cookieVar($CONF['CookiePrefix'] . 'comment_user'); if (!$user) { $user = postVar('user'); } $userid = cookieVar($CONF['CookiePrefix'] . 'comment_userid'); if (!$userid) { $userid = postVar('userid'); } $email = cookieVar($CONF['CookiePrefix'] . 'comment_email'); if (!$email) { $email = postVar('email'); } $body = postVar('body'); $this->formdata = array('destinationurl' => $destinationurl, 'actionurl' => htmlspecialchars($actionurl, ENT_QUOTES), 'itemid' => $itemid, 'user' => htmlspecialchars($user, ENT_QUOTES), 'userid' => htmlspecialchars($userid, ENT_QUOTES), 'email' => htmlspecialchars($email, ENT_QUOTES), 'body' => htmlspecialchars($body, ENT_QUOTES), 'membername' => $member->getDisplayName(), 'rememberchecked' => cookieVar($CONF['CookiePrefix'] . 'comment_user') ? 'checked="checked"' : ''); if (!$member->isLoggedIn()) { $this->doForm('commentform-notloggedin'); } else { $this->doForm('commentform-loggedin'); } }
public function doTemplateVar(&$item, $constant) { global $member, $CONF; $language = getLanguageName(); $getLanguage = isset($_GET['lang']) ? getVar('lang') : false; $cookieLanguage = isset($_COOKIE['NP_Text']) ? cookieVar('NP_Text') : false; if ($getLanguage) { $this->use_lang($getLanguage, $constant); } elseif ($cookieLanguage) { $this->use_lang($cookieLanguage, $constant); } else { $this->use_lang($language, $constant); } }