Empty commit

This commit is contained in:
Git 2012-01-25 08:00:20 +00:00
parent d07f2a1a67
commit 0c52e30873
7 changed files with 224 additions and 13 deletions

View File

@ -238,6 +238,7 @@ CREATE TABLE `forums` (
`LastPostAuthorID` int(10) NOT NULL DEFAULT '0',
`LastPostTopicID` int(10) NOT NULL DEFAULT '0',
`LastPostTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`AutoLock` enum('0','1') DEFAULT '1',
PRIMARY KEY (`ID`),
KEY `Sort` (`Sort`),
KEY `MinClassRead` (`MinClassRead`)
@ -714,6 +715,24 @@ CREATE TABLE `sphinx_requests_delta` (
KEY `LastVote` (`LastVote`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `staff_blog` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`UserID` int(10) unsigned NOT NULL,
`Title` varchar(255) NOT NULL,
`Body` text NOT NULL,
`Time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`ID`),
KEY `UserID` (`UserID`),
KEY `Time` (`Time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `staff_blog_visits` (
`UserID` int(10) unsigned NOT NULL,
`Time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
UNIQUE KEY `UserID` (`UserID`),
CONSTRAINT `staff_blog_visits_ibfk_1` FOREIGN KEY (`UserID`) REFERENCES `users_main` (`ID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `staff_pm_conversations` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`Subject` text,

View File

@ -47,7 +47,54 @@
</div>
<?
}
if (check_perms('users_mod')) {
?>
<div class="box">
<div class="head colhead_dark"><strong><a href="staffblog.php">Latest staff blog posts</a></strong></div>
<?
if(($Blog = $Cache->get_value('staff_blog')) === false) {
$DB->query("SELECT
b.ID,
um.Username,
b.Title,
b.Body,
b.Time
FROM staff_blog AS b LEFT JOIN users_main AS um ON b.UserID=um.ID
ORDER BY Time DESC
LIMIT 20");
$Blog = $DB->to_array();
$Cache->cache_value('staff_blog',$Blog,1209600);
}
if(($ReadTime = $Cache->get_value('staff_blog_read_'.$LoggedUser['ID'])) === false) {
$DB->query("SELECT Time FROM staff_blog_visits WHERE UserID = ".$LoggedUser['ID']);
if (list($ReadTime) = $DB->next_record()) {
$ReadTime = strtotime($ReadTime);
} else {
$ReadTime = 0;
}
$Cache->cache_value('staff_blog_read_'.$LoggedUser['ID'],$ReadTime,1209600);
}
?>
<ul class="stats nobullet">
<?
if(count($Blog) < 5) {
$Limit = count($Blog);
} else {
$Limit = 5;
}
for($i = 0; $i < $Limit; $i++) {
list($BlogID, $Author, $Title, $Body, $BlogTime, $ThreadID) = $Blog[$i];
?>
<li>
<?=($ReadTime < strtotime($BlogTime))?'<strong>':''?><?=($i + 1)?>. <a href="staffblog.php#blog<?=$BlogID?>"><?=$Title?></a><?=($ReadTime < strtotime($BlogTime))?'</strong>':''?>
</li>
<?
}
?>
</ul>
</div>
<? } ?>
<div class="box">
<div class="head colhead_dark"><strong><a href="blog.php">Latest blog posts</a></strong></div>
<?

View File

@ -600,13 +600,12 @@ function next_hour() {
//------------- Lock old threads ----------------------------------------//
sleep(10);
$DB->query("SELECT ID FROM forums_topics WHERE
IsLocked='0'
AND IsSticky='0'
AND LastPostTime<'".time_minus(3600*24*28)."'");
$DB->query("SELECT t.ID
FROM forums_topics AS t
JOIN forums AS f ON t.ForumID = f.ID
WHERE t.IsLocked='0' AND t.IsSticky='0'
AND t.LastPostTime<'".time_minus(3600*24*28)."'
AND f.AutoLock = '1'");
$IDs = $DB->collect('ID');
if(count($IDs) > 0) {

View File

@ -0,0 +1,134 @@
<?
enforce_login();
if(!check_perms('users_mod')) {
error(403);
}
define('ANNOUNCEMENT_FORUM_ID', 19);
show_header('Staff Blog','bbcode');
require(SERVER_ROOT.'/classes/class_text.php');
$Text = new TEXT;
if(check_perms('admin_manage_blog')) {
if(!empty($_REQUEST['action'])) {
switch($_REQUEST['action']) {
case 'takeeditblog':
authorize();
if (empty($_POST['title'])) {
error("Please enter a title.");
}
if(is_number($_POST['blogid'])) {
$DB->query("UPDATE staff_blog SET Title='".db_string($_POST['title'])."', Body='".db_string($_POST['body'])."' WHERE ID='".db_string($_POST['blogid'])."'");
$Cache->delete_value('staff_blog');
$Cache->delete_value('staff_feed_blog');
}
header('Location: staffblog.php');
break;
case 'editblog':
if(is_number($_GET['id'])){
$BlogID = $_GET['id'];
$DB->query("SELECT Title, Body FROM staff_blog WHERE ID=$BlogID");
list($Title, $Body, $ThreadID) = $DB->next_record();
}
break;
case 'deleteblog':
if(is_number($_GET['id'])){
authorize();
$DB->query("DELETE FROM staff_blog WHERE ID='".db_string($_GET['id'])."'");
$Cache->delete_value('staff_blog');
$Cache->delete_value('staff_feed_blog');
}
header('Location: staffblog.php');
break;
case 'takenewblog':
authorize();
if (empty($_POST['title'])) {
error("Please enter a title.");
}
$Title = db_string($_POST['title']);
$Body = db_string($_POST['body']);
$DB->query("INSERT INTO staff_blog (UserID, Title, Body, Time) VALUES ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', '".sqltime()."')");
$Cache->delete_value('staff_blog');
send_irc("PRIVMSG ".ADMIN_CHAN." :!blog " . $_POST['title']);
header('Location: staffblog.php');
break;
}
}
?>
<div class="box thin">
<div class="head">
<?=((empty($_GET['action'])) ? 'Create a staff blog post' : 'Edit staff blog post')?>
<span style="float:right;">
<a href="#" onclick="$('#postform').toggle(); this.innerHTML=(this.innerHTML=='(Hide)'?'(Show)':'(Hide)'); return false;"><?=($_REQUEST['action']!='editblog')?'(Show)':'(Hide)'?></a>
</span>
</div>
<form action="staffblog.php" method="post">
<div id="postform" class="pad<?=($_REQUEST['action']!='editblog')?' hidden':''?>">
<input type="hidden" name="action" value="<?=((empty($_GET['action'])) ? 'takenewblog' : 'takeeditblog')?>" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<? if(!empty($_GET['action']) && $_GET['action'] == 'editblog'){?>
<input type="hidden" name="blogid" value="<?=$BlogID; ?>" />
<? }?>
<h3>Title</h3>
<input type="text" name="title" size="95" <? if(!empty($Title)) { echo 'value="'.display_str($Title).'"'; } ?> /><br />
<h3>Body</h3>
<textarea name="body" cols="95" rows="15"><? if(!empty($Body)) { echo display_str($Body); } ?></textarea> <br />
<br /><br />
<div class="center">
<input type="submit" value="<?=((!isset($_GET['action'])) ? 'Create blog post' : 'Edit blog post') ?>" />
</div>
</div>
</form>
</div>
<br />
<?
}
?>
<div class="thin">
<?
if (!$Blog = $Cache->get_value('staff_blog')) {
$DB->query("SELECT
b.ID,
um.Username,
b.Title,
b.Body,
b.Time
FROM staff_blog AS b LEFT JOIN users_main AS um ON b.UserID=um.ID
ORDER BY Time DESC
LIMIT 20");
$Blog = $DB->to_array();
$Cache->cache_value('Blog',$Blog,1209600);
}
$DB->query("INSERT INTO staff_blog_visits (UserID, Time) VALUES (".$LoggedUser['ID'].", NOW()) ON DUPLICATE KEY UPDATE Time=NOW()");
$Cache->delete_value('staff_blog_read_'.$LoggedUser['ID']);
foreach ($Blog as $BlogItem) {
list($BlogID, $Author, $Title, $Body, $BlogTime) = $BlogItem;
?>
<div id="blog<?=$BlogID?>" class="box">
<div class="head">
<strong><?=$Title?></strong> - posted <?=time_diff($BlogTime);?> by <?=$Author?>
<? if(check_perms('admin_manage_blog')) { ?>
- <a href="staffblog.php?action=editblog&amp;id=<?=$BlogID?>">[Edit]</a>
<a href="staffblog.php?action=deleteblog&amp;id=<?=$BlogID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" onClick="return confirm('Do you want to delete this?')">[Delete]</a>
<? } ?>
</div>
<div class="pad">
<?=$Text->full_format($Body)?>
</div>
</div>
<br />
<?
}
?>
</div>
<?
show_footer();
?>

View File

@ -20,7 +20,7 @@
if($P['minclassread'] > $LoggedUser['Class'] || $P['minclasswrite'] > $LoggedUser['Class'] || $P['minclasscreate'] > $LoggedUser['Class']) {
error(403);
}
$P['autolock'] = isset($_POST['autolock'])?'1':'0';
if($_POST['submit'] == 'Edit'){ //Edit
if(!is_number($_POST['id']) || $_POST['id'] == ''){ error(0); }
@ -41,12 +41,13 @@
Description='$P[description]',
MinClassRead='$P[minclassread]',
MinClassWrite='$P[minclasswrite]',
MinClassCreate='$P[minclasscreate]'
MinClassCreate='$P[minclasscreate]',
AutoLock='$P[autolock]'
WHERE ID='$P[id]'");
} else { //Create
$DB->query("INSERT INTO forums
(Sort, CategoryID, Name, Description, MinClassRead, MinClassWrite, MinClassCreate) VALUES
('$P[sort]', '$P[categoryid]', '$P[name]','$P[description]','$P[minclassread]','$P[minclasswrite]','$P[minclasscreate]')");
(Sort, CategoryID, Name, Description, MinClassRead, MinClassWrite, MinClassCreate, AutoLock) VALUES
('$P[sort]', '$P[categoryid]', '$P[name]','$P[description]','$P[minclassread]','$P[minclasswrite]','$P[minclasscreate]','$P[autolock]')");
}
}

View File

@ -30,7 +30,8 @@ function class_list($Selected=0){
Description,
MinClassRead,
MinClassWrite,
MinClassCreate
MinClassCreate,
AutoLock
FROM forums
ORDER BY CategoryID, Sort ASC');
?>
@ -45,11 +46,12 @@ function class_list($Selected=0){
<td>Min class read</td>
<td>Min class write</td>
<td>Min class create</td>
<td>Autolock</td>
<td>Submit</td>
</tr>
<?
$Row = 'b';
while(list($ID, $CategoryID, $Sort, $Name, $Description, $MinClassRead, $MinClassWrite, $MinClassCreate) = $DB->next_record()){
while(list($ID, $CategoryID, $Sort, $Name, $Description, $MinClassRead, $MinClassWrite, $MinClassCreate, $AutoLock) = $DB->next_record()){
$Row = ($Row === 'a' ? 'b' : 'a');
?>
<tr class="row<?=$Row?>">
@ -90,6 +92,9 @@ function class_list($Selected=0){
<?=class_list($MinClassCreate)?>
</select>
</td>
<td>
<input type="checkbox" name="autolock" <?=($AutoLock == '1')?'checked ':''?>/>
</td>
<td>
<input type="submit" name="submit" value="Edit" />
<input type="submit" name="submit" value="Delete" />
@ -139,6 +144,9 @@ function class_list($Selected=0){
<?=class_list()?>
</select>
</td>
<td>
<input type="checkbox" name="autolock" checked />
</td>
<td>
<input type="submit" value="Create" />
</td>

3
staffblog.php Normal file
View File

@ -0,0 +1,3 @@
<?
define('ERROR_EXCEPTION', true);
require('classes/script_start.php');