Beispiel #1
0
 /**
  * Send a message to the public forum. The variables passed are assumed to be already sanitized
  *
  * @param int $toID User/Thread ID to send to
  * @param int $fromUserID UserID sent from
  * @param string $message The message to be sent
  * @param string[optional] $subject The subject
  * @param string[optional] $type 'Bulletin'(GameMaster->Player) 'ThreadStart'(User->All) 'ThreadReply'(User->Thread)
  *
  * @return int The message ID
  */
 public static function send($toID, $fromUserID, $message, $subject = "", $type = 'Bulletin')
 {
     global $DB;
     if (defined('AdminUserSwitch')) {
         $fromUserID = AdminUserSwitch;
     }
     $message = self::linkify($message);
     $sentTime = time();
     if (65000 < strlen($message)) {
         throw new Exception(l_t("Message too long"));
     }
     libCache::wipeDir(libCache::dirName('forum'));
     $DB->sql_put("INSERT INTO wD_ForumMessages\r\n\t\t\t\t\t\tSET toID = " . $toID . ", fromUserID = " . $fromUserID . ", timeSent = " . $sentTime . ",\r\n\t\t\t\t\t\tmessage = '" . $message . "', subject = '" . $subject . "', replies = 0,\r\n\t\t\t\t\t\ttype = '" . $type . "', latestReplySent = 0");
     $id = $DB->last_inserted();
     if ($type == 'ThreadReply') {
         $DB->sql_put("UPDATE wD_ForumMessages " . "SET latestReplySent = " . $id . ", replies = replies + 1 WHERE ( id=" . $id . " OR id=" . $toID . " )");
     } else {
         $DB->sql_put("UPDATE wD_ForumMessages SET latestReplySent = id WHERE id = " . $id);
     }
     $tabl = $DB->sql_tabl("SELECT t.id FROM wD_ForumMessages t LEFT JOIN wD_ForumMessages r ON ( r.toID=t.id AND r.fromUserID=" . $fromUserID . " AND r.type='ThreadReply' ) WHERE t.type='ThreadStart' AND ( t.fromUserID=" . $fromUserID . " OR r.id IS NOT NULL ) GROUP BY t.id");
     $participatedThreadIDs = array();
     while (list($participatedThreadID) = $DB->tabl_row($tabl)) {
         $participatedThreadIDs[$participatedThreadID] = $participatedThreadID;
     }
     $cacheUserParticipatedThreadIDsFilename = libCache::dirID('users', $fromUserID) . '/readThreads.js';
     file_put_contents($cacheUserParticipatedThreadIDsFilename, 'participatedThreadIDs = $A([' . implode(',', $participatedThreadIDs) . ']);');
     return $id;
 }
Beispiel #2
0
 public function turnAsDate($turn)
 {
     if ($turn == -1) {
         return l_t("Pre-game");
     } else {
         return ($turn % 2 ? l_t("Autumn") . ", " : l_t("Spring") . ", ") . (floor($turn / 2) + 1);
     }
 }
Beispiel #3
0
 public function formHTML()
 {
     print '<form method="post" name="search">';
     foreach ($this->searchItems as $item) {
         print $item->formHTML();
     }
     print '<br /><input type="submit" class="form-submit" value="' . l_t('Search') . '" />';
     print '</form>';
 }
Beispiel #4
0
 /**
  * Display a table with the vital members info; who is finalized, who has sent messages etc, each member
  * takes up a short, thin column.
  * @return string
  */
 function membersList()
 {
     global $User;
     // $membersList[$i]=array($nameOrCountryID,$iconOne,$iconTwo,...);
     $membersList = array();
     if ($this->Game->phase == 'Pre-game') {
         $count = count($this->ByID);
         for ($i = 0; $i < $count; $i++) {
             $membersList[] = array($i + 1, '<img src="' . l_s('images/icons/tick.png') . '" alt=" " title="' . l_t('Player joined, spot filled') . '" />');
         }
         for ($i = $count; $i <= count($this->Game->Variant->countries); $i++) {
             $membersList[] = array($i + 1, '');
         }
     } else {
         for ($countryID = 1; $countryID <= count($this->Game->Variant->countries); $countryID++) {
             $Member = $this->ByCountryID[$countryID];
             //if ( $User->id == $this->ByCountryID[$countryID]->userID )
             //	continue;
             //elseif( $Member->status != 'Playing' && $Member->status != 'Left' )
             //	continue;
             $membersList[] = $Member->memberColumn();
         }
     }
     $buf = '<table class="homeMembersTable">';
     $rowsCount = count($membersList[0]);
     $alternate = libHTML::$alternate;
     for ($i = 0; $i < $rowsCount; $i++) {
         $rowBuf = '';
         $dataPresent = false;
         $remainingPlayers = count($this->ByID);
         $remainingWidth = 100;
         foreach ($membersList as $data) {
             if ($data[$i]) {
                 $dataPresent = true;
             }
             if ($remainingPlayers > 1) {
                 $width = floor($remainingWidth / $remainingPlayers);
             } else {
                 $width = $remainingWidth;
             }
             $remainingPlayers--;
             $remainingWidth -= $width;
             $rowBuf .= '<td style="width:' . $width . '%" class="barAlt' . libHTML::alternate() . '">' . $data[$i] . '</td>';
         }
         libHTML::alternate();
         if ($dataPresent) {
             $buf .= '<tr>' . $rowBuf . '</tr>';
         }
         libHTML::$alternate = $alternate;
     }
     libHTML::alternate();
     $buf .= '</table>';
     return $buf;
 }
