Initial commit
This commit is contained in:
15
lotgd-web/lotgd/lib/newday/dbcleanup.php
Executable file
15
lotgd-web/lotgd/lib/newday/dbcleanup.php
Executable file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
//db cleanup
|
||||
savesetting("lastdboptimize",date("Y-m-d H:i:s"));
|
||||
$result = db_query("SHOW TABLES");
|
||||
$tables = array();
|
||||
$start = getmicrotime();
|
||||
for ($i=0;$i<db_num_rows($result);$i++){
|
||||
list($key,$val)=each(db_fetch_assoc($result));
|
||||
db_query("OPTIMIZE TABLE $val");
|
||||
array_push($tables,$val);
|
||||
}
|
||||
$time = round(getmicrotime() - $start,2);
|
||||
require_once("lib/gamelog.php");
|
||||
gamelog("Optimized tables: ".join(", ",$tables)." in $time seconds.","maintenance");
|
||||
?>
|
27
lotgd-web/lotgd/lib/newday/dp_recalc.php
Executable file
27
lotgd-web/lotgd/lib/newday/dp_recalc.php
Executable file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
reset($labels);
|
||||
$pdktotal = 0;
|
||||
$pdkneg = false;
|
||||
modulehook("pdkpointrecalc");
|
||||
foreach($labels as $type=>$label) {
|
||||
$pdktotal += (int)$pdks[$type];
|
||||
if((int)$pdks[$type] < 0) $pdkneg = true;
|
||||
}
|
||||
if ($pdktotal == $dkills-$dp && !$pdkneg) {
|
||||
$dp += $pdktotal;
|
||||
$session['user']['maxhitpoints'] += (5 * $pdks["hp"]);
|
||||
$session['user']['attack'] += $pdks["at"];
|
||||
$session['user']['defense'] += $pdks["de"];
|
||||
reset($labels);
|
||||
foreach($labels as $type=>$label) {
|
||||
$count = 0;
|
||||
if (isset($pdks[$type])) $count = (int)$pdks[$type];
|
||||
while($count) {
|
||||
$count--;
|
||||
array_push($session['user']['dragonpoints'],$type);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
output("`\$Error: Please spend the correct total amount of dragon points.`n`n");
|
||||
}
|
||||
?>
|
118
lotgd-web/lotgd/lib/newday/dragonpointspend.php
Executable file
118
lotgd-web/lotgd/lib/newday/dragonpointspend.php
Executable file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
if ($dkills-$dp > 1) {
|
||||
page_header("Dragon Points");
|
||||
output("`@You earn one dragon point each time you slay the dragon.");
|
||||
output("Advancements made by spending dragon points are permanent!");
|
||||
output("`n`nYou have `^%s`@ unspent dragon points.", $dkills-$dp);
|
||||
output("How do you wish to spend them?`n`n");
|
||||
output("Be sure that your allocations add up to your total unspent dragon points.");
|
||||
$text = "<script type='text/javascript' language='Javascript'>
|
||||
<!--
|
||||
function pointsLeft() {
|
||||
var form = document.getElementById(\"dkForm\");
|
||||
";
|
||||
reset($labels);
|
||||
foreach($labels as $type=>$label) {
|
||||
if (isset($canbuy[$type]) && $canbuy[$type]) {
|
||||
$text .= "var $type = parseInt(form.$type.value);
|
||||
";
|
||||
}
|
||||
}
|
||||
reset($labels);
|
||||
foreach($labels as $type=>$label) {
|
||||
if (isset($canbuy[$type]) && $canbuy[$type]) {
|
||||
$text .= "if (isNaN($type)) $type = 0;
|
||||
";
|
||||
}
|
||||
}
|
||||
$text .= "var val = $dkills - $dp ";
|
||||
foreach($labels as $type=>$label) {
|
||||
if (isset($canbuy[$type]) && $canbuy[$type]) {
|
||||
$text .= "- $type";
|
||||
}
|
||||
}
|
||||
$text .= ";
|
||||
var absval = Math.abs(val);
|
||||
var points = 'points';
|
||||
if (absval == 1) points = 'point';
|
||||
if (val >= 0)
|
||||
document.getElementById(\"amtLeft\").innerHTML = \"<span class='colLtWhite'>You have </span><span class='colLtYellow'>\"+absval+\"</span><span class='colLtWhite'> \"+points+\" left to spend.</span><br />\";
|
||||
else
|
||||
document.getElementById(\"amtLeft\").innerHTML = \"<span class='colLtWhite'>You have spent </span><span class='colLtRed'>\"+absval+\"</span><span class='colLtWhite'> \"+points+\" too many!</span><br />\";
|
||||
}
|
||||
// -->
|
||||
</script>\n";
|
||||
rawoutput($text);
|
||||
addnav("Reset", "newday.php?pdk=0$resline");
|
||||
$link = appendcount("newday.php?pdk=1$resline");
|
||||
rawoutput("<form id='dkForm' action='$link' method='POST'>");
|
||||
addnav("",$link);
|
||||
rawoutput("<table cellpadding='0' cellspacing='0' border='0' width='200'>");
|
||||
reset($labels);
|
||||
foreach($labels as $type=>$label) {
|
||||
if (isset($canbuy[$type]) && $canbuy[$type]) {
|
||||
rawoutput("<tr><td nowrap>");
|
||||
output($label);
|
||||
output_notl(":");
|
||||
rawoutput("</td><td>");
|
||||
rawoutput("<input id='$type' name='$type' size='4' maxlength='4' value='{$pdks[$type]}' onKeyUp='pointsLeft();' onBlur='pointsLeft();' onFocus='pointsLeft();'>");
|
||||
rawoutput("</td></tr>");
|
||||
}
|
||||
}
|
||||
rawoutput("<tr><td colspan='2'> ");
|
||||
rawoutput("</td></tr><tr><td colspan='2' align='center'>");
|
||||
$click = translate_inline("Spend");
|
||||
rawoutput("<input id='dksub' type='submit' class='button' value='$click'>");
|
||||
rawoutput("</td></tr><tr><td colspan='2'> ");
|
||||
rawoutput("</td></tr><tr><td colspan='2' align='center'>");
|
||||
rawoutput("<div id='amtLeft'></div>");
|
||||
rawoutput("</td></tr>");
|
||||
rawoutput("</table>");
|
||||
rawoutput("</form>");
|
||||
reset($labels);
|
||||
$count = 0;
|
||||
foreach($labels as $type=>$label) {
|
||||
if ($count > 0) break;
|
||||
if (isset($canbuy[$type]) && $canbuy[$type]) {
|
||||
rawoutput("<script language='JavaScript'>document.getElementById('$type').focus();</script>");
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
page_header("Dragon Points");
|
||||
reset ($labels);
|
||||
$dist = array();
|
||||
foreach ($labels as $type=>$label) {
|
||||
$dist[$type] = 0; // Initialize the distribution
|
||||
if (isset($canbuy[$type]) && $canbuy[$type]) {
|
||||
addnav($label, "newday.php?dk=$type$resline");
|
||||
}
|
||||
}
|
||||
output("`@You have `&1`@ unspent dragon point.");
|
||||
output("How do you wish to spend it?`n`n");
|
||||
output("You earn one dragon point each time you slay the dragon.");
|
||||
output("Advancements made by spending dragon points are permanent!");
|
||||
for ($i=0; $i<count($session['user']['dragonpoints']); $i++) {
|
||||
if (isset($dist[$session['user']['dragonpoints'][$i]])) {
|
||||
$dist[$session['user']['dragonpoints'][$i]]++;
|
||||
} else {
|
||||
$dist['unknown']++;
|
||||
}
|
||||
}
|
||||
output("`n`nCurrently, the dragon points you have already spent are distributed in the following manner.");
|
||||
rawoutput("<blockquote>");
|
||||
rawoutput("<table>");
|
||||
reset ($labels);
|
||||
foreach ($labels as $type=>$label) {
|
||||
if ($type == 'unknown' && $dist[$type] == 0) continue;
|
||||
rawoutput("<tr><td nowrap>");
|
||||
output($label);
|
||||
output_notl(":");
|
||||
rawoutput("</td><td> </td><td>");
|
||||
output_notl("`@%s", $dist[$type]);
|
||||
rawoutput("</td></tr>");
|
||||
}
|
||||
rawoutput("</table>");
|
||||
rawoutput("</blockquote>");
|
||||
}
|
||||
?>
|
70
lotgd-web/lotgd/lib/newday/newday_runonce.php
Executable file
70
lotgd-web/lotgd/lib/newday/newday_runonce.php
Executable file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
//newday runonce
|
||||
//Let's do a new day operation that will only fire off for
|
||||
//one user on the whole server.
|
||||
//run the hook.
|
||||
modulehook("newday-runonce",array());
|
||||
|
||||
//Do some high-load-cleanup
|
||||
|
||||
//Moved from lib/datacache.php
|
||||
if (getsetting("usedatacache",0)){
|
||||
$handle = opendir($datacachefilepath);
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
if (substr($file,0,strlen(DATACACHE_FILENAME_PREFIX)) ==
|
||||
DATACACHE_FILENAME_PREFIX){
|
||||
$fn = $datacachefilepath."/".$file;
|
||||
$fn = preg_replace("'//'","/",$fn);
|
||||
$fn = preg_replace("'\\\\'","\\",$fn);
|
||||
if (is_file($fn) &&
|
||||
filemtime($fn) < strtotime("-24 hours")){
|
||||
unlink($fn);
|
||||
}else{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Expire Chars
|
||||
require_once("lib/expire_chars.php");
|
||||
|
||||
//Clean up old mails
|
||||
$sql = "DELETE FROM " . db_prefix("mail") . " WHERE sent<'".date("Y-m-d H:i:s",strtotime("-".getsetting("oldmail",14)."days"))."'";
|
||||
db_query($sql);
|
||||
massinvalidate("mail");
|
||||
|
||||
// clean up old bans
|
||||
db_query("DELETE FROM " . db_prefix("bans") . " WHERE banexpire < \"".date("Y-m-d")."\" AND banexpire>'0000-00-00'");
|
||||
|
||||
if (getsetting("expirecontent",180)>0){
|
||||
// Clean up old prefs
|
||||
$tables = array('module_userprefs'=>'prefs','module_settings'=>'settings');
|
||||
foreach ($tables as $table=>$key) module_delete_oldvalues($table,$key);
|
||||
|
||||
//Clean up debug log, moved from there
|
||||
$timestamp = date("Y-m-d H:i:s",strtotime("-".round(getsetting("expirecontent",180)/10,0)." days"));
|
||||
$sql = "DELETE FROM " . db_prefix("debuglog") . " WHERE date <'$timestamp'";
|
||||
db_query($sql);
|
||||
require_once("lib/gamelog.php");
|
||||
gamelog("Cleaned up ".db_affected_rows()." from ".db_prefix("debuglog")." older than $timestamp.",'maintenance');
|
||||
|
||||
//Clean up game log
|
||||
$timestamp = date("Y-m-d H:i:s",strtotime("-1 month"));
|
||||
$sql = "DELETE FROM ".db_prefix("gamelog")." WHERE date < '$timestamp' ";
|
||||
db_query($sql);
|
||||
gamelog("Cleaned up ".db_prefix("gamelog")." table removing ".db_affected_rows()." older than $timestamp.","maintenance");
|
||||
|
||||
//Clean up old comments
|
||||
|
||||
$sql = "DELETE FROM " . db_prefix("commentary") . " WHERE postdate<'".date("Y-m-d H:i:s",strtotime("-".getsetting("expirecontent",180)." days"))."'";
|
||||
db_query($sql);
|
||||
gamelog("Deleted ".db_affected_rows()." old comments.","comment expiration");
|
||||
|
||||
//Clean up old moderated comments
|
||||
|
||||
$sql = "DELETE FROM " . db_prefix("moderatedcomments") . " WHERE moddate<'".date("Y-m-d H:i:s",strtotime("-".getsetting("expirecontent",180)." days"))."'";
|
||||
db_query($sql);
|
||||
gamelog("Deleted ".db_affected_rows()." old moderated comments.","comment expiration");
|
||||
}
|
||||
if (strtotime(getsetting("lastdboptimize", date("Y-m-d H:i:s", strtotime("-1 day")))) < strtotime("-1 day"))
|
||||
require_once("lib/newday/dbcleanup.php");
|
||||
?>
|
32
lotgd-web/lotgd/lib/newday/setrace.php
Executable file
32
lotgd-web/lotgd/lib/newday/setrace.php
Executable file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
$setrace = httpget("setrace");
|
||||
if ($setrace!=""){
|
||||
$vname = getsetting("villagename", LOCATION_FIELDS);
|
||||
//in case the module wants to reference it this way.
|
||||
$session['user']['race']=$setrace;
|
||||
// Set the person to the main village/capital by default
|
||||
$session['user']['location'] = $vname;
|
||||
modulehook("setrace");
|
||||
addnav("Continue","newday.php?continue=1$resline");
|
||||
}else{
|
||||
output("Where do you recall growing up?`n`n");
|
||||
modulehook("chooserace");
|
||||
}
|
||||
if (navcount()==0){
|
||||
clearoutput();
|
||||
page_header("No Races Installed");
|
||||
output("No races were installed in this game.");
|
||||
output("So we'll call you a 'human' and get on with it.");
|
||||
if ($session['user']['superuser'] & (SU_MEGAUSER|SU_MANAGE_MODULES)) {
|
||||
output("You should go into the module manager off of the super user grotto, install and activate some races.");
|
||||
} else {
|
||||
output("You might want to ask your admin to install some races, they're really quite fun.");
|
||||
}
|
||||
$session['user']['race']="Human";
|
||||
addnav("Continue","newday.php?continue=1$resline");
|
||||
page_footer();
|
||||
}else{
|
||||
page_header("A little history about yourself");
|
||||
page_footer();
|
||||
}
|
||||
?>
|
29
lotgd-web/lotgd/lib/newday/setspecialty.php
Executable file
29
lotgd-web/lotgd/lib/newday/setspecialty.php
Executable file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
$setspecialty=httpget('setspecialty');
|
||||
if ($setspecialty != "") {
|
||||
$session['user']['specialty']=$setspecialty;
|
||||
modulehook("set-specialty");
|
||||
addnav("Continue","newday.php?continue=1$resline");
|
||||
} else {
|
||||
page_header("A little history about yourself");
|
||||
output("What do you recall doing as a child?`n`n");
|
||||
modulehook("choose-specialty");
|
||||
}
|
||||
if (navcount() == 0) {
|
||||
clearoutput();
|
||||
page_header("No Specialties Installed");
|
||||
output("Since there are no suitable specialties available, we'll make you a student of the mystical powers and get on with it.");
|
||||
// This is someone who will definately have the rights to install
|
||||
// modules.
|
||||
if ($session['user']['superuser'] & (SU_MEGAUSER|SU_MANAGE_MODULES)) {
|
||||
output("You should go into the module manager off of the super user grotto, install and activate some specialties.");
|
||||
} else {
|
||||
output("You might want to ask your admin to install some specialties, as they are quite fun (and helpful).");
|
||||
}
|
||||
$session['user']['specialty'] = "MP";
|
||||
addnav("Continue","newday.php?continue=1$resline");
|
||||
page_footer();
|
||||
}else{
|
||||
page_footer();
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user