=====Regexpindex Action===== >>==See also:== - Documentation: RegexpindexActionInfo ==works with:== - Wikka 1.1.6.2 to 1.1.6.5 >>//NOT included in any Wikka version//{{lastedit show="3"}} This is the development page for the Regexpindex action. ===Installation=== - Save the first code block below as ##actions/regexpindex.php## - Give it the same file permissions as the other php files in that directory === Code === <<##actions/regexpindex.php##<< %%(php)'. $msg .'
'); } } $output = ''; if ( (isset($vars['opts']) && (!preg_match("/^[ot]{1,2}$/i", $vars['opts'])) ) || ( !isset($vars['re']) ) || ( isset($vars['re']) && (preg_match("/^\s*$/i", $vars['re'])) ) || ( isset($vars['cat']) && (preg_match("/^\s*$/i", $vars['cat'])) ) || ( isset($vars['sort']) && (!preg_match("/^(time|tag|rtime)$/i", $vars['sort'])) ) ) { $output .= RIerror(sprintf(RI_ERROR_REQUEST_FORMAT, RI_ERROR_USAGE)); } else { $display_title = isset($vars['opts']) && preg_match('/t/i', $vars['opts']); $display_owner = isset($vars['opts']) && preg_match('/o/i', $vars['opts']); $cached_username = $this->GetUserName(); $orderby = isset($vars['sort']) ? (strtolower($vars['sort'])=='rtime' ? 'time DESC' : strtolower($vars['sort'])) : 'tag'; $wherecat = isset($vars['cat']) ? ' AND (body REGEXP \''. mysql_real_escape_string($vars['cat']) .'\')' : ''; $query = 'SELECT body, tag, owner FROM '. $this->config['table_prefix'] .'pages WHERE ((latest = \'Y\') AND (CAST(tag AS BINARY) REGEXP \''. mysql_real_escape_string($vars['re']) .'\')'. $wherecat .') ORDER BY '. $orderby; $pages = $this->LoadAll($query); foreach ($pages as $page) { if ($this->HasAccess('read', $page['tag'])) { $output .= $this->Link($page['tag']); if ($display_title) { // display page title; this code is taken from PageTitle() function in Wakka.class.php $title = ''; $pagecontent = $page['body']; if (ereg( "(=){3,5}([^=\n]+)(=){3,5}", $pagecontent, $title)) { $formatting_tags = array('**', '//', '__', '##', '""', '++', '#%', '@@', '\'\''); $title = str_replace($formatting_tags, '', $title[2]); } $output .= ($title ? ': '. strip_tags($this->Format($title)) : ''.RI_NO_TITLE.''); } if ($display_owner) { // display page owner, or '*' if current user is the page owner $page_owner = $page['owner']; if ($cached_username == $page_owner) { $output .= '*'; } elseif ($page_owner != '(Public)' && $page_owner != '') { $output .= sprintf(RI_PAGE_OWNER, $page_owner); } } $output .= "
\n"; } } } echo ($output ? $output : RI_ERROR_NO_PAGES_FOUND); ?> %% ---- CategoryUserContributions