Beispiel #5
0
 public static function dir($dir, array $dirParts)
 {
     $name = array_pop($dirParts);
     if (is_null($name)) {
         return $dir;
     }
     if (!is_dir($dir . '/' . $name) && !mkdir($dir . '/' . $name, 0775, true)) {
         throw new Exception(l_t("Couldn't make cache directory '%s'.", $dir . '/' . $name));
     }
     return self::dir($dir . '/' . $name, $dirParts);
 }
Beispiel #6
0
 function iconText()
 {
     if ($this->None) {
         return l_t('No orders to submit');
     } elseif ($this->Ready) {
         return l_t('Ready to move to the next turn');
     } elseif ($this->Completed) {
         return l_t('Orders completed, but not ready for next turn');
     } elseif ($this->Saved) {
         return l_t('Orders saved, but not completed!');
     } else {
         return l_t('No orders submitted!');
     }
 }
    function formHTML()
    {
        $output = "";
        $output .= '<input type="radio" 
			value="' . $this->value . '" 
			' . ($this->locked ? '' : 'name="' . $this->htmlName . '"') . ' 
			' . ($this->checked ? 'checked ' : '') . '
			' . ($this->locked ? 'disabled ' : '') . '/> 
			' . l_t($this->label);
        if ($this->locked) {
            $output .= ' <input type="hidden" name="' . $this->htmlName . '" value="' . $this->value . '" />';
        }
        return $output;
    }
Beispiel #8
0
 protected function toTerrIDCheck()
 {
     $this->toTerrID = (int) $this->toTerrID;
     if ($this->type == 'Build Army') {
         /*
          * Creating an army at which territory
          *
          * Unoccupied supply centers owned by our country, which the specified unit type
          * can be built in. If a parent coast is found return Child entries.
          */
         return $this->sqlCheck("SELECT t.id\r\n\t\t\t\tFROM wD_TerrStatus ts\r\n\t\t\t\tINNER JOIN wD_Territories t\r\n\t\t\t\t\tON ( t.id = ts.terrID )\r\n\t\t\t\tWHERE ts.gameID = " . $this->gameID . "\r\n\t\t\t\t\tAND ts.countryID = " . $this->countryID . "\r\n\t\t\t\t\tAND t.countryID = " . $this->countryID . "\r\n\t\t\t\t\tAND ts.occupyingUnitID IS NULL\r\n\t\t\t\t\tAND t.supply = 'Yes' AND NOT t.type='Sea'\r\n\t\t\t\t\tAND NOT t.coast = 'Child'\r\n\t\t\t\t\tAND t.id=" . $this->toTerrID . "\r\n\t\t\t\t\tAND t.mapID=" . MAPID . "\r\n\t\t\t\tLIMIT 1");
     } elseif ($this->type == 'Build Fleet') {
         return $this->sqlCheck("SELECT IF(t.coast='Parent', coast.id, t.id) as terrID\r\n\t\t\t\tFROM wD_TerrStatus ts\r\n\t\t\t\tINNER JOIN wD_Territories t ON ( t.id = ts.terrID )\r\n\t\t\t\tLEFT JOIN wD_Territories coast ON ( coast.mapID=t.mapID AND coast.coastParentID = t.id AND NOT t.id = coast.id )\r\n\t\t\t\tWHERE ts.gameID = " . $this->gameID . "\r\n\t\t\t\t\tAND ts.countryID = " . $this->countryID . "\r\n\t\t\t\t\tAND t.countryID = " . $this->countryID . "\r\n\t\t\t\t\tAND ts.occupyingUnitID IS NULL\r\n\t\t\t\t\tAND t.supply = 'Yes'\r\n\t\t\t\t\tAND t.type = 'Coast'\r\n\t\t\t\t\tAND ( t.coast='No' OR ( t.coast='Parent' AND NOT coast.id IS NULL ) )\r\n\t\t\t\t\tAND (\r\n\t\t\t\t\t\t(t.coast='Parent' AND coast.id=" . $this->toTerrID . ")\r\n\t\t\t\t\t\tOR t.id=" . $this->toTerrID . "\r\n\t\t\t\t\t)\r\n\t\t\t\t\tAND t.mapID=" . MAPID . "\r\n\t\t\t\tLIMIT 1");
     } elseif ($this->type == 'Destroy') {
         /*
          * Destroying a unit at which territory
          */
         return $this->sqlCheck("SELECT terrID\n\t\t\t\tFROM wD_TerrStatus\r\n\t\t\t\tWHERE gameID = " . $this->gameID . "\r\n\t\t\t\t\tAND occupyingUnitID IS NOT NULL\r\n\t\t\t\t\tAND countryID = " . $this->countryID . "\r\n\t\t\t\t\tAND terrID = " . $this->toTerrID . "\r\n\t\t\t\tLIMIT 1");
     } else {
         throw new Exception(l_t("Checking the territory when not required."));
     }
 }
