function xoonips_session_regenerate() { $old_sessid = session_id(); session_regenerate_id(); $new_sessid = session_id(); session_id($old_sessid); session_destroy(); $old_session = $_SESSION; session_id($new_sessid); $sess_handler =& xoops_gethandler('session'); session_set_save_handler(array(&$sess_handler, 'open'), array(&$sess_handler, 'close'), array(&$sess_handler, 'read'), array(&$sess_handler, 'write'), array(&$sess_handler, 'destroy'), array(&$sess_handler, 'gc')); session_start(); $_SESSION = array(); foreach (array_keys($old_session) as $key) { $_SESSION[$key] = $old_session[$key]; } // write and close session for xnp_is_valid_session_id() session_write_close(); // restart session session_set_save_handler(array(&$sess_handler, 'open'), array(&$sess_handler, 'close'), array(&$sess_handler, 'read'), array(&$sess_handler, 'write'), array(&$sess_handler, 'destroy'), array(&$sess_handler, 'gc')); session_start(); $_SESSION = array(); foreach (array_keys($old_session) as $key) { $_SESSION[$key] = $old_session[$key]; } }
function fetchSummary($external_link_id) { $db =& Database::getInstance(); $myts =& MyTextsanitizer::getInstance(); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($this->mydirname); $storyid = intval($external_link_id); $mydirname = $this->mydirname; if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } $mytrustdirpath = dirname(dirname(__FILE__)); require_once dirname(dirname(__FILE__)) . '/class/bulletin.php'; if (Bulletin::isPublishedExists($mydirname, $storyid)) { $article = new Bulletin($mydirname, $storyid); $subject4assign = $article->getVar('title'); $summary = $article->getVar('hometext'); if (function_exists('easiestml')) { $summary = easiestml($summary); } $summary4assign = htmlspecialchars(xoops_substr($this->unhtmlspecialchars(strip_tags($summary)), 0, 255), ENT_QUOTES); } else { $subject4assign = ''; $summary4assign = ''; } return array('dirname' => $mydirname, 'module_name' => $module->getVar('name'), 'subject' => $subject4assign, 'uri' => XOOPS_URL . '/modules/' . $mydirname . '/index.php?page=article&storyid=' . $storyid, 'summary' => $summary4assign); }
/** * Constructor * * @param string $caption * @param string $name * @param mixed $value Pre-selected value (or array of them). * For an item with massive members, such as "Registered Users", "$value" should be used to store selected temporary users only instead of all members of that item * @param bool $include_anon Include user "anonymous"? * @param int $size Number or rows. "1" makes a drop-down-list. * @param bool $multiple Allow multiple selections? */ function XoopsFormSelectUser($caption, $name, $include_anon = false, $value = null, $size = 1, $multiple = false) { $limit = 200; $select_element = new XoopsFormSelect('', $name, $value, $size, $multiple); if ($include_anon) { $select_element->addOption(0, $GLOBALS['xoopsConfig']['anonymous']); } $member_handler =& xoops_gethandler('member'); $user_count = $member_handler->getUserCount(); $value = is_array($value) ? $value : (empty($value) ? array() : array($value)); if ($user_count > $limit && count($value) > 0) { $criteria = new CriteriaCompo(new Criteria('uid', '(' . implode(',', $value) . ')', 'IN')); } else { $criteria = new CriteriaCompo(); $criteria->setLimit($limit); } $criteria->setSort('uname'); $criteria->setOrder('ASC'); $users = $member_handler->getUserList($criteria); $select_element->addOptionArray($users); if ($user_count <= $limit) { $this->XoopsFormElementTray($caption, "", $name); $this->addElement($select_element); return; } xoops_loadLanguage('findusers'); $js_addusers = "<script type='text/javascript'>\r\n function addusers(opts){\r\n var num = opts.substring(0, opts.indexOf(':'));\r\n opts = opts.substring(opts.indexOf(':')+1, opts.length);\r\n var sel = xoopsGetElementById('" . $name . "');\r\n var arr = new Array(num);\r\n for (var n=0; n < num; n++) {\r\n var nm = opts.substring(0, opts.indexOf(':'));\r\n opts = opts.substring(opts.indexOf(':')+1, opts.length);\r\n var val = opts.substring(0, opts.indexOf(':'));\r\n opts = opts.substring(opts.indexOf(':')+1, opts.length);\r\n var txt = opts.substring(0, nm - val.length);\r\n opts = opts.substring(nm - val.length, opts.length);\r\n var added = false;\r\n for (var k = 0; k < sel.options.length; k++) {\r\n if(sel.options[k].value == val){\r\n added = true;\r\n break;\r\n }\r\n }\r\n if (added == false) {\r\n sel.options[k] = new Option(txt, val);\r\n sel.options[k].selected = true;\r\n }\r\n }\r\n return true;\r\n }\r\n </script>"; $token = $GLOBALS['xoopsSecurity']->createToken(); $action_tray = new XoopsFormElementTray("", " | "); $action_tray->addElement(new XoopsFormLabel('', '<a href="#" onclick="var sel = xoopsGetElementById(\'' . $name . '\');for (var i = sel.options.length-1; i >= 0; i--) {if (!sel.options[i].selected) {sel.options[i] = null;}}; return false;">' . _MA_USER_REMOVE . "</a>")); $action_tray->addElement(new XoopsFormLabel('', '<a href="#" onclick="openWithSelfMain(\'' . XOOPS_URL . '/include/findusers.php?target=' . $name . '&multiple=' . $multiple . '&token=' . $token . '\', \'userselect\', 800, 600, null); return false;" >' . _MA_USER_MORE . "</a>" . $js_addusers)); $this->XoopsFormElementTray($caption, '<br /><br />', $name); $this->addElement($select_element); $this->addElement($action_tray); }
function getDefaultView(&$controller, &$xoopsUser) { $dirname = xoops_getrequest('dirname'); if (!preg_match("/^[a-zA-Z_][a-zA-Z0-9_]*\$/", $dirname)) { return LEGACY_FRAME_VIEW_ERROR; } if (!is_dir(XOOPS_MODULE_PATH . "/" . $dirname)) { return LEGACY_FRAME_VIEW_ERROR; } $moduleHandler =& xoops_gethandler('module'); $this->mModuleObject =& $moduleHandler->getByDirname($dirname); // // If a module is installed, load modinfo and go to special displaying. // if (is_object($this->mModuleObject)) { $this->mModuleObject->loadAdminMenu(); $this->mModuleObject->loadInfo($dirname); $this->mInstalledFlag = true; } else { $this->mModuleObject =& $moduleHandler->create(); $this->mModuleObject->loadInfoAsVar($dirname); $this->mInstalledFlag = false; } return LEGACY_FRAME_VIEW_SUCCESS; }
/** * @public */ public function get(&$userName, $uid) { $handler = xoops_gethandler('member'); $user = $handler->getUser($uid); $name = $user->getShow('name'); $userName = $name ? $name : $user->getShow('uname'); }
function search_album_set() { global $ALBUM_SET_SEARCH, $xoopsDB, $xoopsUser; if (is_object($xoopsUser)) { $usergroups = $xoopsUser->getgroups(); $usergroup = implode(",", $usergroups); $buid = $xoopsUser->uid(); } else { $usergroup = XOOPS_GROUP_ANONYMOUS; $buid = 0; } $user_cat = 10000; $module_handler =& xoops_gethandler('module'); $xcgalModule = $module_handler->getByDirname('xcgal'); $config_handler =& xoops_gethandler('config'); $xcgalCon =& $config_handler->getConfigsByCat(0, $xcgalModule->mid()); if (is_object($xoopsUser) && $xoopsUser->isAdmin($xcgalModule->mid())) { $ALBUM_SET_SEARCH = ""; } else { $result = $xoopsDB->query("SELECT aid FROM " . $xoopsDB->prefix("xcgal_albums") . " WHERE visibility NOT IN ({$usergroup}, 0," . ($user_cat + $buid) . ")"); if ($xoopsDB->getRowsNum($result)) { $set = ''; while ($album = $xoopsDB->fetchArray($result)) { $set .= $album['aid'] . ','; } // while $ALBUM_SET_SEARCH .= 'AND aid NOT IN (' . substr($set, 0, -1) . ') '; } $xoopsDB->freeRecordSet($result); } return $xcgalCon; }
function XooNIps_Amazon_ECS40() { // get module config $mydirname = basename(dirname(dirname(__FILE__))); $mhandler =& xoops_gethandler('module'); $module =& $mhandler->getByDirname($mydirname); $chandler =& xoops_gethandler('config'); $mconfig = $chandler->getConfigsByCat(false, $module->mid()); // call parent constructor parent::XooNIpsXMLParser(); // set fetcher conditions $this->_fetch_url = 'http://ecs.amazonaws.com/onca/xml'; $this->_fetch_arguments['Service'] = 'AWSECommerceService'; $this->_fetch_arguments['Version'] = '2007-07-16'; $this->_fetch_arguments['Operation'] = 'ItemLookup'; $this->_fetch_arguments['IdType'] = 'ISBN'; $this->_fetch_arguments['SearchIndex'] = 'Books'; $this->_fetch_arguments['ResponseGroup'] = 'Medium'; $this->_fetch_arguments['AWSAccessKeyId'] = $mconfig['AccessKey']; $this->_fetch_arguments['Timestamp'] = gmdate('Y-m-d\\TH:i:s\\Z'); $this->_fetch_arguments['AssociateTag'] = $mconfig['AssociateTag']; // secret access key for amazon API $this->_secret_access_key = $mconfig['SecretAccessKey']; // set parser conditions $this->_parser_doctype = ''; $this->_parser_public_id = ''; }
/** * Returns a module's option * * Return's a module's option * * @package multimenu * @author Hervé Thouzard * @param string $option module option's name * @param string $module module's name */ function multimenu_getmoduleoption($option, $repmodule = 'multiMenu') { global $xoopsModuleConfig, $xoopsModule; static $tbloptions = array(); if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) { return $tbloptions[$option]; } $retval = false; if (isset($xoopsModuleConfig) && (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule && $xoopsModule->getVar('isactive'))) { if (isset($xoopsModuleConfig[$option])) { $retval = $xoopsModuleConfig[$option]; } } else { $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($repmodule); $config_handler =& xoops_gethandler('config'); if ($module) { $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); if (isset($moduleConfig[$option])) { $retval = $moduleConfig[$option]; } } } $tbloptions[$option] = $retval; return $retval; }
function smarty_function_pico_category_search($params, &$smarty) { $dir = @$params['dir'] . @$params['dirname']; $cat_title = @$params['title'] . @$params['cat_title']; $var_name = @$params['item'] . @$params['assign']; if (empty($var_name)) { echo 'error ' . __FUNCTION__ . ' [specify item]'; return; } if (empty($dir)) { $dir = $smarty->get_template_vars('mydirname'); } if (empty($dir)) { echo 'error ' . __FUNCTION__ . ' [specify dirname]'; return; } $mydirnames = explode(',', $dir); $db =& Database::getInstance(); $myts =& MyTextSanitizer::getInstance(); $module_handler =& xoops_gethandler('module'); $config_handler =& xoops_gethandler('config'); $categories4assign = array(); foreach ($mydirnames as $mydirname) { $module =& $module_handler->getByDirname($mydirname); $configs = $config_handler->getConfigList($module->getVar('mid')); $sql = "SELECT * FROM " . $db->prefix($mydirname . "_categories") . " c WHERE c.cat_title='" . mysql_real_escape_string($cat_title) . "'"; $result = $db->query($sql); while ($cat_row = $db->fetchArray($result)) { $category4assign = array('mod_mid' => $module->getVar('mid'), 'mod_dirname' => $mydirname, 'mod_name' => $module->getVar('name'), 'id' => intval($cat_row['cat_id']), 'link' => pico_common_make_category_link4html($configs, $cat_row), 'title' => $myts->makeTboxData4Show($cat_row['cat_title']), 'desc' => $myts->displayTarea($cat_row['cat_desc'], 1), 'paths_raw' => pico_common_unserialize($cat_row['cat_path_in_tree']), 'paths_value' => array_values(pico_common_unserialize($cat_row['cat_path_in_tree'])), 'redundants' => pico_common_unserialize($cat_row['cat_redundants'])) + $cat_row; $categories4assign[] = $category4assign; } } $smarty->assign($var_name, $categories4assign); }
public function prepare() { $root = XCube_Root::getSingleton(); $handler = xoops_gethandler('config'); $xoopsMailerConfig = $handler->getConfigsByCat(XOOPS_CONF_MAILER); $this->reset(); if ($xoopsMailerConfig['from'] == '') { $this->From = $root->mContext->mXoopsConfig['adminmail']; } else { $this->From = $xoopsMailerConfig['from']; } $this->Sender = $root->mContext->mXoopsConfig['adminmail']; $this->SetLanguage(LEGACY_MAIL_LANG, XOOPS_ROOT_PATH . '/class/mail/phpmailer/language/'); $this->CharSet = LEGACY_MAIL_CHAR; $this->Encoding = LEGACY_MAIL_ENCO; switch ($xoopsMailerConfig['mailmethod']) { case 'smtpauth': $this->IsSMTP(); $this->SMTPAuth = true; $this->Host = implode(';', $xoopsMailerConfig['smtphost']); $this->Username = $xoopsMailerConfig['smtpuser']; $this->Password = $xoopsMailerConfig['smtppass']; break; case 'smtp': $this->IsSMTP(); $this->SMTPAuth = false; $this->Host = implode(';', $xoopsMailerConfig['smtphost']); break; case 'sendmail': $this->IsSendmail(); $this->Sendmail = $xoopsMailerConfig['sendmailpath']; break; } return true; }
public function render() { $module_handler =& xoops_gethandler('application'); $modules =& $module_handler->getObjects(new Criteria('hasmain', 1), true); $options = array('0' => _NOCACHE, '30' => sprintf(_SECONDS, 30), '60' => _MINUTE, '300' => sprintf(_MINUTES, 5), '1800' => sprintf(_MINUTES, 30), '3600' => _HOUR, '18000' => sprintf(_HOURS, 5), '86400' => _DAY, '259200' => sprintf(_DAYS, 3), '604800' => _WEEK); $rtn = "<table cellpadding='2' cellspacing='1' border='0'>"; if (count($modules) > 0) { foreach ($modules as $mod) { $rtn .= "<tr><td>" . $mod->getVar('name') . "</td><td>\n\t\t\t\t\t\t <select name='" . $this->getName() . "[" . $mod->getVar('mid') . "]' id='" . $this->getName() . "[" . $mod->getVar('mid') . "]'>"; foreach ($options as $k => $v) { $rtn .= "<option value='{$k}'"; $rtn .= isset($this->selected[$mod->getVar('mid')]) && $this->selected[$mod->getVar('mid')] == $k ? " selected='selected'" : ""; $rtn .= ">{$v}</option>"; } $rtn .= "</td></tr>"; /*$c_val = isset($currrent_val[$mid]) ? intval($currrent_val[$mid]) : null; $selform = new XoopsFormSelect($modules[$mid]->getVar('name'), $config[$i]->getVar('conf_name')."[$mid]", $c_val); $selform->addOptionArray($cache_options); $ele->addElement($selform); unset($selform);*/ } } else { $rtn .= "<tr><td>" . _AS_SYSPREF_NOMODS . "</td></tr>"; } $rtn .= "</table>"; return $rtn; }
function execute(&$controller, &$xoopsUser) { if (XCube_Root::getSingleton()->mContext->mRequest->getRequest('_form_control_cancel') != null) { return USER_FRAME_VIEW_CANCEL; } $memberHandler =& xoops_gethandler('member'); $this->mNewUser =& $memberHandler->createUser(); $this->mRegistForm->update($this->mNewUser); $this->mNewUser->set('uorder', $controller->mRoot->mContext->getXoopsConfig('com_order'), true); $this->mNewUser->set('umode', $controller->mRoot->mContext->getXoopsConfig('com_mode'), true); if ($this->mConfig['activation_type'] == 1) { $this->mNewUser->set('level', 1, true); } if (!$memberHandler->insertUser($this->mNewUser)) { $this->mRedirectMessage = _MD_USER_LANG_REGISTERNG; return USER_FRAME_VIEW_ERROR; } if (!$memberHandler->addUserToGroup(XOOPS_GROUP_USERS, $this->mNewUser->get('uid'))) { $this->mRedirectMessage = _MD_USER_LANG_REGISTERNG; return USER_FRAME_VIEW_ERROR; } $this->_clearRegistForm($controller); $this->_processMail($controller); $this->_eventNotifyMail($controller); XCube_DelegateUtils::call('Legacy.Event.RegistUser.Success', new XCube_Ref($this->mNewUser)); return USER_FRAME_VIEW_SUCCESS; }
function fetchSummary($external_link_id) { $myts =& MyTextsanitizer::getInstance(); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($this->mydirname); $config_handler =& xoops_gethandler('config'); $configs = $config_handler->getConfigList($module->mid()); // external_link_id means $content_id $content_id = intval($external_link_id); $mydirname = $this->mydirname; if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } // get categoryObject and contentObject list($categoryObj, $contentObj) = pico_common_get_objects_from_content_id($mydirname, $content_id); // existence check if (!is_object($categoryObj) || !is_object($contentObj)) { return ''; } // permission check $content_data = $contentObj->getData(); if (empty($content_data['can_read'])) { return ''; } // dare to convert it irregularly $summary = str_replace('&', '&', htmlspecialchars(xoops_substr(strip_tags($content_data['body_cached']), 0, 255), ENT_QUOTES)); return array('dirname' => $mydirname, 'module_name' => $module->getVar('name'), 'subject' => $myts->makeTboxData4Show($content_data['subject_raw'], 1, 1), 'uri' => XOOPS_URL . '/modules/' . $mydirname . '/' . pico_common_make_content_link4html($configs, $content_data), 'summary' => $summary); }
function articles_notify_iteminfo($category, $item_id) { global $xoopsModule, $xoopsModuleConfig, $xoopsConfig, $xoopsDB; if (empty($xoopsModule) || $xoopsModule->getVar('dirname') != 'articles') { $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname('articles'); $config_handler =& xoops_gethandler('config'); $config =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); } else { $module =& $xoopsModule; $config =& $xoopsModuleConfig; } if ($category == 'global') { $item['name'] = ''; $item['url'] = ''; return $item; } # if ($category=='story') { # // Assume we have a valid story id # $sql = 'SELECT title FROM '.$xoopsDB->prefix('stories') . ' WHERE storyid = ' . $item_id; # $result = $xoopsDB->query($sql); // TODO: error check # $result_array = $xoopsDB->fetchArray($result); # $item['name'] = $result_array['title']; # $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/article.php?storyid=' . $item_id; # return $item; # } }
function execute(&$controller, &$xoopsUser) { // // Fetch request and validate. // $this->mActionForm->fetch(); $this->mActionForm->validate(); // // If error, go to re-input. // if ($this->mActionForm->hasError()) { return PM_FRAME_VIEW_ERROR; } // // Delete PM // $handler =& xoops_gethandler('privmessage'); foreach ($this->mActionForm->getVar('msg_id') as $msg_id) { $pm =& $handler->get($msg_id); if (is_object($pm) && $pm->get('to_userid') == $xoopsUser->get('uid')) { $handler->delete($pm); } unset($pm); } return PM_FRAME_VIEW_SUCCESS; }
function safeAgent($useragent) { $part = explode('/', $useragent); foreach ($part as $key => $value) { if (strpos(strtolower($value), '.x')) { unset($part[$key]); } } $useragent = implode('/', $part); $ver_char = array('x.x', '*.*', 'X.X', 'x.xxx', 'x.y', 'xxx', 'xxxx', 'xxxxx', 'xxxxxx', 'vX.X.X', 'X.X.X', 'X.xx'); foreach ($ver_char as $vc) { if (strpos($useragent, $vc)) { $useragent = str_replace($vc, '', $useragent); } } $modulehandler =& xoops_gethandler('module'); $confighandler =& xoops_gethandler('config'); $xoModule = $modulehandler->getByDirname('spiders'); $xoConfig = $confighandler->getConfigList($xoModule->getVar('mid'), false); $reservedphrases = explode('|', $xoConfig['reserved_prases']); foreach ($reservedphrases as $id => $phrase) { $useragent = str_replace($phrase, '', $useragent); } return $useragent; }
function b_dbtheme_theme_hook_show($options) { $mydirname = empty($options[0]) ? 'dbtheme' : $options[0]; $tpl_name = empty($options[1]) ? $mydirname . '_theme.html' : $options[1]; if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } $tpl_name = preg_replace('/[^0-9a-zA-Z_.-]/', '', $tpl_name); /* if( ! file_exists( XOOPS_ROOT_PATH.'/class/smarty/plugins/resource.dbtheme.php' ) ) { $ret = array( 'content' => 'resource.dbtheme.php is not set properly' ) ; return $ret ; } */ if (defined('XOOPS_CUBE_LEGACY')) { // Cube Legacy @define('DBTHEME_THEME_NAME', $tpl_name); @define('DBTHEME_MYDIRNAME', $mydirname); } else { // X2.0.x $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($mydirname); $config_handler =& xoops_gethandler('config'); $mod_config =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); if (!empty($mod_config['base_theme'])) { $GLOBALS['xoopsTpl']->assign(array('xoops_theme' => $mod_config['base_theme'], 'xoops_imageurl' => XOOPS_THEME_URL . '/' . $mod_config['base_theme'] . '/', 'xoops_themecss' => XOOPS_URL . '/modules/' . $mydirname . '/?template=style.css', 'xoops_dbthemecssurl' => XOOPS_URL . '/modules/' . $mydirname . '/?template=')); } $obj_serialized = serialize($GLOBALS['xoopsTpl']); unset($GLOBALS['xoopsTpl']); $obj_serialized = preg_replace('/xoopstpl/i', 'dbthmtpl', substr($obj_serialized, 0, 20)) . substr($obj_serialized, 20); //var_dump( $obj_serialized ) ; $GLOBALS['xoopsTpl'] = unserialize($obj_serialized); //var_dump( get_class( $GLOBALS['xoopsTpl'] ) ) ; $GLOBALS['xoopsConfig']['theme_set'] = 'dbtheme:' . $tpl_name . "\n"; return array(); } }
function _doExecute() { if ($this->mActionForm->mFormFile != null) { if (!$this->mActionForm->mFormFile->saveAs(XOOPS_UPLOAD_PATH)) { return false; } if ($this->mActionForm->mOldFileName != null && $this->mActionForm->mOldFileName != "blank.gif") { @unlink(XOOPS_UPLOAD_PATH . "/" . $this->mActionForm->mOldFileName); // // Change user_avatar of all users who are setting this avatar. // if (!$this->mObject->isNew()) { $linkHandler =& xoops_getmodulehandler('avatar_user_link'); $criteria =new Criteria('avatar_id', $this->mObject->get('avatar_id')); $linkArr =& $linkHandler->getObjects($criteria); $userHandler =& xoops_gethandler('user'); foreach ($linkArr as $link) { $user =& $userHandler->get($link->get('user_id')); if (is_object($user)) { $user->set('user_avatar', $this->mObject->get('avatar_file')); $userHandler->insert($user); } unset($user); } } } } return parent::_doExecute(); }
function newbb_loadConfig() { global $xoopsModuleConfig; static $moduleConfig; if (isset($moduleConfig)) { return $moduleConfig; } if (isset($GLOBALS["xoopsModule"]) && is_object($GLOBALS["xoopsModule"]) && $GLOBALS["xoopsModule"]->getVar("dirname", "n") == "newbb") { if (!empty($GLOBALS["xoopsModuleConfig"])) { $moduleConfig = $GLOBALS["xoopsModuleConfig"]; } else { return null; } } else { $module_handler =& xoops_gethandler('module'); $module = $module_handler->getByDirname("newbb"); $config_handler =& xoops_gethandler('config'); $criteria = new CriteriaCompo(new Criteria('conf_modid', $module->getVar('mid'))); $configs = $config_handler->getConfigs($criteria); foreach (array_keys($configs) as $i) { $moduleConfig[$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput(); } unset($configs); } if ($customConfig = @(include XOOPS_ROOT_PATH . "/modules/newbb/include/plugin.php")) { $moduleConfig = array_merge($moduleConfig, $customConfig); } return $moduleConfig; }
/** * Constructor * * @param string $caption * @param string $name * @param mixed $value Pre-selected value (or array of them). * For an item with massive members, such as "Registered Users", "$value" should be used to store selected temporary users only instead of all members of that item * @param bool $include_anon Include user "anonymous"? * @param int $size Number or rows. "1" makes a drop-down-list. * @param bool $multiple Allow multiple selections? */ function __construct($caption, $name, $include_anon = false, $value = null, $size = 1, $multiple = false) { $limit = 200; $select_element = new Xmf_Form_Element_Select("", $name, $value, $size, $multiple); if ($include_anon) { $select_element->addOption(0, $GLOBALS["xoopsConfig"]['anonymous']); } $member_handler =& xoops_gethandler('member'); $user_count = $member_handler->getUserCount(); $value = is_array($value) ? $value : (empty($value) ? array() : array($value)); if ($user_count > $limit && count($value) > 0) { $criteria = new CriteriaCompo(new Criteria("uid", "(" . implode(",", $value) . ")", "IN")); } else { $criteria = new CriteriaCompo(); $criteria->setLimit($limit); } $criteria->setSort('uname'); $criteria->setOrder('ASC'); $users = $member_handler->getUserList($criteria); $select_element->addOptionArray($users); if ($user_count <= $limit) { parent::__construct($caption, "", $name); $this->addElement($select_element); return; } xoops_loadLanguage("findusers"); $js_addusers = "<script type=\"text/javascript\">\r\n function addusers(opts){\r\n var num = opts.substring(0, opts.indexOf(\":\"));\r\n opts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n var sel = xoopsGetElementById(\"" . $name . ($multiple ? "[]" : "") . "\");\r\n var arr = new Array(num);\r\n for (var n=0; n < num; n++) {\r\n var nm = opts.substring(0, opts.indexOf(\":\"));\r\n opts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n var val = opts.substring(0, opts.indexOf(\":\"));\r\n opts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n var txt = opts.substring(0, nm - val.length);\r\n opts = opts.substring(nm - val.length, opts.length);\r\n var added = false;\r\n for (var k = 0; k < sel.options.length; k++) {\r\n if(sel.options[k].value == val){\r\n added = true;\r\n break;\r\n }\r\n }\r\n if (added == false) {\r\n sel.options[k] = new Option(txt, val);\r\n sel.options[k].selected = true;\r\n }\r\n }\r\n return true;\r\n }\r\n </script>"; $token = $GLOBALS['xoopsSecurity']->createToken(); $action_tray = new Xmf_Form_Element_Tray("", " | "); $action_tray->addElement(new Xmf_Form_Element_Label('', "<a href='#' onclick='var sel = xoopsGetElementById(\"" . $name . ($multiple ? "[]" : "") . "\");for (var i = sel.options.length-1; i >= 0; i--) {if (!sel.options[i].selected) {sel.options[i] = null;}}; return false;'>" . _MA_USER_REMOVE . "</a>")); $action_tray->addElement(new Xmf_Form_Element_Label('', "<a href='#' onclick='openWithSelfMain(\"" . XOOPS_URL . "/include/findusers.php?target={$name}&multiple={$multiple}&token={$token}\", \"userselect\", 800, 600, null); return false;' >" . _MA_USER_MORE . "</a>" . $js_addusers)); parent::__construct($caption, "<br /><br />", $name); $this->addElement($select_element); $this->addElement($action_tray); }
public static function setupUser(&$principal, &$controller, &$context) { if (is_object($context->mXoopsUser)) { return; } if (!empty($_SESSION['xoopsUserId'])) { $memberHandler = xoops_gethandler('member'); $user =& $memberHandler->getUser($_SESSION['xoopsUserId']); $context->mXoopsUser =& $user; if (is_object($context->mXoopsUser)) { $context->mXoopsUser->setGroups($_SESSION['xoopsUserGroups']); $roles = array(); $roles[] = "Site.RegisteredUser"; if ($context->mXoopsUser->isAdmin(-1)) { $roles[] = "Site.Administrator"; } if (in_array(XOOPS_GROUP_ADMIN, $_SESSION['xoopsUserGroups'])) { $roles[] = "Site.Owner"; } $identity = new Legacy_Identity($context->mXoopsUser); $principal = new Legacy_GenericPrincipal($identity, $roles); return; } else { $context->mXoopsUser = null; $_SESSION = array(); } } $identity = new Legacy_AnonymousIdentity(); $principal = new Legacy_GenericPrincipal($identity, array("Site.GuestUser")); }
function getValidDirnames() { $ret = array(); $module_handler =& xoops_gethandler('module'); $modules = $module_handler->getList(null, true); if (!empty($this->trustdirname)) { foreach (array_keys($modules) as $mydirname) { $trustpath_file = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/mytrustdirname.php'; if (!file_exists($trustpath_file)) { continue; } $mytrustdirname = ''; require $trustpath_file; if ($mytrustdirname == $this->trustdirname) { $ret[] = $mydirname; } } } else { $dirname = strtolower(substr(get_class($this), strlen('D3pipesBlock'))); if (isset($modules[$dirname])) { $ret[] = $dirname; } } return $ret; }
function xpress_create_db_template($file_name, $file_path, $mydirname, $mid) { if (is_file($file_path)) { $tplfile_handler =& xoops_gethandler('tplfile'); $tplfile =& $tplfile_handler->create(); $mtime = intval(@filemtime($file_path)); $tplfile->setVar('tpl_source', file_get_contents($file_path), true); $tplfile->setVar('tpl_refid', $mid); $tplfile->setVar('tpl_tplset', 'default'); $tplfile->setVar('tpl_file', $file_name); $tplfile->setVar('tpl_desc', '', true); $tplfile->setVar('tpl_module', $mydirname); $tplfile->setVar('tpl_lastmodified', $mtime); $tplfile->setVar('tpl_lastimported', 0); $tplfile->setVar('tpl_type', 'module'); if (!$tplfile_handler->insert($tplfile)) { $msg = '<span style="color:#ff0000;">ERROR: Template Could not added to the database. <b>' . htmlspecialchars($file_name) . '</b> to the database.</span><br />'; } else { $tplid = $tplfile->getVar('tpl_id'); $msg = 'Template <b>' . htmlspecialchars($file_name) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)<br />'; // generate compiled file include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; include_once XOOPS_ROOT_PATH . '/class/template.php'; if (!xoops_template_touch($tplid)) { $msg = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>' . htmlspecialchars($file_name) . '</b>.</span><br />'; } else { $msg = 'Template <b>' . htmlspecialchars($file_name) . '</b> compiled.</span><br />'; } } } return $msg; }
protected function _registerAction() { $this->form->fetchInput()->validate(); if ($this->form->hasError() === true) { return; } $memberHandler =& xoops_gethandler('member'); $newUser =& $memberHandler->createUser(); $this->_update($newUser); try { $this->root->cms->database()->queryF('BEGIN'); if ($memberHandler->insertUser($newUser) == false) { throw new Exception(t('Database error 111')); } if ($memberHandler->addUserToGroup(XOOPS_GROUP_USERS, $newUser->get('uid')) == false) { throw new Exception(t('Database error 222')); } $providerUserLinkHandler = $this->root->getModelHandler('ProviderUserLink', 'social_media'); $result = $providerUserLinkHandler->addProviderUserLink($_SESSION['socialMediaType'], $_SESSION['socialMediaId'], $newUser->get('uid')); if ($result == false) { throw new Exception(t('Database error 333')); } $this->root->cms->database()->queryF('COMMIT'); unset($_SESSION['socialMediaType'], $_SESSION['socialMediaId']); $this->_registerSession($newUser); redirect_header(XOOPS_URL, 1, t('Thank you for your registeration. You now logged in.')); } catch (Exception $e) { $this->form->addError($e->getMessage()); $this->root->cms->database()->queryF('ROLLBACK'); } }
/** * @desc Envía correo de aprobación de publicación * @param Object $res Publicación **/ function mail_approved(RDResource &$res) { global $xoopsModuleConfig, $xoopsConfig; $config_handler =& xoops_gethandler('config'); $mconfig = $config_handler->getConfigsByCat(XOOPS_CONF_MAILER); $errors = ''; $user = new XoopsUser($res->getVar('owner')); $member_handler =& xoops_gethandler('member'); $method = $user->getVar('notify_method'); $mailer = new RMMailer('text/plain'); $mailer->add_xoops_users($user); $mailer->set_subject(sprintf(__('Publication <%s> approved!', 'docs'), $res->getVar('title'))); $mailer->assign('dear_user', $user->getVar('name') != '' ? $user->getVar('name') : $user->getVar('uname')); $mailer->assign('link_to_resource', $res->permalink()); $mailer->assign('site_name', $xoopsConfig['sitename']); $mailer->assign('resource_name', $res->getVar('title')); $mailer->template(RMTemplate::get()->get_template('mail/resource_approved.php', 'module', 'docs')); switch ($method) { case '1': $mailer->set_from_xuser($mconfig['fromuid']); $ret = $mailer->send_pm(); break; case '2': $ret = $mailer->send(); break; } $page = rmc_server_var($_POST, 'page', 1); return $ret; }
function _doExecute() { $linkHandler =& xoops_getmodulehandler('avatar_user_link'); $criteria = new Criteria('avatar_id', $this->mObject->get('avatar_id')); $linkArr =& $linkHandler->getObjects($criteria); if ($this->mObjectHandler->delete($this->mObject)) { // // Clear all user who set the avatar deleted with blank.gif // if (count($linkArr) > 0) { $userHandler =& xoops_gethandler('user'); foreach ($linkArr as $link) { $user =& $userHandler->get($link->get('user_id')); if (is_object($user)) { $user->set('user_avatar', 'blank.gif'); $userHandler->insert($user); } unset($user); } } return true; } else { return false; } }
function setupBlock() { $showFlag = 0; $mid = 0; if ($this->mController->mRoot->mContext->mModule != null) { $showFlag = preg_match("/index\\.php\$/i", xoops_getenv('PHP_SELF')) && $this->mController->mRoot->mContext->mXoopsConfig['startpage'] == $this->mController->mRoot->mContext->mXoopsModule->get('dirname'); $mid = $this->mController->mRoot->mContext->mXoopsModule->get('mid'); } else { // // If you does not have module_contoller, this request is to toppage or other pages of toppage. // // $mid = preg_match("/index\.php$/i", xoops_getenv('PHP_SELF')) ? -1 : 0; $pathArray = parse_url(!empty($_SERVER['PATH_INFO']) ? substr($_SERVER['PHP_SELF'], 0, -strlen($_SERVER['PATH_INFO'])) : $_SERVER['PHP_SELF']); $mid = preg_match("#(/index\\.php|/)\$#i", @$pathArray['path']) ? -1 : 0; } $blockHandler =& xoops_gethandler('block'); $showCenterFlag = SHOW_CENTERBLOCK_LEFT | SHOW_CENTERBLOCK_CENTER | SHOW_CENTERBLOCK_RIGHT; $showRightFlag = SHOW_SIDEBLOCK_RIGHT; $showFlag = SHOW_SIDEBLOCK_LEFT | $showRightFlag | $showCenterFlag; $groups = is_object($this->mController->mRoot->mContext->mXoopsUser) ? $this->mController->mRoot->mContext->mXoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; $blockObjects =& $blockHandler->getBlocks($groups, $mid, $showFlag); foreach ($blockObjects as $blockObject) { $block =& Legacy_Utils::createBlockProcedure($blockObject); if ($block->prepare() !== false) { $this->mController->_mBlockChain[] =& $block; } unset($block); unset($blockObject); } }
/** * constructor * * @param mixed $id **/ function XoopsBlock($id = null) { $this->initVar('bid', XOBJ_DTYPE_INT, null, false); $this->initVar('mid', XOBJ_DTYPE_INT, 0, false); $this->initVar('func_num', XOBJ_DTYPE_INT, 0, false); $this->initVar('options', XOBJ_DTYPE_TXTBOX, null, false, 255); $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, true, 150); //$this->initVar('position', XOBJ_DTYPE_INT, 0, false); $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false, 150); $this->initVar('content', XOBJ_DTYPE_TXTAREA, null, false); $this->initVar('side', XOBJ_DTYPE_INT, 0, false); $this->initVar('weight', XOBJ_DTYPE_INT, 0, false); $this->initVar('visible', XOBJ_DTYPE_INT, 0, false); $this->initVar('block_type', XOBJ_DTYPE_OTHER, null, false); $this->initVar('c_type', XOBJ_DTYPE_OTHER, null, false); $this->initVar('isactive', XOBJ_DTYPE_INT, null, false); $this->initVar('dirname', XOBJ_DTYPE_TXTBOX, null, false, 50); $this->initVar('func_file', XOBJ_DTYPE_TXTBOX, null, false, 50); $this->initVar('show_func', XOBJ_DTYPE_TXTBOX, null, false, 50); $this->initVar('edit_func', XOBJ_DTYPE_TXTBOX, null, false, 50); $this->initVar('template', XOBJ_DTYPE_OTHER, null, false); $this->initVar('bcachetime', XOBJ_DTYPE_INT, 0, false); $this->initVar('last_modified', XOBJ_DTYPE_INT, 0, false); // for backward compatibility if (isset($id)) { if (is_array($id)) { $this->assignVars($id); } else { $blkhandler =& xoops_gethandler('block'); $this =& $blkhandler->get($id); } } }
function art_load_config() { static $moduleConfig; if (isset($moduleConfig[$GLOBALS["artdirname"]])) { return $moduleConfig[$GLOBALS["artdirname"]]; } //load_functions("config"); //$moduleConfig[$GLOBALS["artdirname"]] = mod_loadConfig($GLOBALS["artdirname"]); if (isset($GLOBALS["xoopsModule"]) && is_object($GLOBALS["xoopsModule"]) && $GLOBALS["xoopsModule"]->getVar("dirname", "n") == $GLOBALS["artdirname"]) { if (!empty($GLOBALS["xoopsModuleConfig"])) { $moduleConfig[$GLOBALS["artdirname"]] =& $GLOBALS["xoopsModuleConfig"]; } else { return null; } } else { $module_handler =& xoops_gethandler('module'); $module = $module_handler->getByDirname($GLOBALS["artdirname"]); $config_handler =& xoops_gethandler('config'); $criteria = new CriteriaCompo(new Criteria('conf_modid', $module->getVar('mid'))); $configs =& $config_handler->getConfigs($criteria); foreach (array_keys($configs) as $i) { $moduleConfig[$GLOBALS["artdirname"]][$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput(); } unset($configs); } if ($customConfig = @(include XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/include/plugin.php")) { $moduleConfig[$GLOBALS["artdirname"]] = array_merge($moduleConfig[$GLOBALS["artdirname"]], $customConfig); } return $moduleConfig[$GLOBALS["artdirname"]]; }
/** * Function to check if a user is an administrator of the module * * @return bool */ function newbb_isAdministrator($user = -1, $mid = 0) { global $xoopsUser, $xoopsModule; if (is_numeric($user) && $user == -1) { $user =& $xoopsUser; } if (!is_object($user) && intval($user) < 1) { return false; } $uid = is_object($user) ? $user->getVar("uid") : intval($user); if (!$mid) { if (is_object($xoopsModule) && "newbb" == $xoopsModule->getVar("dirname", "n")) { $mid = $xoopsModule->getVar("mid", "n"); } else { $modhandler =& xoops_gethandler("module"); $newbb_module =& $modhandler->getByDirname("newbb"); $mid = $newbb_module->getVar("mid", "n"); unset($newbb_module); } } if (is_object($xoopsModule) && $mid == $xoopsModule->getVar("mid", "n") && is_object($xoopsUser) && $uid == $xoopsUser->getVar("uid", "n")) { return $GLOBALS["xoopsUserIsAdmin"]; } $member_handler =& xoops_gethandler('member'); $groups = $member_handler->getGroupsByUser($uid); $moduleperm_handler =& xoops_gethandler('groupperm'); return $moduleperm_handler->checkRight('module_admin', $mid, $groups); }