function get_rc_blogs($date, $pages = array()) { global $DBInfo; $blogs = array(); $changecache = new Cache_text('blogchanges', array('hash' => '')); $files = array(); $changecache->_caches($files); if (!$date) { $date = Blog_cache::get_daterule(); } if (!$pages) { $pagerule = '.*'; } else { $pages = array_map('_preg_search_escape', $pages); $pagerule = implode('|', $pages); } $rule = "@^({$date}\\d*)\\.({$pagerule})\$@"; foreach ($files as $file) { $pagename = $DBInfo->keyToPagename($file); if (preg_match($rule, $pagename, $match)) { $blogs[] = $match[2]; } } return array_unique($blogs); }
function deletePage($page, $options = '') { if (empty($options['.force']) && !$this->_isWritable($page->name)) { return -1; } if (!empty($this->use_x_forwarded_for)) { $REMOTE_ADDR = get_log_addr(); } else { $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; } $comment = $options['comment']; $user =& $this->user; $action = 'DELETE'; if (!empty($options['.revoke'])) { $action = 'REVOKE'; } // check abusing FIXME if (!empty($this->use_abusefilter)) { $params = array(); $params['retval'] =& $options['retval']; $params['id'] = $user->id == 'Anonymous' ? $REMOTE_ADDR : $user->id; if (is_string($this->use_abusefilter)) { $filtername = $this->use_abusefilter; } else { $filtername = 'default'; } $ret = call_abusefilter($filtername, 'delete', $params); if ($ret === false) { return -1; } } $comment = trim($comment); $comment = strtr(strip_tags($options['comment']), array("\r\n" => ' ', "\r" => ' ', "\n" => ' ', "\t" => ' ')); // strip out all action flags FIXME $comment = preg_replace('@^{(SAVE|CREATE|DELETE|RENAME|REVERT|UPLOAD|ATTDRW|FORK|REVOKE|MINOR|BOTFIX)}:?@', '', $comment); $tag = '{' . $action . '}'; if (!empty($comment)) { $comment = $tag . ': ' . $comment; } else { $comment = $tag; } $keyname = $this->_getPageKey($page->name); $deleted = false; if (file_exists($this->text_dir . '/' . $keyname)) { $deleted = @unlink($this->text_dir . '/' . $keyname); // fail to delete if (!$deleted) { return -1; } } if (!empty($this->version_class)) { $version = $this->lazyLoad('version', $this); if ($deleted && !empty($this->log_deletion)) { // make a empty file to log deletion touch($this->text_dir . '/' . $keyname); $log = $REMOTE_ADDR . ';;' . $user->id . ';;' . $comment; $ret = $version->ci($page->name, $log, true); // force } // delete history if (!empty($this->delete_history) && in_array($options['id'], $this->owners) && !empty($options['history'])) { $version->delete($page->name); } // delete the empty file again if ($deleted) { @unlink($this->text_dir . '/' . $keyname); } } // history deletion case by owners if (!$deleted) { return 0; } if (empty($options['.nolog'])) { $this->addLogEntry($page->name, $REMOTE_ADDR, $comment, $action); } $indexer = $this->lazyLoad('titleindexer'); $indexer->deletePage($page->name); // remove pagelinks and backlinks store_pagelinks($page->name, array()); // remove aliases if (!empty($this->use_alias)) { store_aliases($page->name, array()); } // remove redirects update_redirects($page->name, null); $handle = opendir($this->cache_dir); $permanents = array('backlinks', 'keywords', 'aliases', 'wordindex', 'redirect'); while ($file = readdir($handle)) { if ($file[0] != '.' and is_dir("{$this->cache_dir}/{$file}") and is_file($this->cache_dir . '/' . $file . '/.info')) { // do not delete permanent caches if (in_array($file, $permanents)) { continue; } $cache = new Cache_text($file); $cache->remove($page->name); # blog cache if ($file == 'blogchanges') { $files = array(); $cache->_caches($files, array('prefix' => 1)); foreach ($files as $file) { #echo $keyname.';'.$fcache."\n"; if (preg_match("/\\d+_2e{$keyname}\$/", $file)) { unlink($this->cache_dir . '/' . $file); } } } # for blog cache } } return 0; }