Beispiel #9
0
 /**
  * Send a game message. Messages are sanitized
  *
  * @param string $toCountryID The countryID being sent to. 'Global' sends to all.
  * @param string $fromCountryID The county being sent from. 'GameMaster' can also be used.
  * @param string|array $message The message(s) to be sent (Can be an array of messages for)
  * @param int[optional] $gameID The game ID to use. If not given the current global Game is sent to.
  */
 public static function send($toCountryID, $fromCountryID, $message, $gameID = -1)
 {
     global $DB, $Game;
     if (!is_object($Game)) {
         $Variant = libVariant::loadFromGameID($gameID);
         $Game = $Variant->Game($gameID);
     }
     $message = $DB->msg_escape($message);
     if (!is_numeric($toCountryID)) {
         $toCountryID = 0;
     }
     if (!is_numeric($fromCountryID)) {
         $message = '<strong>' . $fromCountryID . ':</strong> ' . $message;
         $fromCountryID = 0;
     }
     if (65000 < strlen($message)) {
         throw new Exception(l_t("Message too long"));
     }
     $DB->sql_put("INSERT INTO wD_GameMessages\r\n\t\t\t\t\t(gameID, toCountryID, fromCountryID, turn, message, timeSent)\r\n\t\t\t\t\tVALUES(" . $Game->id . ",\r\n\t\t\t\t\t\t" . $toCountryID . ",\r\n\t\t\t\t\t\t" . $fromCountryID . ",\r\n\t\t\t\t\t\t" . $Game->turn . ",\r\n\t\t\t\t\t\t'" . $message . "',\r\n\t\t\t\t\t\t" . time() . ")");
     if ($toCountryID != $fromCountryID || $fromCountryID == 0) {
         libGameMessage::notify($toCountryID, $fromCountryID);
     }
 }
Beispiel #10
0
 /**
  * Saves the territories.js JSON file which the order-generation code need to know the board layout.
  *
  * @param string $jsonFileLocation Where the file will be saved to
  * @param int $mapID
  */
 public static function terrJSON($jsonFileLocation, $mapID)
 {
     global $DB;
     $territories = array();
     $tabl = $DB->sql_tabl("SELECT id, name, type, supply, countryID, coast, coastParentID, smallMapX, smallMapY\r\n\t\t\tFROM wD_Territories\r\n\t\t\tWHERE mapID=" . $mapID . "\r\n\t\t\tORDER BY id ASC");
     $selectVars = '';
     while ($row = $DB->tabl_hash($tabl)) {
         $row['Borders'] = array();
         $row['CoastalBorders'] = array();
         $row['name'] = l_t($row['name']);
         $territories[$row['id']] = $row;
     }
     $tabl = $DB->sql_tabl("SELECT * FROM wD_Borders WHERE mapID=" . $mapID);
     while ($row = $DB->tabl_hash($tabl)) {
         // id, a, f saves space
         $territories[$row['fromTerrID']]['Borders'][] = array('id' => $row['toTerrID'], 'a' => $row['armysPass'] == 'Yes', 'f' => $row['fleetsPass'] == 'Yes');
     }
     $tabl = $DB->sql_tabl("SELECT * FROM wD_CoastalBorders WHERE mapID=" . $mapID);
     while ($row = $DB->tabl_hash($tabl)) {
         $territories[$row['fromTerrID']]['CoastalBorders'][] = array('id' => $row['toTerrID'], 'a' => $row['armysPass'] == 'Yes', 'f' => $row['fleetsPass'] == 'Yes');
     }
     $javascript = "function loadTerritories() {\n" . 'Territories = $H(' . json_encode($territories) . ');' . "\n}\n";
     file_put_contents($jsonFileLocation, $javascript);
 }
