2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
class ALIAS {
|
|
|
|
function convert($str) {
|
|
|
|
return trim(substr(preg_replace('/[^a-z0-9]/', '', strtolower(htmlentities($str))), 0, 50));
|
|
|
|
}
|
|
|
|
|
|
|
|
//Alternative approach with potential.
|
|
|
|
function flush() {
|
|
|
|
global $Cache, $DB;
|
2013-06-06 08:01:03 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT Alias, ArticleID
|
|
|
|
FROM wiki_aliases");
|
2011-03-28 14:21:28 +00:00
|
|
|
$Aliases = $DB->to_array('Alias');
|
2013-04-20 08:01:01 +00:00
|
|
|
$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
function to_id($Alias) {
|
|
|
|
global $Cache, $DB;
|
|
|
|
$Aliases = $Cache->get_value('wiki_aliases');
|
2013-04-20 08:01:01 +00:00
|
|
|
if (!$Aliases) {
|
2013-06-06 08:01:03 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT Alias, ArticleID
|
|
|
|
FROM wiki_aliases");
|
2011-03-28 14:21:28 +00:00
|
|
|
$Aliases = $DB->to_array('Alias');
|
2013-04-20 08:01:01 +00:00
|
|
|
$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
return $Aliases[$this->convert($Alias)]['ArticleID'];
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
function flush() {
|
|
|
|
|
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
function to_id($Alias) {
|
|
|
|
global $DB;
|
|
|
|
$Alias = $this->convert($Alias);
|
2013-06-06 08:01:03 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT ArticleID
|
|
|
|
FROM wiki_aliases
|
|
|
|
WHERE Alias LIKE '$Alias'");
|
2011-03-28 14:21:28 +00:00
|
|
|
list($ArticleID) = $DB->next_record();
|
|
|
|
return $ArticleID;
|
|
|
|
}
|
|
|
|
*/
|
2012-12-11 08:00:18 +00:00
|
|
|
function article($ArticleID, $Error = true) {
|
2011-03-28 14:21:28 +00:00
|
|
|
global $Cache, $DB;
|
|
|
|
$Contents = $Cache->get_value('wiki_article_'.$ArticleID);
|
2013-04-20 08:01:01 +00:00
|
|
|
if (!$Contents) {
|
|
|
|
$DB->query("
|
|
|
|
SELECT
|
2011-03-28 14:21:28 +00:00
|
|
|
w.Revision,
|
|
|
|
w.Title,
|
|
|
|
w.Body,
|
|
|
|
w.MinClassRead,
|
|
|
|
w.MinClassEdit,
|
|
|
|
w.Date,
|
|
|
|
w.Author,
|
|
|
|
u.Username,
|
|
|
|
GROUP_CONCAT(a.Alias),
|
|
|
|
GROUP_CONCAT(a.UserID)
|
2013-04-20 08:01:01 +00:00
|
|
|
FROM wiki_articles AS w
|
2011-03-28 14:21:28 +00:00
|
|
|
LEFT JOIN wiki_aliases AS a ON w.ID=a.ArticleID
|
|
|
|
LEFT JOIN users_main AS u ON u.ID=w.Author
|
2013-04-20 08:01:01 +00:00
|
|
|
WHERE w.ID='$ArticleID'
|
|
|
|
GROUP BY w.ID");
|
|
|
|
if (!$DB->record_count() && $Error) {
|
|
|
|
error(404);
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
$Contents = $DB->to_array();
|
2013-04-20 08:01:01 +00:00
|
|
|
$Cache->cache_value('wiki_article_'.$ArticleID, $Contents, 3600 * 24 * 14); // 2 weeks
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
return $Contents;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|