function setCookieSection($name, $value, $section = '', $expire = null, $path = '', $domain = '', $secure = '') { global $feature_no_cookie; if ($section) { $valSection = getCookie($section); $name2 = '@' . $name . ':'; if ($valSection) { if (preg_match('/' . preg_quote($name2) . '/', $valSection)) { $valSection = preg_replace('/' . preg_quote($name2) . '[^@;]*/', $name2 . $value, $valSection); } else { $valSection = $valSection . $name2 . $value; } setCookieSection($section, $valSection, '', $expire, $path, $domain, $secure); } else { $valSection = $name2 . $value; setCookieSection($section, $valSection, '', $expire, $path, $domain, $secure); } } else { if ($feature_no_cookie) { $_SESSION['tiki_cookie_jar'][$name] = $value; } else { setcookie($name, $value, $expire, $path, $domain, $secure); } } }
function setCookieSection($name, $value, $section = '', $expire = null, $path = '', $domain = '', $secure = '') { if ($section) { $valSection = getCookie($section); $name2 = '@' . $name . ':'; if ($valSection) { if (preg_match('/' . preg_quote($name2) . '/', $valSection)) { $valSection = preg_replace('/' . preg_quote($name2) . '[^@;]*/', $name2 + $value, $valSection); } else { $valSection = $valSection + $name2 + $value; } setCookieSection($section, $valSection, '', $expire, $path, $domain, $secure); } else { $valSection = $name2 . $value; setCookieSection($section, $valSection, '', $expire, $path, $domain, $secure); } } else { setcookie($name, $value, $expire, $path, $domain, $secure); } }
$_SESSION['current_perspective'] = $persp; $isWikiPage = $tikiIndex === 'tiki-index.php' && strpos($_SERVER['PHP_SELF'], 'tiki-index.php') !== false; $wantsHomePage = empty($_REQUEST['page']) || $_REQUEST['page'] === $wikiHomePage && strpos($_SERVER['HTTP_REFERER'], $base_url) === false; if ($isWikiPage && $wantsHomePage) { $pprefs = $perspectivelib->get_preferences($_SESSION['current_perspective']); if (in_array('wikiHomePage', array_keys($pprefs))) { // mobile persp has home page set (often the case) header('Location: ' . $base_url); // so redirect to site root and try again } else { $prefs = array_merge($prefs, $pprefs); } } } } else { $prefs['mobile_mode'] = 'n'; if (!$supported_device) { // send error only if not on a read mobile device TikiLib::lib('errorreport')->report(tra('Mobile mode: Permission denied, please log in.')); } } } } else { $prefs['mobile_mode'] = 'n'; } } else { $prefs['mobile_mode'] = 'n'; } if ($prefs['mobile_mode'] === 'y') { setCookieSection('mobile_mode', $prefs['mobile_mode']); }
function setupBiDi() { global $prefs; if ($prefs['feature_multilingual'] === 'y') { // Some languages need BiDi support. Add their code names here ... if (Language::isRTL()) { $prefs['feature_bidi'] = 'y'; TikiLib::lib('header')->add_cssfile('styles/BiDi/BiDi.css'); setCookieSection('rtl', 'y'); } else { $prefs['feature_bidi'] = 'n'; TikiLib::lib('header')->drop_cssfile('styles/BiDi/BiDi.css'); setCookieSection('rtl', 'n'); } } }
require_once 'lib/setup/mobile.php'; // needs to be before js_detect but after cookies } else { $prefs['mobile_mode'] = ''; } require_once 'lib/setup/user_prefs.php'; require_once 'lib/setup/language.php'; require_once 'lib/setup/javascript.php'; require_once 'lib/setup/wiki.php'; /* Cookie consent setup, has to be after the JS decision and wiki setup */ $cookie_consent_html = ''; if ($prefs['cookie_consent_feature'] === 'y') { if (!empty($_REQUEST['cookie_consent_checkbox']) || $prefs['site_closed'] === 'y') { // js disabled $feature_no_cookie = false; setCookieSection($prefs['cookie_consent_name'], 'y'); } $cookie_consent = getCookie($prefs['cookie_consent_name']); if (empty($cookie_consent)) { if ($prefs['javascript_enabled'] !== 'y') { $prefs['cookie_consent_mode'] = ''; } else { $headerlib->add_js('jqueryTiki.no_cookie = true; jqueryTiki.cookie_consent_alert = "' . addslashes($prefs['cookie_consent_alert']) . '";'); } foreach ($_COOKIE as $k => $v) { setcookie($k, '', time() - 3600); // unset any previously existing cookies } $cookie_consent_html = $smarty->fetch('cookie_consent.tpl'); } else { $feature_no_cookie = false;
function smarty_block_tabset($params, $content, $smarty, &$repeat) { global $prefs, $smarty_tabset_name, $smarty_tabset, $smarty_tabset_i_tab, $cookietab, $tabset_index; $headerlib = TikiLib::lib('header'); if ($smarty->getTemplateVars('print_page') == 'y' || $prefs['layout_tabs_optional'] === 'n') { $params['toggle'] = 'n'; } if ($repeat) { // opening if (!is_array($smarty_tabset)) { $smarty_tabset = array(); } $tabset_index = count($smarty_tabset) + 1; $smarty_tabset_name = getTabsetName($params, $tabset_index); $smarty_tabset[$tabset_index] = array('name' => $smarty_tabset_name, 'tabs' => array()); if (!isset($smarty_tabset_i_tab)) { $smarty_tabset_i_tab = 1; } if (!isset($cookietab) || $tabset_index > 1) { $cookietab = getCookie($smarty_tabset_name, 'tabs', 1); } // work out cookie value if there if (isset($_REQUEST['cookietab']) && $tabset_index) { // overrides cookie if added to request as in tiki-admin.php?page=look&cookietab=6 $cookietab = empty($_REQUEST['cookietab']) ? 1 : $_REQUEST['cookietab']; setCookieSection($smarty_tabset_name, $cookietab, 'tabs'); // too late to set it here as output has started } // If the tabset specifies the tab, override any kind of memory but only if not doing "no tabs" mode if (isset($params['cookietab']) && $cookietab !== 'n') { $cookietab = $params['cookietab']; } $smarty_tabset_i_tab = 1; return; } else { $content = trim($content); if (empty($content)) { return ''; } if (!empty($params['skipsingle']) && count($smarty_tabset[$tabset_index]['tabs']) == 1) { return $content; } $ret = ''; $notabs = ''; //closing if ($prefs['feature_tabs'] == 'y') { if (empty($params['toggle']) || $params['toggle'] != 'n') { $smarty->loadPlugin('smarty_function_button'); if ($cookietab == 'n') { $button_params['_text'] = tra('Tab View'); } else { $button_params['_text'] = tra('No Tabs'); } $button_params['_size'] = 'mini'; $button_params['_auto_args'] = '*'; $button_params['_onclick'] = "setCookie('{$smarty_tabset_name}','" . ($cookietab == 'n' ? 1 : 'n') . "', 'tabs') ;"; $button_params['_class'] = 'btn-xs'; $notabs = smarty_function_button($button_params, $smarty); $notabs = "<div class='pull-right'>{$notabs}</div>"; $content_class = ''; } else { $content_class = ' full_width'; // no no-tabs button } } else { return $content; } if ($cookietab == 'n') { return $ret . $notabs . $content; } $smarty_tabset_name = getTabsetName($params, $tabset_index); $ret .= '<div class="clearfix tabs" data-name="' . $smarty_tabset_name . '">' . $notabs; $count = 1; $ret .= '<ul class="nav nav-tabs">'; foreach ($smarty_tabset[$tabset_index]['tabs'] as $value) { $ret .= '<li class="' . $value['active'] . '"><a href="#' . $value['id'] . '" data-toggle="tab">' . $value['label'] . '</a></li>'; ++$count; } $ret .= '</ul>'; $ret .= "</div>"; $tabset_index--; return $ret . '<div class="tab-content">' . $content . '</div>'; } }
// Update the pref with the cookie value $prefs['javascript_enabled'] = $js_cookie; } else { $prefs['javascript_enabled'] = 'y'; } if ($prefs['javascript_enabled'] != 'y' && $prefs['disableJavascript'] != 'y') { // Set the cookie to 'y', through javascript (will override the above cookie set to 'n' and sent by PHP / HTTP headers) - duration: approx. 1 year $headerlib->add_js("setCookie('javascript_enabled', 'y');", 0); // the first and second time, we should not trust the absence of javascript_enabled cookie yet, as it could be a redirection and the js will not get a chance to run yet, so we wait until the third run, assuming that js is on before then $runs_before_js_detect = getCookie('runs_before_js_detect'); if ($runs_before_js_detect === null) { $prefs['javascript_enabled'] = 'y'; setCookieSection('runs_before_js_detect', '1', null, $tikilib->now + 365 * 24 * 3600); } elseif ($runs_before_js_detect > 0) { $prefs['javascript_enabled'] = 'y'; setCookieSection('runs_before_js_detect', $runs_before_js_detect - 1, null, $tikilib->now + 365 * 24 * 3600); } } if ($prefs['javascript_enabled'] == 'n') { // disable js dependant features $prefs['feature_tabs'] = 'n'; $prefs['feature_jquery'] = 'n'; $prefs['feature_shadowbox'] = 'n'; $prefs['feature_wysiwyg'] = 'n'; $prefs['feature_ajax'] = 'n'; $prefs['calendar_fullcalendar'] = 'n'; } if ($prefs['javascript_enabled'] == 'y') { // we have JavaScript $prefs['feature_jquery'] = 'y'; // just in case
($gal_info['show_backlinks']!='n'), $find, $syntax ); $smarty->assign_by_ref('files', $files['data']); $smarty->assign('cant', $files['cant']); } $smarty->assign('mid', 'tiki-list_file_gallery.tpl'); } // Browse view $smarty->assign('thumbnail_size', $prefs['fgal_thumb_max_size']); if (isset($_REQUEST['show_details'])) { $show_details = $_REQUEST['show_details']; setCookieSection('show_details', $show_details); } else { $show_details = getCookie('show_details', null, 'n'); } $smarty->assign('show_details', $show_details); $options_sortorder = array( tra('Creation Date') => 'created' , tra('Name') => 'name' , tra('Last modification date') => 'lastModif' , tra('Hits') => 'hits' , tra('Owner') => 'user' , tra('Description') => 'description' , tra('ID') => 'id' ); $smarty->assign_by_ref('options_sortorder', $options_sortorder); // Set section config
function smarty_block_tabset($params, $content, $smarty, &$repeat) { global $prefs, $smarty_tabset_name, $smarty_tabset, $smarty_tabset_i_tab, $cookietab, $headerlib, $tabset_index; if ($smarty->getTemplateVars('print_page') == 'y' || $prefs['layout_tabs_optional'] === 'n') { $params['toggle'] = 'n'; } if ($repeat) { // opening if (!is_array($smarty_tabset)) { $smarty_tabset = array(); } $tabset_index = count($smarty_tabset) + 1; if (isset($params['name']) and !empty($params['name'])) { $smarty_tabset_name = $params['name']; // names have to be unique } else { $short_name = str_replace(array('tiki-', '.php'), '', basename($_SERVER['SCRIPT_NAME'])); $smarty_tabset_name = 't_' . $short_name . $tabset_index; } $smarty_tabset_name = TikiLib::remove_non_word_characters_and_accents($smarty_tabset_name); $smarty_tabset[$tabset_index] = array('name' => $smarty_tabset_name, 'tabs' => array()); if (!isset($smarty_tabset_i_tab)) { $smarty_tabset_i_tab = 1; } if (!isset($cookietab) || $tabset_index > 1) { $cookietab = getCookie($smarty_tabset_name, 'tabs', 1); } // work out cookie value if there if (isset($_REQUEST['cookietab']) && $tabset_index === 1) { // overrides cookie if added to request as in tiki-admin.php?page=look&cookietab=6 $cookietab = empty($_REQUEST['cookietab']) ? 1 : $_REQUEST['cookietab']; setCookieSection($smarty_tabset_name, $cookietab, 'tabs'); // too late to set it here as output has started } // If the tabset specifies the tab, override any kind of memory but only if not doing "no tabs" mode if (isset($params['cookietab']) && $cookietab !== 'n') { $cookietab = $params['cookietab']; } $smarty_tabset_i_tab = 1; return; } else { $content = trim($content); if (empty($content)) { return ''; } $ret = ''; $notabs = ''; //closing if ($prefs['feature_tabs'] == 'y') { if (empty($params['toggle']) || $params['toggle'] != 'n') { $smarty->loadPlugin('smarty_function_button'); if ($cookietab == 'n') { $button_params['_text'] = tra('Tab View'); } else { $button_params['_text'] = tra('No Tabs'); } $button_params['_auto_args'] = '*'; $button_params['_onclick'] = "setCookie('{$smarty_tabset_name}','" . ($cookietab == 'n' ? 1 : 'n') . "', 'tabs') ;"; $notabs = smarty_function_button($button_params, $smarty); $notabs = "<div class='tabstoggle floatright'>{$notabs}</div>"; $content_class = ''; } else { $content_class = ' full_width'; // no no-tabs button } } else { return $content; } if ($cookietab == 'n') { return $ret . $notabs . $content; } $ret .= '<div class="clearfix tabs" data-name="' . $smarty_tabset_name . '">' . $notabs; $count = 1; if ($prefs['mobile_feature'] === 'y' && $prefs['mobile_mode'] === 'y') { $ret .= '<div class="container' . $content_class . '" data-role="navbar"><ul>'; foreach ($smarty_tabset[$tabset_index]['tabs'] as $value) { $ret .= '<li>' . '<a href="#" class="tabmark tab' . $count . ' ' . ($count == $cookietab ? 'ui-btn-active' : '') . '"' . ' onclick="tikitabs(' . $count . ',this); return false;">' . $value . '</a></li>'; ++$count; } $ret .= '</ul></div>'; } else { // notmal non-mobile rendering $ret .= '<div class="container' . $content_class . '">'; foreach ($smarty_tabset[$tabset_index]['tabs'] as $value) { $ret .= '<span class="tabmark tab' . $count . ' ' . ($count == $cookietab ? 'tabactive' : '') . '">' . '<a href="#content' . $count . '"' . ' onclick="tikitabs(' . $count . ',this); return false;">' . $value . '</a></span>'; ++$count; } $ret .= '</div>'; } $ret .= "</div>{$content}"; // add some jq to initialize the tab, needed when page is cached if ($tabset_index === 1) { // override cookie with query cookietab $headerlib->add_jq_onready(' var ctab = location.search.match(/cookietab=(\\d+)/); if (ctab) { setCookie("' . $smarty_tabset_name . '", ctab[1],"tabs"); }'); } if ($cookietab != getCookie($smarty_tabset_name, 'tabs', 1)) { // has been changed by code but now too late to reset $headerlib->add_jq_onready('setCookie("' . $smarty_tabset_name . '",' . $cookietab . ',"tabs");'); } else { $headerlib->add_jq_onready('tikitabs(getCookie("' . $smarty_tabset_name . '","tabs",1), $("div[data-name=' . $smarty_tabset_name . '] .tabmark:first"));'); } $div_id = $smarty_tabset_name; // work arounds for nested plugins $tabset_index--; array_pop($smarty_tabset); if ($tabset_index > 0) { $smarty_tabset_name = $smarty_tabset[$tabset_index]['name']; $cookietab = getCookie($smarty_tabset_name, 'tabs', 1); } return '<div class="tabset" id="' . $div_id . '">' . $ret . '</div>'; } }
/** * This is the function called when a bound event is triggered. This stores the scoring transaction to the db * and increases the score * @param array $args * @param string $eventType * @throws Exception */ function assignPoints($args = array(), $eventType = "") { $rules = $this->getScoreEventRules($eventType); $date = TikiLib::lib('tiki')->now; //for each rule associated with the event, set up the scor foreach ($rules as $rule) { // if the object is invalid, do nothing. if (!$this->objectIsValid($args, $rule)) { continue; } $recipient = $this->evaluateExpression($rule->recipient, $args, "eval"); $recipientType = $this->evaluateExpression($rule->recipientType, $args); $points = $this->evaluateExpression($rule->score, $args); if (!$recipient || !$points) { continue; } if ($rule->expiration > 0 && !$this->hasWaitedMinTime($args, $rule, $recipientType, $recipient)) { continue; } //if user is anonymous, store a unique identifier in a cookie and set it as the user. if (empty($args['user'])) { $uniqueVal = getCookie('anonUserScoreId'); if (empty($uniqueVal)) { $uniqueVal = getenv('HTTP_CLIENT_IP') . time() . rand(); $uniqueVal = md5($uniqueVal); setCookieSection('anonUserScoreId', "anon" . $uniqueVal); } $args['user'] = $uniqueVal; } $pbalance = $this->getPointsBalance($recipientType, $recipient); $data = ['triggerObjectType' => $args['type'], 'triggerObjectId' => $args['object'], 'triggerUser' => $args['user'], 'triggerEvent' => $eventType, 'ruleId' => $rule->ruleId, 'recipientObjectType' => $recipientType, 'recipientObjectId' => $recipient, 'pointsAssigned' => $points, 'pointsBalance' => $pbalance + $points, 'date' => $date]; $id = $this->table()->insert($data); } }
if ($prefs['tracker_wikirelation_redirectpage'] == 'y' && !isset($_REQUEST['admin'])) { $relatedItems = TikiLib::lib('relation')->get_object_ids_with_relations_from('wiki page', $page, 'tiki.wiki.linkeditem'); $relatedItem = reset($relatedItems); if ($relatedItem) { $url = 'tiki-view_tracker_item.php?itemId=' . $relatedItem; include_once 'tiki-sefurl.php'; header('location: ' . filter_out_sefurl($url, 'trackeritem')); } } // Inline Ckeditor editor if ($prefs['wysiwyg_inline_editing'] == 'y' && $page && ($tikilib->user_has_perm_on_object($user, $_REQUEST['page'], 'wiki page', 'edit') || $tikilib->user_has_perm_on_object($user, $_REQUEST['page'], 'wiki page', 'edit_inline'))) { TikiLib::lib('wysiwyg')->setUpInlineEditor($_REQUEST['page']); // init ckeditor } else { if (getCookie('wysiwyg_inline_edit', 'preview')) { setCookieSection('wysiwyg_inline_edit', 0, 'preview'); // kill cookie if pref off or no perms } } $page = $_REQUEST['page'] = $wikilib->get_page_by_slug($page); // Process page display options $wikilib->processPageDisplayOptions(); #Propagate the fullscreen parameter to templates if (isset($_REQUEST['fullscreen'])) { $fullscreen = $_REQUEST['fullscreen']; } else { $fullscreen = 'n'; } $smarty->assign('fullscreen', $fullscreen); if (!$info || isset($_REQUEST['date']) || isset($_REQUEST['version'])) { if ($prefs['feature_wiki_use_date'] == 'y' && isset($_REQUEST['date'])) {
// so check that $feature_no_cookie is not true because cookies are not really set when using cookie_consent_feature // and so javascript will get disabled by mistake if (empty($javascript_enabled_detect) && $feature_no_cookie) { $prefs['javascript_enabled'] = 'y'; // assume javascript should be enabled while cookie consent is pending } else { if ($prefs['javascript_enabled'] === '' && $prefs['disableJavascript'] != 'y' && $javascript_enabled_detect < 3) { // Set the cookie to 'y', through javascript - expires: approx. 1 year $prefs['javascript_enabled'] = 'y'; // temporarily enable to we output the test js $plus_one_year = $tikilib->now + 365 * 24 * 3600; $headerlib->add_js("setCookieBrowser('javascript_enabled', 'y', '', new Date({$plus_one_year}000));", 0); // setCookieBrowser does not use the tiki_cookie_jar if (strpos($_SERVER['PHP_SELF'], 'tiki-download') === false && strpos($_SERVER['PHP_SELF'], 'tiki-ajax_services.php') === false && strpos($_SERVER['PHP_SELF'], 'tiki-jsmodule.php') === false && strpos($_SERVER['PHP_SELF'], 'tiki-jsplugin.php') === false && strpos($_SERVER['PHP_SELF'], 'tiki-login.php') === false && strpos($_SERVER['PHP_SELF'], 'tiki-install.php') === false) { $javascript_enabled_detect++; setCookieSection('javascript_enabled_detect', $javascript_enabled_detect, '', $plus_one_year); } } else { if ($js_cookie !== 'y') { // no js cookie detected $prefs['javascript_enabled'] = 'n'; } } } if ($prefs['javascript_enabled'] == 'n') { // disable js dependant features $prefs['feature_tabs'] = 'n'; $prefs['feature_jquery'] = 'n'; $prefs['feature_shadowbox'] = 'n'; $prefs['feature_wysiwyg'] = 'n'; $prefs['feature_ajax'] = 'n';
function wikiplugin_tour($data, $params) { $defaults = array(); $plugininfo = wikiplugin_tour_info(); foreach ($plugininfo['params'] as $key => $param) { $defaults["{$key}"] = $param['default']; } $params = array_merge($defaults, $params); $cookie_id = 'tour' . md5($params['tour_id']); if (getCookie($cookie_id, 'tours') == 'y') { $dontStart = true; } else { $dontStart = false; if ($params['show_once'] === 'y') { setCookieSection($cookie_id, 'y', 'tours'); } } static $id = 0; $unique = 'wptour_' . ++$id; static $wp_tour = array('steps' => array()); if (!isset($wp_tour['start'])) { $wp_tour['start'] = $params['start']; } $headerlib = TikiLib::lib('header'); $headerlib->add_jsfile('vendor/sorich87/bootstrap-tour/build/js/bootstrap-tour.js')->add_cssfile('vendor/sorich87/bootstrap-tour/build/css/bootstrap-tour.css'); // non changing init js in ransk 11 and 13 (the tour definition goes in 12) $headerlib->add_jq_onready('var tour; ', 11); if ($wp_tour['start'] === 'y' && !$dontStart) { $headerlib->add_jq_onready(' if (tour) { // Start the tour tour.restart(); } else { console.log("Warning: Tour not initialized, the last step needs to have parameter next set to -1"); } ', 13); } unset($params['start']); unset($params['tour_id']); $html = ''; $params['orphan'] = $params['orphan'] === 'y'; $params['backdrop'] = $params['backdrop'] === 'y'; if (empty($params['element']) && !$params['orphan']) { $params['element'] = "#{$unique}"; $html = '<span id="' . $unique . '"></span>'; if (!empty($params['show_restart_button'])) { $smarty = TikiLib::lib('smarty'); $smarty->loadPlugin('smarty_function_button'); $html .= smarty_function_button(['_text' => tra($params['show_restart_button']), '_id' => $unique . '_restart', 'href' => '#'], $smarty); $headerlib->add_jq_onready('$("#' . $unique . '_restart").click(function() { tour.goTo(0); tour.restart(); return false; });', 13); } } $params['content'] = TikiLib::lib('parser')->parse_data($data); $wp_tour['steps'][] = array_filter($params); if ($params['next'] == -1 || $params['path']) { $js = '// Instance the tour tour = new Tour(' . json_encode($wp_tour) . '); '; $headerlib->add_jq_onready($js, 12); } return $html; }