Beispiel #11
0
 /**
  * Return the next process time in textual format, in terms of time remaining
  *
  * @return string
  */
 function processTimetxt()
 {
     if ($this->processTime < time()) {
         return l_t("Now");
     } else {
         return libTime::remainingText($this->processTime);
     }
 }
Beispiel #12
0
						<input type="hidden" name="viewthread" value="0" />
						<input type="submit" class="form-submit" value="' . l_t('Close') . '" />
				</form>';
    } else {
        print '<a href="forum.php?viewthread=' . $message['id'] . '#' . $message['id'] . '" ' . 'title="' . l_t('Open this thread to view the replies, or post your own reply') . '">' . l_t('Open') . '</a>';
        /*
        print '<form action="forum.php#'.$message['id'].'" method="get">
        				<input type="hidden" name="viewthread" value="'.$message['id'].'" />
        				<input type="submit" class="form-submit" value="Open"
        					title="Open this thread to view the replies, or post your own reply" />
        		</form>';
        */
    }
    print "</div>\r\n\t\t</div>";
}
print '<div class="hr"></div>';
print '<div>';
print $forumPager->html('bottom');
print '<div><a href="#forum">' . l_t('Back to top') . '</a><a name="bottom"></a></div>';
print '<div style="clear:both;"> </div>
		</div>';
print '</div>';
print '</div>';
if ($User->type['User']) {
    if (isset($replyToID)) {
        libHTML::$footerScript[] = 'readThread(' . $replyToID . ', ' . $replyID . ');';
    }
}
libHTML::$footerScript[] = 'makeFormsSafe();';
$_SESSION['lastSeenForum'] = time();
libHTML::footer();
Beispiel #13
0
    private static function footerCopyright()
    {
        // Version, sourceforge and HTML compliance logos
        return l_t('webDiplomacy version <strong>%s</strong>', number_format(VERSION / 100, 2)) . '<br />
			<a href="http://github.com/kestasjk/webDiplomacy" class="light">GitHub Project</a> | 
			<a href="http://github.com/kestasjk/webDiplomacy/issues" class="light">Bug Reports</a> | <a href="mailto:' . Config::$modEMail . '" class="light">Contact Moderator</a>';
    }
Beispiel #14
0
            if ($percentLeft > 0) {
                $percentLeft--;
                $percent = 1;
                continue;
            } else {
                break;
            }
        }
        $percentLeft -= $percent;
        $scCountsByTurn[$turn][$countryID] = $percent;
    }
}
$scRatiosByTurn = $scCountsByTurn;
unset($scCountsByTurn);
if (count($scRatiosByTurn) < 3) {
    print l_t('Game too new to graph.');
    return;
}
print '<div class="variant' . $Variant->name . ' boardGraph" style="width:auto">';
foreach ($scRatiosByTurn as $turn => $scRatiosByCountryID) {
    print '<div class="boardGraphTurn" style="width:auto">';
    //500px">';
    foreach ($scRatiosByCountryID as $countryID => $scRatio) {
        if ($scRatio < 1) {
            continue;
        }
        print '<div class="boardGraphTurnCountry occupationBar' . $countryID . '" ' . 'style="text-align:center; font-size:10pt; font-weight:bold; overflow:hidden;' . 'float:left;width:' . $scRatio . '%">' . $scRatio . '%</div>';
    }
    print '<div style="clear:both"></div>';
    print '</div>';
}
            $sql[] = number_format(round($chance, 3), 3);
        }
        $lastLine = "(" . implode(",", $sql) . ")";
        unset($userID);
    }
}
print "<br />";
flush();
print l_t("Indexing") . "<br />";
flush();
$DB->sql_put("ALTER TABLE `Chances` ADD INDEX ( `id` )");
print l_t("Putting chances table data into users table") . "<br />";
flush();
$sqlBuf = "UPDATE wD_Users u INNER JOIN Chances c SET ";
$first = true;
foreach ($Game->Variant->countries as $c) {
    if ($first) {
        $first = false;
    } else {
        $sqlBuf .= ", ";
    }
    $sqlBuf .= "u.Chance" . $c . " = c.Chance" . $c;
}
$sqlBuf .= " WHERE u.id = c.id";
$DB->sql_put($sqlBuf);
print l_t("Deleting chances table");
flush();
$DB->sql_put("DROP TABLE Chances");
$DB->sql_put("COMMIT");
print l_t("Done");
flush();
Beispiel #16
0
 /**
  * Load the $this->territoryPositions array
  */
 protected function loadTerritories()
 {
     global $DB;
     $territoryPositionsSQL = "SELECT id, name, ";
     if ($this->smallmap) {
         $territoryPositionsSQL .= 'smallMapX, smallMapY';
     } else {
         $territoryPositionsSQL .= 'mapX, mapY';
     }
     $territoryPositionsSQL .= " FROM wD_Territories WHERE mapID=" . $this->mapID;
     $this->territoryPositions = array();
     $tabl = $DB->sql_tabl($territoryPositionsSQL);
     while (list($terrID, $terrName, $x, $y) = $DB->tabl_row($tabl)) {
         $this->territoryPositions[$terrID] = array($x, $y);
         $this->territoryNames[$terrID] = l_t($terrName);
     }
 }
