function motd_form($id)
{
    global $session;
    $subject = httppost('subject');
    $body = httppost('body');
    $preview = httppost('preview');
    if ($subject == "" || $body == "" || $preview > "") {
        $edit = translate_inline("Edit a MoTD");
        $add = translate_inline("Add a MoTD");
        $ret = translate_inline("Return");
        $row = array("motditem" => 0, "motdauthorname" => "", "motdtitle" => "", "motdbody" => "");
        if ($id > "") {
            $sql = "SELECT " . db_prefix("motd") . ".*,name AS motdauthorname FROM " . db_prefix("motd") . " LEFT JOIN " . db_prefix("accounts") . " ON " . db_prefix("accounts") . ".acctid = " . db_prefix("motd") . ".motdauthor WHERE motditem='{$id}'";
            $result = db_query($sql);
            if (db_num_rows($result) > 0) {
                $row = db_fetch_assoc($result);
                $msg = $edit;
            } else {
                $msg = $add;
            }
        } else {
            $msg = $add;
        }
        output_notl("`b%s`b", $msg);
        rawoutput("[ <a href='motd.php'>{$ret}</a> ]<br>");
        rawoutput("<form action='motd.php?op=add&id={$row['motditem']}' method='POST'>");
        addnav("", "motd.php?op=add&id={$row['motditem']}");
        if ($row['motdauthorname'] > "") {
            output("Originally by `@%s`0 on %s`n", $row['motdauthorname'], $row['motddate']);
        }
        if ($subject > "") {
            $row['motdtitle'] = stripslashes($subject);
        }
        if ($body > "") {
            $row['motdbody'] = stripslashes($body);
        }
        if ($preview > "") {
            if (httppost('changeauthor') || $row['motdauthorname'] == "") {
                $row['motdauthorname'] = $session['user']['name'];
            }
            if (httppost('changedate') || !isset($row['motddate']) || $row['motddate'] == "") {
                $row['motddate'] = date("Y-m-d H:i:s");
            }
            motditem($row['motdtitle'], $row['motdbody'], $row['motdauthorname'], $row['motddate'], "");
        }
        output("Subject: ");
        rawoutput("<input type='text' size='50' name='subject' value=\"" . HTMLEntities(stripslashes($row['motdtitle']), ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "\"><br/>");
        output("Body:`n");
        rawoutput("<textarea align='right' class='input' name='body' cols='37' rows='5'>" . HTMLEntities(stripslashes($row['motdbody']), ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "</textarea><br/>");
        if ($row['motditem'] > 0) {
            output("Options:`n");
            rawoutput("<input type='checkbox' value='1' name='changeauthor'" . (httppost('changeauthor') ? " checked" : "") . ">");
            output("Change Author`n");
            rawoutput("<input type='checkbox' value='1' name='changedate'" . (httppost('changedate') ? " checked" : "") . ">");
            output("Change Date (force popup again)`n");
        }
        $prev = translate_inline("Preview");
        $sub = translate_inline("Submit");
        rawoutput("<input type='submit' class='button' name='preview' value='{$prev}'> <input type='submit' class='button' value='{$sub}'></form>");
    } else {
        if ($id > "") {
            $sql = " SET motdtitle='{$subject}', motdbody='{$body}'";
            if (httppost('changeauthor')) {
                $sql .= ", motdauthor={$session['user']['acctid']}";
            }
            if (httppost('changedate')) {
                $sql .= ", motddate='" . date("Y-m-d H:i:s") . "'";
            }
            $sql = "UPDATE " . db_prefix("motd") . $sql . " WHERE motditem='{$id}'";
            db_query($sql);
            invalidatedatacache("motd");
            invalidatedatacache("lastmotd");
            invalidatedatacache("motddate");
        }
        if ($id == "" || db_affected_rows() == 0) {
            if ($id > "") {
                $sql = "SELECT * FROM " . db_prefix("motd") . " WHERE motditem='{$id}'";
                $result = db_query($sql);
                if (db_num_rows($result) > 0) {
                    $doinsert = false;
                } else {
                    $doinsert = true;
                }
            } else {
                $doinsert = true;
            }
            if ($doinsert) {
                $sql = "INSERT INTO " . db_prefix("motd") . " (motdtitle,motdbody,motddate,motdauthor) VALUES (\"{$subject}\",\"{$body}\",'" . date("Y-m-d H:i:s") . "','{$session['user']['acctid']}')";
                db_query($sql);
                invalidatedatacache("motd");
                invalidatedatacache("lastmotd");
                invalidatedatacache("motddate");
            }
        }
        header("Location: motd.php");
        exit;
    }
}
Пример #2
0
	output("`%");

	$sql = "SELECT * FROM motd ORDER BY motddate DESC limit 20";
	$result = db_query($sql);
	for ($i=0;$i<db_num_rows($result);$i++){
		$row = db_fetch_assoc($result);
		if ($row['motddate']>$session['user']['lastmotd'] || $i<5){
			if ($row['motdtype']==0){
				motditem($row[motdtitle].($session[user][superuser]>=3?"[<a href='motd.php?op=del&id=$row[motditem]' onClick=\"return confirm('Are you sure you want to delete this item?');\">Del</a>]":""),$row[motdbody]);
			}else{
				pollitem($row['motditem'],$row['motdtitle'].($session[user][superuser]>=3?"[<a href='motd.php?op=del&id=$row[motditem]' onClick=\"return confirm('Are you sure you want to delete this item?');\">Del</a>]":""),$row[motdbody]);
			}
		}
	}
	output("`&");
	motditem("Beta!","For those who might be unaware, this website is still in beta mode.  I'm working on it when I have time, which generally means a couple of changes a week.  Feel free to drop suggestions, I'm open to anything :-)");
	output("`@Commentary:`0`n");
	viewcommentary("motd");
}
/*
motditem("Spring Fashions","My lovely wife is in the process of updating the armor and weapons found in the local shoppes.  There will be a new set for each dragon kill, so you'll never wear the same armor or wield the same weapon twice!");
motditem("Dragon Points!","You probably already noticed by now, but there is a new system named Dragon Points.  These afford you another way to permanently increase  your character's abilities.  You gain one Dragon Point for each dragon slaying.");
motditem("Getting slain in the fields","There is a new drawback, and a new upside to getting attacked in the fields.  If you die in the fields when someone else attacked you, you lose 5% of your exp, along with your gold.  But if you are victorious when someone else attacks you, you get their gold, and 10% of THEIR exp.  When you attack others in the field has not changed, you can get 10% of your victim's exp and all their gold if you win, and you lose 15% of your exp, and all of your gold if you lose.  You cannot attack someone 2 levels below you any longer either, only 1 level below, and 2 levels above.");
motditem("New Days","New days should now occur automatically when the clock in the village reaches midnight.  Due to a bug on my part though, some accounts got goofed up.  Please email me at trash@mightye.org if you are not able to play the game, and I'll fix your account.");
*/

$session[needtoviewmotd]=false;

	$sql = "SELECT motddate FROM motd ORDER BY motditem DESC LIMIT 1";
	$result = db_query($sql);
	$row = db_fetch_assoc($result);
Пример #3
0
    motditem("Testing!", "Please see the testing message below.");
    output("`%");
    $sql = "SELECT * FROM motd ORDER BY motddate DESC limit 20";
    $result = db_query($sql);
    for ($i = 0; $i < db_num_rows($result); $i++) {
        $row = db_fetch_assoc($result);
        if ($row['motddate'] > $session['user']['lastmotd'] || $i < 5) {
            if ($row['motdtype'] == 0) {
                motditem($row['motdtitle'] . ($session['user']['superuser'] >= 3 ? "[<a href='motd.php?op=del&id=" . $row['motditem'] . "' onClick=\"return confirm('Are you sure you want to delete this item?');\">Del</a>]" : ""), $row['motdbody']);
            } else {
                pollitem($row['motditem'], $row['motdtitle'] . ($session['user']['superuser'] >= 3 ? "[<a href='motd.php?op=del&id=" . $row['motditem'] . "' onClick=\"return confirm('Are you sure you want to delete this item?');\">Del</a>]" : ""), $row['motdbody']);
            }
        }
    }
    output("`&");
    motditem("Testing!", "For those who might be unaware, this game is in testing.  We are working on it when we have time.  Feel free to drop suggestions, I'm open to anything :-)");
    output("`@Commentary:`0`n");
    viewcommentary("motd");
}
/*
motditem("Spring Fashions","My lovely wife is in the process of updating the armor and weapons found in the local shoppes.  There will be a new set for each dragon kill, so you'll never wear the same armor or wield the same weapon twice!");
motditem("Dragon Points!","You probably already noticed by now, but there is a new system named Dragon Points.  These afford you another way to permanently increase  your character's abilities.  You gain one Dragon Point for each dragon slaying.");
motditem("Getting slain in the fields","There is a new drawback, and a new upside to getting attacked in the fields.  If you die in the fields when someone else attacked you, you lose 5% of your exp, along with your gold.  But if you are victorious when someone else attacks you, you get their gold, and 10% of THEIR exp.  When you attack others in the field has not changed, you can get 10% of your victim's exp and all their gold if you win, and you lose 15% of your exp, and all of your gold if you lose.  You cannot attack someone 2 levels below you any longer either, only 1 level below, and 2 levels above.");
motditem("New Days","New days should now occur automatically when the clock in the village reaches midnight.  Due to a bug on my part though, some accounts got goofed up.  Please email me at trash@mightye.org if you are not able to play the game, and I'll fix your account.");
*/
$session['needtoviewmotd'] = false;
$sql = "SELECT motddate FROM motd ORDER BY motditem DESC LIMIT 1";
$result = db_query($sql);
$row = db_fetch_assoc($result);
$session['user']['lastmotd'] = $row['motddate'];
popup_footer();
page_header("LoGD News");
$date = date("D, M j, Y", $timestamp);
$pagestr = "";
if ($totaltoday > $newsperpage) {
    $pagestr = sprintf_translate("(Items %s - %s of %s)", $pageoffset + 1, min($pageoffset + $newsperpage, $totaltoday), $totaltoday);
}
$sql2 = "SELECT " . db_prefix("motd") . ".*,name AS motdauthorname FROM " . db_prefix("motd") . " LEFT JOIN " . db_prefix("accounts") . " ON " . db_prefix("accounts") . ".acctid = " . db_prefix("motd") . ".motdauthor ORDER BY motddate DESC LIMIT 1";
$result2 = db_query_cached($sql2, "lastmotd");
while ($row = db_fetch_assoc($result2)) {
    require_once "lib/motd.php";
    require_once "lib/nltoappon.php";
    if ($row['motdauthorname'] == "") {
        $row['motdauthorname'] = "`@Green Dragon Staff`0";
    }
    if ($row['motdtype'] == 0) {
        motditem($row['motdtitle'], $row['motdbody'], $row['motdauthorname'], $row['motddate'], "");
    } else {
        pollitem($row['motditem'], $row['motdtitle'], $row['motdbody'], $row['motdauthorname'], $row['motddate'], false);
    }
}
output_notl("`n");
output("`c`b`!News since the last new Game Day %s`0`b`c", $pagestr);
while ($row = db_fetch_assoc($result)) {
    output_notl("`c`2-=-`@=-=`2-=-`@=-=`2-=-`@=-=`2-=-`0`c");
    if ($session['user']['superuser'] & SU_EDIT_COMMENTS) {
        $del = translate_inline("Del");
        rawoutput("[ <a href='superuser.php?op=newsdelete&newsid=" . $row['newsid'] . "&return=" . URLEncode($_SERVER['REQUEST_URI']) . "'>{$del}</a> ]&nbsp;");
        addnav("", "superuser.php?op=newsdelete&newsid={$row['newsid']}&return=" . URLEncode($_SERVER['REQUEST_URI']));
    }
    tlschema($row['tlschema']);
    if ($row['arguments'] > "") {