/** * confirm an authorisation key is valid * <br> * See description of <code>pnSecGenAuthKey</code> for information on * this function * @public * @returns bool * @return true if the key is valid, false if it is not */ function pnSecConfirmAuthKey($preview = false) { list($module, $authid) = pnVarCleanFromInput('module', 'authid'); // Regenerate static part of key $partkey = pnSessionGetVar('rand') . strtolower($module); if (md5($partkey) == $authid) { // Match - generate new random number for next key and leave happy if (!$preview) { srand((double) microtime() * 1000000); pnSessionSetVar('rand', rand()); } return true; } // Not found, assume invalid return false; }
/** * get the user's language * * @public <br> * jgm - the language parameter should be a user variable, not a * session variable * @return string the name of the user's language */ function pnUserGetLang() { $lang = pnSessionGetVar('lang'); if (!empty($lang)) { return $lang; } else { return pnConfigGetVar('language'); } }
/** * confirm an authorisation key is valid * <br /> * See description of <code>pnSecGenAuthKey</code> for information on * this function * * @public * @return bool true if the key is valid, false if it is not */ function pnSecConfirmAuthKey() { list($module, $authid) = pnVarCleanFromInput('module', 'authid'); // get the module info $modinfo = pnModGetInfo(pnModGetIDFromName($module)); // Regenerate static part of key $partkey = pnSessionGetVar('rand') . strtolower($modinfo['name']); // Not using time-sensitive keys for the moment // // Key life is 5 minutes, so search backwards and forwards 5 // // minutes to see if there is a match anywhere // for ($i=-5; $i<=5; $i++) { // $testdate = mktime(date('G'), date('i')+$i, 0, date('m') , date('d'), date('Y')); // $testauthid = md5($partkey . date('YmdGi', $testdate)); // if ($testauthid == $authid) { // // Match // // We've used up the current random // // number, make up a new one // srand((double)microtime()*1000000); // pnSessionSetVar('rand', rand()); // return true; // } // } if (md5($partkey) == $authid) { // Match - generate new random number for next key and leave happy srand((double) microtime() * 1000000); pnSessionSetVar('rand', rand()); return true; } // Not found, assume invalid return false; }
/** * Loads the required manual for module */ function modules_get_manual() { $currentlang = pnSessionGetVar('lang'); $language = pnConfigGetVar('language'); if (!isset($GLOBALS['ModName'])) { $modname = pnModGetName(); } else { $modname = $GLOBALS['ModName']; } $modinfo = pnModGetInfo(pnModGetIDFromName($modname)); if (file_exists('modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/' . pnVarPrepForOS($currentlang) . '/manual.html')) { $hlpfile = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/' . pnVarPrepForOS($currentlang) . '/manual.html'; } elseif (!empty($language)) { if (file_exists('modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/' . pnVarPrepForOS($language) . '/manual.html')) { $hlpfile = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/' . pnVarPrepForOS($language) . '/manual.html'; } } else { $hlpfile = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/eng/manual.html'; } return; }
/** * get status message from previous operation * <br> * Obtains any status message, and also destroys * it from the session to prevent duplication * @returns string * @return the status message */ function pnGetStatusMsg() { $msg = pnSessionGetVar('statusmsg'); pnSessionDelVar('statusmsg'); $errmsg = pnSessionGetVar('errormsg'); pnSessionDelVar('errormsg'); // Error message overrides status message if (!empty($errmsg)) { return $errmsg; } return $msg; }
function Lenses_user_compare_form() { if (!pnSecAuthAction(0, 'Lenses::', '::', ACCESS_OVERVIEW)) { return pnVarPrepHTMLDisplay(_NOTSUBSCRIBED); } $pnRender =& new pnRender('Lenses'); //get the saved lens session variable $saved_lens_array = pnSessionGetVar('saved_lens_array'); if (!isset($saved_lens_array)) { $pnRender->assign('no_lenses', true); } else { $pnRender->assign('lenses', $saved_lens_array); } return $pnRender->fetch('lenses_user_compare_form.htm'); }
function pollCollector($pollID, $voteID, $forwarder) { list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); // Check that the user hasn't voted for this poll already if (pnSessionGetVar("poll_voted{$pollID}")) { $warn = "You already voted today!"; } else { pnSessionSetVar("poll_voted{$pollID}", 1); $column =& $pntable['poll_data_column']; $dbconn->Execute("UPDATE {$pntable['poll_data']} SET {$column['optioncount']}={$column['optioncount']}+1 WHERE ({$column['pollid']}=" . (int) pnVarPrepForStore($pollID) . ") AND ({$column['voteid']}=" . (int) pnVarPrepForStore($voteID) . ")"); $column =& $pntable['poll_desc_column']; $dbconn->Execute("UPDATE {$pntable['poll_desc']} SET {$column['voters']}={$column['voters']}+1 WHERE {$column['pollid']}=" . (int) pnVarPrepForStore($pollID) . ""); } pnRedirect($forwarder); }
/** * add core data to the template * * This function adds some basic data to the template depending on the * current user and the PN settings. * * @param list of module names. all mod vars of these modules will be included too The mod vars of the current module will always be included * @return boolean true if ok, otherwise false * @access public */ function add_core_data() { $pncore = array(); $pncore['version_num'] = _PN_VERSION_NUM; $pncore['version_id'] = _PN_VERSION_ID; $pncore['version_sub'] = _PN_VERSION_SUB; $pncore['logged_in'] = pnUserLoggedIn(); $pncore['language'] = pnUserGetLang(); $pncore['themeinfo'] = pnThemeInfo(pnUserGetTheme()); pnThemeLoad($pncore['themeinfo']['name']); $colors = array(); $colors['bgcolor1'] = pnThemeGetVar('bgcolor1'); $colors['bgcolor2'] = pnThemeGetVar('bgcolor2'); $colors['bgcolor3'] = pnThemeGetVar('bgcolor3'); $colors['bgcolor4'] = pnThemeGetVar('bgcolor4'); $colors['bgcolor5'] = pnThemeGetVar('bgcolor5'); $colors['sepcolor'] = pnThemeGetVar('sepcolor'); $colors['textcolor1'] = pnThemeGetVar('textcolor1'); $colors['textcolor2'] = pnThemeGetVar('textcolor2'); // add userdata $pncore['user'] = pnUserGetVars(pnSessionGetVar('uid')); // add modvars of current module $pncore[$this->module] = pnModGetVar($this->module); // add mod vars of all modules supplied as parameter foreach (func_get_args() as $modulename) { // if the modulename is empty do nothing if (!empty($modulename) && !is_array($modulename) && $modulename != $this->module) { // check if user wants to have /PNConfig if ($modulename == _PN_CONFIG_MODULE) { $pnconfig = pnModGetVar(_PN_CONFIG_MODULE); foreach ($pnconfig as $key => $value) { // unserialize all config vars $pncore['pnconfig'][$key] = @unserialize($value); } } else { $pncore[$modulename] = pnModGetVar($modulename); } } } $this->assign('pncore', $pncore); $this->assign($colors); return true; }
function pnThemeLangLoad($script = 'global') { $currentlang = pnSessionGetVar('lang'); $language = pnConfigGetVar('language'); $theme = pnUserGetTheme(); if (file_exists($file = WHERE_IS_PERSO . 'themes/' . pnVarPrepForOS($theme) . '/lang/' . pnVarPrepForOS($currentlang) . '/' . pnVarPrepForOS($script) . '.php')) { @(include_once $file); } elseif (file_exists($file = WHERE_IS_PERSO . 'themes/' . pnVarPrepForOS($theme) . '/lang/' . pnVarPrepForOS($language) . '/' . pnVarPrepForOS($script) . '.php')) { @(include_once $file); } elseif (file_exists($file = 'themes/' . pnVarPrepForOS($theme) . '/lang/' . pnVarPrepForOS($currentlang) . '/' . pnVarPrepForOS($script) . '.php')) { @(include_once $file); } elseif (file_exists($file = 'themes/' . pnVarPrepForOS($theme) . '/lang/' . pnVarPrepForOS($language) . '/' . pnVarPrepForOS($script) . '.php')) { @(include_once $file); } return; }