Beispiel #17
0
            if ($set != '') {
                $set .= ', ';
            }
            $set .= $SQLName . " = '" . $SQLVars[$SQLName] . "'";
            $formOutput .= l_t('%s updated successfully.', $name) . ' ';
        }
        if ($set != '') {
            $DB->sql_put("UPDATE wD_Users SET " . $set . " WHERE id = " . $User->id);
        }
        if (isset($SQLVars['password'])) {
            $DB->sql_put("UPDATE wD_Users SET password = "******" WHERE id = " . $User->id);
            libAuth::keyWipe();
            header('refresh: 3; url=logon.php');
            $formOutput .= l_t('Password updated successfully; you have been logged out and ' . 'will need to logon with the new password.') . ' ';
        }
    } catch (Exception $e) {
        $formOutput .= $e->getMessage();
    }
    // We may have received no new data
    if ($formOutput) {
        $User->load();
        // Reload in case of a change
        print '<div class="content"><p class="notice">' . $formOutput . '</p></div>';
    }
}
print libHTML::pageTitle(l_t('User account settings'), l_t('Alter the settings for your webDiplomacy user account; e.g. change your password/e-mail.'));
print '<form method="post">
<ul class="formlist">';
require_once l_r('locales/English/user.php');
print '</div>';
libHTML::footer();
Beispiel #18
0
 public function link()
 {
     return '<a class="light" href="variants.php#' . $this->name . '">' . l_t($this->fullName) . '</a>';
 }
 /**
  * Compares numeric values using the max and min possible values returned, and will
  * throw a paradox if the comparison cannot be made. $hisValueSource can be a static integer
  * value, or it can be an array of a dependencyNode, and the name of the value to be
  * compared with from the dependencyNode.
  *
  * This function behaves like the __call wrapper function, except instead of wrapping
  * true/false decisions it wraps numeric comparisons in such a way that they behave like
  * true/false decisions
  *
  * @param string $myValueName What this node is comparing
  * @param string $comparison Greater, smaller, equal, etc
  * @param int|array $hisValueSource A max/min array, or a static value
  * @return bool True or false (or else throw a paradox)
  */
 private function _compare($myValueName, $comparison, $hisValueSource)
 {
     // Load the values which will be getting compared
     if (is_array($hisValueSource)) {
         /*
          * It's an object numeric value call
          */
         list($him, $valueName) = $hisValueSource;
         // These functions are called directly without going through __call
         $hisValue = $him->{$valueName}();
     } else {
         /*
          * It's a static value; max = min = value
          */
         $hisValue = array('max' => $hisValueSource, 'min' => $hisValueSource);
     }
     $myValue = $this->{$myValueName}();
     if ($comparison == '>') {
         // My min is larger than his max; myVal is larger
         if ($myValue['min'] > $hisValue['max']) {
             return true;
         }
         // My max is smaller than or equal to his min; myVal is not larger
         if ($myValue['max'] <= $hisValue['min']) {
             return false;
         }
     } else {
         // My max is smaller than his min; myVal is smaller
         if ($myValue['max'] < $hisValue['min']) {
             return true;
         }
         // My min is not smaller than his max; myVal is not smaller
         if ($myValue['min'] >= $hisValue['max']) {
             return false;
         }
     }
     /*
      * There are only 4 ways to get a sure true or false decision, and we haven't got it
      *
      * The comparison couldn't be resolved due to a paradox; re-throw the smallest paradox
      */
     if (isset($myValue['paradox']) and isset($hisValue['paradox'])) {
         $p = $myValue['paradox'];
         $p->downSizeTo($hisValue['paradox']);
     } elseif (isset($myValue['paradox'])) {
         $p = $myValue['paradox'];
     } elseif (isset($hisValue['paradox'])) {
         $p = $hisValue['paradox'];
     } else {
         trigger_error(l_t("Comparison paradox code reached, without a paradox."));
     }
     throw $p;
     // The comparison failed
 }
