function b_sitemap_xpwiki($mydirname) { global $sitemap_configs; (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); $ret = array(); include_once dirname(dirname(__FILE__)) . '/include.php'; $xpwiki =& XpWiki::getInitedSingleton($mydirname); $result = $xpwiki->func->get_existpages(FALSE, '', array('limit' => 5, 'order' => ' ORDER BY editedtime DESC', 'select' => array('title'), 'nolisting' => TRUE)); $ret = array(); // Recent Changes $show_cat = @$sitemap_configs['show_subcategoris'] ? 'child' : 'parent'; if ($show_cat === 'child') { $ret['id'] = 0; $ret['title'] = $xpwiki->root->_LANG['skin']['recent']; $ret['url'] = '?' . rawurlencode($xpwiki->root->whatsnew); } foreach ($result as $_res) { $pgid = $_res['pgid']; $page = $_res['name']; $title = $_res['title']; $title = $xpwiki->root->pagename_num2str ? preg_replace('/\\/(?:[0-9\\-]+|[B0-9][A-Z0-9]{9})$/', '/' . $xpwiki->func->get_heading($page), $page) : $page; $ret[$show_cat][] = array("id" => intval($pgid), "title" => $myts->makeTboxData4Show($title), "url" => $xpwiki->func->get_page_uri($page), 'image' => 2); } if ($show_cat === 'child') { $ret = array('parent' => array($ret)); } // Other menus $ret['parent'][] = array('id' => 0, 'title' => $xpwiki->root->_LANG['skin']['list'], 'url' => '?cmd=list'); $ret['parent'][] = array('id' => 0, 'title' => $xpwiki->root->_attach_messages['msg_list'], 'url' => '?plugin=attach&pcmd=list'); $ret['parent'][] = array('id' => 0, 'title' => $xpwiki->root->_LANG['skin']['help'], 'url' => '?Help'); return $ret; }
function reassign($data) { (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); $entries = array(); foreach ($data['entry'] as $item) { $ctime = preg_split("/[-: ]/", $item['create_time']); $yd_timestamp = mktime($ctime[3], $ctime[4], $ctime[5], $ctime[1], $ctime[2], $ctime[0]); $entry = array('pubtime' => $yd_timestamp, 'link' => $item['url'], 'headline' => $item['title'], 'description' => strip_tags($item['diary']), 'allow_html' => true); $entry['fingerprint'] = $entry['link']; $entries[] = $entry; } return $entries; }
function fetchSummary($pgid) { $db =& Database::getInstance(); (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextsanitizer::getInstance()); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($this->mydirname); $pgid = intval($pgid); $mydirname = $this->mydirname; if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } // query $data = $db->fetchArray($db->query("SELECT `name`, `title`, `editedtime` FROM " . $db->prefix($mydirname . "_pginfo") . " WHERE `pgid`={$pgid} LIMIT 1")); // get body $uri = $body = ''; if ($data['name'] !== '') { if (strpos(@$_SERVER['REQUEST_URI'], '/modules/' . $mydirname) === FALSE) { include_once dirname(dirname(__FILE__)) . "/include.php"; $page =& XpWiki::getSingleton($mydirname); if ($data['editedtime']) { $page->init($data['name']); $page->execute(); $body = $page->body; } else { $body = _MD_D3FORUM_ERR_READPOST . " \n" . '"' . $data['name'] . '" is deleted.'; } $uri = $page->func->get_page_uri($data['name'], true); } } else { $body = _MD_D3FORUM_ERR_READPOST; } // make subject $subject = $data['name']; if ($subject !== $data['title']) { $subject .= ' [ ' . $data['title'] . ' ]'; } return array('dirname' => $mydirname, 'module_name' => $module->getVar('name'), 'subject' => $myts->makeTboxData4Show($subject), 'uri' => $uri, 'summary' => xoops_substr(strip_tags($body), 0, 255)); }
public function __construct($mydirname, $req_uid = 0, $caller = "") { global $xoopsUser, $xoopsConfig; $this->start_time = (int) (microtime(true) * 1000); $this->db =& Database::getInstance(); $this->mydirname = $mydirname; $this->caller = $caller; if (is_object(@$xoopsUser)) { $this->uid = intval($xoopsUser->getVar('uid')); $this->uname = $xoopsUser->getVar('uname'); $this->name = $xoopsUser->getVar('name'); } else { $this->uid = 0; $this->uname = ""; $this->name = ""; } $this->req_uid = (int) $req_uid > 0 ? (int) $req_uid : ((int) $this->getpost_param("req_uid") ? (int) $this->getpost_param("req_uid") : 0); // ((int)$this->getpost_param("req_uid") ? (int)$this->getpost_param("req_uid") : $this->uid ) ; // !! Must not do this //var_dump($this->mydirname); var_dump($this->req_uid); var_dump($this->uid); var_dump($caller); echo "<br />"; // module ID $module_handler =& xoops_gethandler('module'); $this_module =& $module_handler->getByDirname($this->mydirname); if (is_object($this_module)) { $this->mid = (int) $this_module->getVar('mid'); $this->module_name = $this_module->getVar('name'); // module config $config_handler =& xoops_gethandler("config"); $this->mod_config = $config_handler->getConfigsByCat(0, $this->mid); } // is_main $constpref = "_MB_" . strtoupper($this->mydirname); if (defined("_MD_W_SUN")) { $this->is_main = true; } elseif (!defined($constpref . "_W_SUN")) { $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php'; if (!file_exists($langmanpath)) { die('install the latest altsys'); } require_once $langmanpath; $langman =& D3LanguageManager::getInstance(); $mytrustdirname = basename(dirname(dirname(__FILE__))); $langman->read('blocks_each.php', $this->mydirname, $mytrustdirname, false); } if (XOOPS_USE_MULTIBYTES == 1) { // mbstring emulator if (!extension_loaded('mbstring') && !class_exists('HypMBString')) { if (file_exists(XOOPS_TRUST_PATH . '/class/hyp_common/mbemulator/mb-emulator.php')) { require_once XOOPS_TRUST_PATH . '/class/hyp_common/mbemulator/mb-emulator.php'; } } // rss feed encoding from switch ($this->mod_config['enc_from']) { case 'xoops_charset': $this->enc_from = _CHARSET; break; case 'auto': $this->enc_from = "auto"; break; case 'default': default: // null } } $this->params['uploaddir_abs'] = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/upimg/'; // photo upload dir $this->params['previewdir'] = 'prev/'; // photo preview dir $this->params['cachedir'] = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/cache/'; // photo cache dir //if( $caller != "xoops_uname" ) { $_year = $this->getpost_param('year'); $_month = $this->getpost_param('month'); $this->set_month($_year, $_month); // permission_class (read ef class and create the object) $perm_class = empty($this->mod_config['permission_class']) ? 'd3diaryPermission' : preg_replace('/[^0-9a-zA-Z_]/', '', $this->mod_config['permission_class']); (method_exists('MyTextSanitizer', 'sGetInstance') and $this->myts =& MyTextSanitizer::sGetInstance()) || ($this->myts =& MyTextSanitizer::getInstance()); require_once dirname(__FILE__) . '/' . $perm_class . '.class.php'; require_once dirname(__FILE__) . '/groupperm.class.php'; require_once dirname(__FILE__) . '/func.class.php'; include_once dirname(__FILE__) . '/diaryconfig.class.php'; require_once dirname(__FILE__) . '/sanitizer.class.php'; $this->mPerm = new $perm_class($this); $this->gPerm = new D3dGperm($this); $this->func = new D3diaryFunc($this); // needs req_uid $this->mPerm->ini_set(); $this->gPerm->ini_set(); $this->func->ini_set(); // get personal config for req_uid $this->dcfg = new DiaryConfig(); $this->dcfg->uid = $this->req_uid; $this->dcfg->readdb($this->mydirname); // sanitizer class for input validation vulnerabilities $this->sani = new D3diarySanitizer(); // mail post class if ($this->caller == "mailpost" || $this->caller == "index") { require_once dirname(__FILE__) . '/mailpost.class.php'; $this->mPost = new D3diaryMailPost($this); $this->mPost->ini_set(); } $this->debug_appendtime('d3dConf_construct'); //} $this->page = $this->func->htmlspecialchars($this->func->getpost_param('page')); $this->q_mode = $this->func->htmlspecialchars($this->func->getpost_param('mode')); $this->q_cid = (int) $this->func->getpost_param('cid'); $this->q_tag_noquote = rawurldecode($this->func->getpost_param('tag_name')); $this->q_tag = $this->func->htmlspecialchars($this->q_tag_noquote); $this->q_year = (int) $this->func->getpost_param('year'); $this->q_month = (int) $this->func->getpost_param('month'); $this->q_day = (int) $this->func->getpost_param('day'); $this->q_odr = $this->func->htmlspecialchars($this->func->getpost_param('odr')); $this->q_fr = (int) $this->func->getpost_param('fr'); $this->q_multidel = (int) $this->func->getpost_param('multidel'); // create url for sort and common links $this->urluppr = XOOPS_URL . '/modules/' . $this->mydirname . '/index.php?'; $this->urlbase_dlst = "page=diarylist"; $this->urlbase_exph = ""; if (strcmp($this->page, "photolist") == 0) { if ($this->req_uid > 0) { $this->urlbase = "page=photolist&req_uid=" . $this->req_uid; $this->urlbase_exph = "req_uid=" . $this->req_uid; } else { $this->urlbase = "page=photolist"; $this->urlbase_exph = "page=diarylist"; } } else { if ($this->req_uid > 0) { $this->urlbase = "req_uid=" . $this->req_uid; } else { $this->urlbase = "page=diarylist"; } if ($this->q_multidel > 0) { $this->urlbase .= "&multidel=1"; } } $this->urlbase_exfr = $this->urlbase; // exclude category if (strcmp($this->q_mode, "category") == 0) { $this->url4_all = "&mode=category&cid=" . $this->q_cid; } // exclude friend $this->url4ex_fr = $this->url4_all; if ($this->q_fr > 0 && $this->req_uid > 0) { $this->url4_all .= "&fr=1"; $this->url4ex_cat .= $_tmp_para; } // exclude date $this->url4ex_date = $this->url4_all; if ($this->q_day > 0) { $_tmp_para = "&year=" . $this->q_year . "&month=" . $this->q_month . "&day=" . $this->q_day; $this->url4_all .= $_tmp_para; $this->url4ex_cat .= $_tmp_para; $this->url4ex_fr .= $_tmp_para; } elseif ($this->q_month > 0) { $_tmp_para = "&year=" . $this->q_year . "&month=" . $this->q_month; $this->url4_all .= $_tmp_para; $this->url4ex_cat .= $_tmp_para; $this->url4ex_fr .= $_tmp_para; } // exclude tag $this->url4ex_tag = $this->url4_all; if (!empty($this->q_tag)) { $_tmp_para = "&tag_name=" . $this->q_tag; $this->url4_all .= $_tmp_para; $this->url4ex_date .= $_tmp_para; $this->url4ex_cat .= $_tmp_para; $this->url4ex_fr .= $_tmp_para; } // exclude order $this->url4ex_odr = $this->url4_all; if (!empty($this->q_odr)) { $_tmp_para = "&odr=" . $this->q_odr; $this->url4_all .= $_tmp_para; $this->url4ex_date .= $_tmp_para; $this->url4ex_cat .= $_tmp_para; $this->url4ex_fr .= $_tmp_para; $this->url4ex_tag .= $_tmp_para; } $this->url4ex_ph .= $this->url4_all; $this->style_s['time_dsc'] = $this->style_s['title_dsc'] = $this->style_s['name_dsc'] = $this->style_s['count_dsc'] = $this->style_s['hit_dsc'] = "d3dSortDsc"; $this->style_s['time_asc'] = $this->style_s['title_asc'] = $this->style_s['name_asc'] = $this->style_s['count_asc'] = $this->style_s['hit_asc'] = "d3dSortAsc"; switch ($this->q_odr) { case "time_asc": $this->style_s['time_asc'] = "d3dSortAsc_s"; break; case "title_dsc": $this->style_s['title_dsc'] = "d3dSortDsc_s"; break; case "title_asc": $this->style_s['title_asc'] = "d3dSortAsc_s"; break; case "name_dsc": $this->style_s['name_dsc'] = "d3dSortDsc_s"; break; case "name_asc": $this->style_s['name_asc'] = "d3dSortAsc_s"; break; case "count_dsc": $this->style_s['count_dsc'] = "d3dSortDsc_s"; break; case "count_asc": $this->style_s['count_asc'] = "d3dSortAsc_s"; break; case "hit_dsc": $this->style_s['hit_dsc'] = "d3dSortDsc_s"; break; case "hit_asc": $this->style_s['hit_asc'] = "d3dSortAsc_s"; break; case "time_dsc": default: $this->style_s['time_dsc'] = "d3dSortDsc_s"; break; } $this->debug_mode = $xoopsConfig['debug_mode']; // for debugging $this->server_TZ = (int) $xoopsConfig['server_TZ']; }
} else { // no custom session cookie set, destroy session if any $_SESSION = array(); //session_destroy(); } @ini_set('session.gc_maxlifetime', $xoopsConfig['session_expire'] * 60); @ini_set('session.cookie_lifetime', $xoopsConfig['session_expire'] * 60); } 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(); // autologin hack GIJ if ($xoopsConfig['autologin'] && empty($_SESSION['xoopsUserId']) && isset($_COOKIE['autologin_uname']) && isset($_COOKIE['autologin_pass'])) { if (!empty($_POST)) { redirect_header(XOOPS_URL . '/', 0, _RETRYPOST); } (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); $uname = $myts->stripSlashesGPC($_COOKIE['autologin_uname']); $pass = $myts->stripSlashesGPC($_COOKIE['autologin_pass']); if (empty($uname) || is_numeric($pass)) { $user = false; } else { // V3 $uname4sql = addslashes($uname); $criteria = new CriteriaCompo(new Criteria('uname', $uname4sql)); $user_handler =& xoops_gethandler('user'); $users =& $user_handler->getObjects($criteria, false); if (empty($users) || count($users) != 1) { $user = false; } else { // V3.1 begin $user = $users[0];
function hypconfShowForm($config) { global $constpref, $mydirname, $mydirpath, $mytrustdirpath, $page, $xoopsConfig, $xoopsGTicket; if (!$config) { die('no configs'); } if (isset($config['error'])) { echo '<div class="error">' . join('</div><div class="error">', $config['error']) . '</div>'; unset($config['error']); } if (isset($config['contents'])) { echo $config['contents']; unset($config['contents']); } $underContents = ''; if (isset($config['underContents'])) { $underContents = $config['underContents']; unset($config['underContents']); } if ($config) { $count = count($config); include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; include_once dirname(dirname(__FILE__)) . '/class/formcheckbox.php'; if (!XC_CLASS_EXISTS('XoopsFormBreak')) { include_once dirname(dirname(__FILE__)) . '/class/formbreak.php'; } $form = new XoopsThemeForm(hypconf_constant($constpref . '_ADMENU_' . strtoupper($page)), 'pref_form', 'index.php'); $button_tray = new XoopsFormElementTray(""); for ($i = 0; $i < $count; $i++) { $description = defined($config[$i]['description']) ? constant($config[$i]['description']) : ''; //$title4tray = (!$description) ? hypconf_constant($config[$i]['title']) : hypconf_constant($config[$i]['title']).'<br /><br /><span style="font-weight:normal;">'.hypconf_constant($config[$i]['description']).'</span>'; // GIJ $title4tray = hypconf_constant($config[$i]['title']); $title = ''; // GIJ switch ($config[$i]['formtype']) { case 'textarea': (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); if ($config[$i]['valuetype'] == 'array') { // this is exceptional.. only when value type is arrayneed a smarter way for this $ele = $config[$i]['value'] != '' ? new XoopsFormTextArea($title, $config[$i]['name'], $myts->htmlspecialchars(implode('|', $config[$i]['value'], _CHARSET)), 5, 50) : new XoopsFormTextArea($title, $config[$i]['name'], '', 5, 50); } else { $ele = new XoopsFormTextArea($title, $config[$i]['name'], $myts->htmlspecialchars($config[$i]['value'], ENT_COMPAT, _CHARSET), 5, 50); $ele->setExtra('class="norich plain" spellcheck="false"'); } break; case 'select': $size = 1; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } $ele = new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value'], $size); $options = $config[$i]['options']; $opcount = count($options); //var_dump($options); foreach ($options as $option) { if (isset($option['confop_value']) && isset($option['confop_name'])) { $optval = defined($option['confop_value']) ? constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? constant($option['confop_name']) : $option['confop_name']; } else { $optval = $optkey = $option; } $ele->addOption($optval, $optkey); } break; case 'select_multi': $size = 5; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } $ele = new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value'], $size, true); $options = $config[$i]['options']; foreach ($options as $option) { $optval = defined($option['confop_value']) ? constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? constant($option['confop_name']) : $option['confop_name']; $ele->addOption($optval, $optkey); } break; case 'check': $ele = new HypconfFormCheckBox($title, $config[$i]['name'], $config[$i]['value']); if (!empty($config[$i]['width'])) { //$ele->setWidth($config[$i]['width']); } $options = $config[$i]['options']; foreach ($options as $option) { $optval = defined($option['confop_value']) ? hypconf_constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? hypconf_constant($option['confop_name']) : $option['confop_name']; $ele->addOption($optval, $optkey); } break; case 'radio': $ele = new XoopsFormRadio($title, $config[$i]['name'], $config[$i]['value']); if (!empty($config[$i]['width'])) { //$ele->setWidth($config[$i]['width']); } $options = $config[$i]['options']; foreach ($options as $option) { $optval = defined($option['confop_value']) ? hypconf_constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? hypconf_constant($option['confop_name']) : $option['confop_name']; $ele->addOption($optval, $optkey); } break; case 'yesno': $ele = new XoopsFormRadioYN($title, $config[$i]['name'], $config[$i]['value'], _YES, _NO); break; case 'password': $size = 50; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); $ele = new XoopsFormPassword($title, $config[$i]['name'], $size, 255, $myts->htmlspecialchars($config[$i]['value'], ENT_COMPAT, _CHARSET)); break; case 'label': $ele = new XoopsFormLabel($title, $description); $description = ''; break; case 'theme': case 'theme_multi': $ele = $config[$i]['formtype'] !== 'theme_multi' ? new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value']) : new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value'], 5, true); $handle = opendir(XOOPS_THEME_PATH . '/'); $dirlist = array(); while (false !== ($file = readdir($handle))) { if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^\\..*\$/", $file) && strtolower($file) != 'cvs') { $dirlist[$file] = $file; } } closedir($handle); $ele->addOption('', hypconf_constant($constpref . '_NOT_SPECIFY')); if (!empty($dirlist)) { asort($dirlist); $ele->addOptionArray($dirlist); } break; case 'tplset': $ele = new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value']); $tplset_handler =& xoops_gethandler('tplset'); $tplsetlist =& $tplset_handler->getList(); asort($tplsetlist); $ele->addOption('', hypconf_constant($constpref . '_NOT_SPECIFY')); foreach ($tplsetlist as $key => $name) { $ele->addOption($key, htmlspecialchars($name, ENT_QUOTES, _CHARSET)); } break; case 'textbox': default: $size = 50; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); $ele = new XoopsFormText($title, $config[$i]['name'], $size, 255, $myts->htmlspecialchars($config[$i]['value'], ENT_COMPAT, _CHARSET)); if ($config[$i]['valuetype'] === 'int') { $ele->setExtra(' style="text-align:right;"'); } break; } $ele_tray = new XoopsFormElementTray($title4tray, ''); $ele_tray->addElement($ele); $form->addElement($ele_tray); if ($description) { $form->insertBreak('<span style="font-weight:normal;">' . $description . '</span>', 'odd'); } unset($ele_tray); unset($ele); } $button_tray->addElement(new XoopsFormHidden('op', 'save')); $button_tray->addElement(new XoopsFormHidden('page', $page)); $xoopsGTicket->addTicketXoopsFormElement($button_tray, __LINE__, 1800, 'hypconf'); $button_tray->addElement(new XoopsFormButton('', 'button', _GO, 'submit')); $form->addElement($button_tray); $form->display(); } if ($underContents) { echo '<div>' . $underContents . '</div>'; } }