Beispiel #20
0
                $DB->sql_put("UPDATE wD_Games SET attempts=0 WHERE id=" . $Game->id);
                $DB->sql_put("COMMIT");
                print l_t('Processed.');
            }
        }
    } catch (Exception $e) {
        if ($e->getMessage() == "Abandoned" || $e->getMessage() == "Cancelled") {
            $DB->sql_put("COMMIT");
            print l_t('Abandoned.');
        } else {
            $DB->sql_put("ROLLBACK");
            print l_t('Crashed: "%s".', $e->getMessage());
        }
    }
    print '<br />';
}
// If it took over 30 secs there may still be games to process
if (time() - $startTime >= 30) {
    /*
     * For when you're developing and just reloaded the DB from a backup,
     * you usually have to refresh a few times before it runs out of games
     * to process
     */
    header('refresh: 4; url=gamemaster.php');
    print '<p class="notice">' . l_t('Timed-out; re-running') . '</p>';
} else {
    // Finished all remaining games with time to spare; update the civil disorder and NMR counts
    //libGameMaster::updateCDNMRCounts();
}
print '</div>';
libHTML::footer();
Beispiel #21
0
function adminCPTabs()
{
    $tabs = array('Control Panel' => l_t('Perform admin tasks'), 'Mod notes' => l_t('Notes/reports left for/by the mod team'), 'Status lists' => l_t('View server status lists'), 'Control Panel Logs' => l_t('Log of recent admin tasks'), 'Multi-accounts' => l_t('Multi-account detector'), 'Locales' => l_t('Locale management'));
    $tab = 'Control Panel';
    $tabNames = array_keys($tabs);
    if (isset($_REQUEST['tab']) && in_array($_REQUEST['tab'], $tabNames)) {
        $tab = $_SESSION['adminCPTab'] = $_REQUEST['tab'];
    } elseif (isset($_SESSION['adminCPTab']) && in_array($_SESSION['adminCPTab'], $tabNames)) {
        $tab = $_SESSION['adminCPTab'];
    }
    print '<div class="gamelistings-tabs">';
    foreach ($tabs as $tabChoice => $tabTitle) {
        print '<a title="' . $tabTitle . '" alt="' . l_t($tabChoice) . '" href="admincp.php?tab=' . $tabChoice;
        if ($tab == $tabChoice) {
            print '" class="current"';
        } else {
            print '"';
        }
        print '>' . l_t($tabChoice) . '</a>';
    }
    print '</div>';
    return $tab;
}
Beispiel #22
0
   (at your option) any later version.

   webDiplomacy is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with webDiplomacy.  If not, see <http://www.gnu.org/licenses/>.
*/
defined('IN_CODE') or die('This script can not be run by itself.');
/**
 * Return all the maps for this game. May use a lot of resources if the maps aren't
 * already cached.
 *
 * @package Board
 */
print '<h3>' . l_t('Maps') . '</h3>';
for ($i = $Game->turn; $i >= 0; $i--) {
    if ($i < $Game->turn && $i % 2 != 0) {
        print '<div class="hr"></div>';
    }
    print '<h4>' . $Game->datetxt($i) . '</h4>';
    print '<p style="text-align:center">
		<img src="map.php?gameID=' . $Game->id . '&turn=' . $i . '" title="' . l_t('Small map for this turn') . '" /><br />
		' . l_t('Large map:') . ' <a href="map.php?gameID=' . $Game->id . '&largemap=on&turn=' . $i . '">
					<img src="' . l_s('images/historyicons/external.png') . '" alt="' . l_t('Large map') . '"
						title="' . l_t('This button will open the large map in a new window. The large map shows all the moves, and is useful when the small map isn\'t clear enough') . '."
					/></a>
		</p>';
}
Beispiel #23
0
 private static function remainingTextString($givenTime, $timeFrom)
 {
     $secondsRemaining = $givenTime - $timeFrom;
     if ($secondsRemaining <= 0) {
         return l_t('Now');
     }
     $seconds = floor($secondsRemaining % 60);
     $minutes = floor($secondsRemaining % (60 * 60) / 60);
     $hours = floor($secondsRemaining % (24 * 60 * 60) / (60 * 60));
     $days = floor($secondsRemaining / (24 * 60 * 60));
     if ($days > 0) {
         // D, H
         $minutes += round($seconds / 60);
         // Add a minute if the seconds almost give a minute
         $seconds = 0;
         $hours += round($minutes / 60);
         // Add an hour if the minutes almost gives an hour
         $minutes = 0;
         if ($hours > 0) {
             return l_t('%s days, %s hours', $days, $hours);
         } else {
             return l_t('%s days', $days);
         }
     } elseif ($hours > 0) {
         // H, M
         $minutes += round($seconds / 60);
         // Add a minute if the seconds almost give a minute
         $seconds = 0;
         if ($minutes > 0) {
             return l_t('%s hours, %s minutes', $hours, $minutes);
         } else {
             return l_t('%s hours', $hours);
         }
     } else {
         // M, S
         if ($seconds > 0) {
             return l_t('%s minutes, %s seconds', $minutes, $seconds);
         } else {
             return l_t('%s minutes', $minutes);
         }
     }
 }
Beispiel #24
0
 /**
  * Logon as a user with a key. Display a notice and terminate if there is
  * a problem, otherwise return a $User object corresponding to the given
  * key.
  * Will also attempt to use legacy keys
  *
  * @param string $key The auth key (/legacy cookie)
  * @param bool[optional] $session Should the user be logged on only for the session true/false
  *
  * @return User A user object
  */
 public static function key_User($key, $session = false)
 {
     global $DB;
     $userID = self::key_UserID($key);
     if (!$userID) {
         if (isset($_REQUEST['noRefresh'])) {
             // We have been sent back from the logoff script, and clearly not with a wiped key
             // Load some data that will give useful context in the trigger_error errorlog
             // which will occur below.
             if (isset($_COOKIE['wD-Key']) and $_COOKIE['wD-Key']) {
                 $cookieKey = $_COOKIE['wD-Key'];
             }
             $user_agent = $_SERVER['HTTP_USER_AGENT'];
             $allCookies = print_r($_COOKIE, true);
             $success = self::keyWipe();
             // Make sure there's no refresh loop
             trigger_error(l_t("An invalid log-on cookie was given, but it seems an attempt to remove it has failed.") . "<br /><br />" . l_t("This error has been logged, please e-mail %s if the problem persists, or you can't log on.", Config::$modEMail));
         } else {
             self::keyWipe();
             header('refresh: 3; url=logon.php?logoff=on');
             libHTML::error(l_t("You have been logged out. " . "You are being redirected to the log-on page.") . "<br /><br />" . l_t("Inform the moderators at %s if the problem persists, or you can't log on.", Config::$modEMail));
         }
     }
     // This user ID is authenticated
     self::keySet($userID, $session);
     global $User;
     try {
         $User = new User($userID);
     } catch (Exception $e) {
         self::keyWipe();
         header('refresh: 3; url=logon.php?logoff=on');
         libHTML::error(l_t("You are using an invalid log on cookie, which has been wiped. Please try logging on again."));
     }
     $User->logon();
     return $User;
 }
Beispiel #25
0
/**
 * Hall of fame; the top 100 webDip scorers
 *
 * @package Base
 * @subpackage Game
 */
require_once 'header.php';
libHTML::starthtml();
print libHTML::pageTitle(l_t('Hall of fame'), l_t('The webDiplomacy hall of fame; the 100 highest ranking players on this server.'));
print '<p align="center"><img src="' . l_s('images/points/stack.png') . '" alt=" "
			title="' . l_t('webDiplomacy ranking points; who are the most skilled at gathering them from their foes?') . '" /></p>';
print '<p></p>';
if ($User->type['User'] && $User->points > 100) {
    list($position) = $DB->sql_row("SELECT COUNT(id)+1 FROM wD_Users WHERE points > " . $User->points);
    $players = $Misc->RankingPlayers;
    print '<p>' . l_t('You are ranked %s out of %s ranking players (players with >100%s)', '<a href="#me" class="light">#' . $position . '</a>', $players, libHTML::points()) . l_t('For more stats on your ranking visit <a class="light" href="profile.php?userID=' . $User->id . '">your profile</a>.') . '</p>';
}
print '<table class="credits">';
$alternate = false;
$i = 1;
$crashed = $DB->sql_tabl("SELECT id, username, points FROM wD_Users\r\n\t\t\t\t\t\torder BY points DESC LIMIT 100 ");
while (list($id, $username, $points) = $DB->tabl_row($crashed)) {
    $alternate = !$alternate;
    print '
	<tr class="replyalternate' . ($alternate ? '1' : '2') . '">
		<td class="left time">
			' . $points . ' ' . libHTML::points() . ' - #' . $i . '
		</td>

		<td class="right message"><a href="profile.php?userID=' . $id . '">' . $username . '</a></td>
	</tr>';
Beispiel #26
0
 /**
  * Check the Moves table to check that the right units Moved/Held/Got Dislodged
  * Dies if there is a difference between what is there and what should be there
  */
 function checkResults()
 {
     global $DB;
     /*
      * Now the moves table can be used to determine whether the moves'
      * Success/Hold/Dislodged status are as they should be
      */
     $tabl = $DB->sql_tabl("SELECT d.*, m.* FROM wD_DATCOrders d INNER JOIN wD_Moves m ON (\r\n\t\t\t\t" . $this->Variant->deCoastCompare('m.terrID', 'd.terrID') . "\r\n\t\t\t\tAND\r\n\t\t\t\t(\r\n\t\t\t\t\t/* We needed to move in, but have failed to */\r\n\t\t\t\t\t( d.moveType = 'Move' AND d.criteria = 'Success' AND m.success = 'No' )\r\n\t\t\t\t\tOR\r\n\t\t\t\t\t/* We needed to hold, but were dislodged */\r\n\t\t\t\t\t( d.criteria = 'Hold' AND m.dislodged = 'Yes' )\r\n\t\t\t\t\tOR\r\n\t\t\t\t\t/* We needed to get dislodged, but held */\r\n\t\t\t\t\t( d.criteria = 'Dislodged' AND m.dislodged = 'No' )\r\n\t\t\t\t)\r\n\t\t\t)\r\n\t\t\tWHERE d.testID = " . $this->testID . " AND m.gameID = " . $GLOBALS['GAMEID']);
     $failed = false;
     while ($hash = $DB->tabl_hash($tabl)) {
         $failed = true;
         print l_t('Failed on the following order, failed criteria =%s ' . ':<br />%s<br /><br />', $hash['criteria'], nl2br(print_r($hash, true)));
     }
     if ($failed) {
         // Even if this fails we still want to draw a map to visualize it, so don't die
         throw new Exception('<h4>' . l_t('Failed results test. <a href="datc.php">Re-run</a>') . '</h4>');
     } else {
         print l_t('Passed results test') . '<br /><br />';
     }
 }
 public function recalculateRR(array $params)
 {
     require_once l_r('gamemaster/gamemaster.php');
     libGameMaster::updateReliabilityRating(true);
     return l_t("Reliability Ratings have been recalculated");
 }
    function formHTML()
    {
        print '<li>
			<strong>' . l_t($this->label) . '</strong>:
			<ul>
				<li>' . $this->options['-']->formHTML() . '</li>
				<li>' . $this->options['Active']->formHTML() . '
					<ul>' . $this->subItems['activePhases']->formHTML() . $this->subItems['processStatus']->formHTML() . '</ul>
				</li>
				<li>' . $this->options['Finished']->formHTML() . '
					<ul>' . $this->subItems['gameOver']->formHTML() . '</ul>
				</li>
			</ul>
			</li>';
    }
Beispiel #29
0
    public function likeMessageToggleLink($messageID, $fromUserID = -1)
    {
        if ($this->type['User'] && $this->id != $fromUserID && !in_array($messageID, $this->getLikeMessages())) {
            return '<a id="likeMessageToggleLink' . $messageID . '" 
			href="#" title="' . l_t('Give a mark of approval for this post') . '" class="light likeMessageToggleLink" ' . 'onclick="likeMessageToggle(' . $this->id . ',' . $messageID . ',\'' . libAuth::likeToggleToken($this->id, $messageID) . '\'); ' . 'return false;">' . '+1</a>';
        } else {
            return '';
        }
    }
 public function createUserThreadSilenceConfirm(array $params)
 {
     self::checkSilenceParams($params);
     return l_t('Are you sure you want to silence this user %s, and silence the thread they were posting in, because <i>%s</i> ?', Silence::printLength($params['length']), $params['reason']);
 }