本文整理匯總了PHP中Image::getImage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Image::getImage方法的具體用法?PHP Image::getImage怎麽用?PHP Image::getImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Image
的用法示例。
在下文中一共展示了Image::getImage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: indexAction
/**
* @return Bengine_Admin_Controller_News
*/
protected function indexAction()
{
if ($this->getParam("add")) {
$this->add($this->getParam("language_id"), $this->getParam("title"), $this->getParam("text"));
}
$first = true;
$i = 1;
$news = array();
$result = Core::getQuery()->select("news", array("news_id", "title", "text", "time", "enabled", "sort_index"), "", "", "sort_index ASC, news_id DESC");
$total = $result->rowCount();
foreach ($result->fetchAll() as $row) {
$down = "";
$up = "";
if (!$first) {
$up = Image::getImage("admin/up.gif", "", 16, 16);
$up = Link::get("admin/news/moveup/" . $row["news_id"], $up);
}
$first = false;
if ($i < $total) {
$down = Image::getImage("admin/down.gif", "", 16, 16);
$down = Link::get("admin/news/movedown/" . $row["news_id"], $down);
}
$i++;
$news[] = array("news_id" => $row["news_id"], "title" => $row["title"], "text" => $row["text"], "time" => Date::timeToString(1, $row["time"]), "enabled" => $row["enabled"], "edit" => Link::get("admin/news/edit/" . $row["news_id"], Core::getLang()->get("Edit")), "delete" => Link::get("admin/news/delete/" . $row["news_id"], Core::getLang()->get("Delete")), "enable" => Link::get("admin/news/enable/" . $row["news_id"], Core::getLang()->get("Enable"), "", "green"), "disable" => Link::get("admin/news/disable/" . $row["news_id"], Core::getLang()->get("Disable"), "", "red"), "down" => $down, "up" => $up);
}
Core::getTemplate()->addLoop("news", $news);
$languages = $this->getLanguages();
Core::getTPL()->assign("languageCount", count($languages));
if (count($languages) == 1) {
Core::getTPL()->assign("languages", key($languages));
} else {
Core::getTPL()->assign("languages", $this->getLanguageSelect());
}
return $this;
}
示例2: indexAction
/**
* Index action.
*
* @return Bengine_Game_Controller_Friends
*/
protected function indexAction()
{
Core::getLanguage()->load(array("Statistics", "Buddylist"));
if ($this->isPost()) {
if ($this->getParam("delete")) {
$this->remove($this->getParam("remove", array()));
}
if ($this->getParam("accept")) {
$this->acceptRequest($this->getParam("relid"));
}
}
$bl = array();
$select = array("b.relid", "b.friend1", "b.friend2", "b.accepted", "u1.username as user1", "u1.points as points1", "u1.last as lastlogin1", "u2.points as points2", "u2.username as user2", "u2.last as lastlogin2", "a1.tag as ally1", "a1.aid as allyid1", "a2.tag as ally2", "a2.aid as allyid2", "g1.galaxy as gala1", "g1.system as sys1", "g1.position as pos1", "g2.galaxy as gala2", "g2.system as sys2", "g2.position as pos2");
$joins = "LEFT JOIN " . PREFIX . "user u1 ON (u1.userid = b.friend1)";
$joins .= "LEFT JOIN " . PREFIX . "user u2 ON (u2.userid = b.friend2)";
$joins .= "LEFT JOIN " . PREFIX . "galaxy g1 ON (g1.planetid = u1.hp)";
$joins .= "LEFT JOIN " . PREFIX . "galaxy g2 ON (g2.planetid = u2.hp)";
$joins .= "LEFT JOIN " . PREFIX . "user2ally u2a1 ON (u2a1.userid = b.friend1)";
$joins .= "LEFT JOIN " . PREFIX . "user2ally u2a2 ON (u2a2.userid = b.friend2)";
$joins .= "LEFT JOIN " . PREFIX . "alliance a1 ON (a1.aid = u2a1.aid)";
$joins .= "LEFT JOIN " . PREFIX . "alliance a2 ON (a2.aid = u2a2.aid)";
$result = Core::getQuery()->select("buddylist b", $select, $joins, Core::getDB()->quoteInto("b.friend1 = ? OR b.friend2 = ?", Core::getUser()->get("userid")), "u1.points DESC, u2.points DESC, u1.username ASC, u2.username ASC");
foreach ($result->fetchAll() as $row) {
Hook::event("ShowBuddyFirst", array(&$row));
if ($row["friend1"] == Core::getUser()->get("userid")) {
if ($row["lastlogin2"] > TIME - 900) {
$status = Image::getImage("on.gif", getTimeTerm(TIME - $row["lastlogin2"]));
} else {
$status = Image::getImage("off.gif", getTimeTerm(TIME - $row["lastlogin2"]));
}
$username = Link::get("game/" . SID . "/MSG/Write/" . rawurlencode($row["user2"]), Image::getImage("pm.gif", Core::getLanguage()->getItem("WRITE_MESSAGE"))) . " " . Link::get("game/" . SID . "/Profile/Page/" . $row["friend2"], $row["user2"]);
$points = $row["points2"];
$position = getCoordLink($row["gala2"], $row["sys2"], $row["pos2"]);
$ally = Link::get("game/" . SID . "/Alliance/Page/" . $row["allyid2"], $row["ally2"]);
} else {
if ($row["lastlogin1"] > TIME - 900) {
$status = Image::getImage("on.gif", getTimeTerm(TIME - $row["lastlogin1"]));
} else {
$status = Image::getImage("off.gif", getTimeTerm(TIME - $row["lastlogin1"]));
}
$username = Link::get("game/" . SID . "/MSG/Write/" . rawurlencode($row["user1"]), Image::getImage("pm.gif", Core::getLanguage()->getItem("WRITE_MESSAGE"))) . " " . Link::get("game/" . SID . "/Profile/Page/" . $row["friend1"], $row["user1"]);
$points = $row["points1"];
$position = getCoordLink($row["gala1"], $row["sys1"], $row["pos1"]);
$ally = Link::get("game/" . SID . "/Alliance/Page/" . $row["allyid1"], $row["ally1"]);
}
$bl[$row["relid"]]["f1"] = $row["friend1"];
$bl[$row["relid"]]["f2"] = $row["friend2"];
$bl[$row["relid"]]["relid"] = $row["relid"];
$bl[$row["relid"]]["username"] = $username;
$bl[$row["relid"]]["accepted"] = $row["accepted"];
$bl[$row["relid"]]["points"] = fNumber($points);
$bl[$row["relid"]]["status"] = $status;
$bl[$row["relid"]]["position"] = $position;
$bl[$row["relid"]]["ally"] = $ally;
Hook::event("ShowBuddyLast", array($row, &$bl));
}
$result->closeCursor();
Core::getTPL()->addLoop("buddylist", $bl);
return $this;
}
示例3: pageAction
/**
* Alliance page action.
*
* @return Bengine_Comm_Controller_Alliance
*/
public function pageAction()
{
Core::getLanguage()->load("Alliance");
Core::getTPL()->clearHTMLHeaderFiles();
Core::getTPL()->addHTMLHeaderFile("game.css", "css");
Core::getTPL()->addHTMLHeaderFile("lib/jquery.js", "js");
$tag = $this->getParam("1");
$fNumber = array("member", "points", "rpoints", "fpoints", "dpoints");
$attr = array("a.aid", "a.name", "a.tag", "a.logo", "a.textextern", "a.homepage", "a.showhomepage", "COUNT(u2a.userid) AS member", "SUM(u.points) AS points", "SUM(u.rpoints) AS rpoints", "SUM(u.fpoints) AS fpoints", "SUM(u.dpoints) AS dpoints");
$joins = "LEFT JOIN " . PREFIX . "user2ally u2a ON (u2a.aid = a.aid) ";
$joins .= "LEFT JOIN " . PREFIX . "user u ON (u2a.userid = u.userid) ";
$result = Core::getQuery()->select("alliance a", $attr, $joins, Core::getDB()->quoteInto("tag = ?", $tag), "", 1, "a.aid");
$row = $result->fetchRow();
if ($row) {
foreach ($fNumber as $field) {
$row[$field] = fNumber($row[$field]);
}
$parser = new Bengine_Game_Alliance_Page_Parser($row["aid"]);
if (Str::length(strip_tags($row["textextern"])) > 0) {
$row["textextern"] = $parser->startParser($row["textextern"]);
} else {
$row["textextern"] = Core::getLang()->get("WELCOME");
}
$row["homepage"] = $row["homepage"] != "" ? Link::get($row["homepage"], $row["homepage"], $row["homepage"]) : "";
$row["logo"] = $row["logo"] != "" ? Image::getImage($row["logo"], "") : "";
Hook::event("ShowPublicAlliancePage", array(&$row));
$this->assign($row);
$this->setIsAjax();
} else {
$this->setNoDisplay(true);
}
return $this;
}
示例4: indexAction
/**
* Index action.
*
* @return Bengine_Game_Controller_MSG
*/
protected function indexAction()
{
$select = array("f.folder_id", "f.label", "f.is_standard", "COUNT(m.msgid) AS messages", "SUM(m.read) AS `read`", "SUM(LENGTH(m.message)) AS `storage`");
$joins = "LEFT JOIN " . PREFIX . "message m ON (m.mode = f.folder_id AND m.receiver = '" . Core::getUser()->get("userid") . "')";
$where = Core::getDB()->quoteInto("f.userid = ? OR f.is_standard = '1'", Core::getUser()->get("userid"));
$result = Core::getQuery()->select("folder f", $select, $joins, $where, "", "", "f.folder_id");
$folders = array();
foreach ($result->fetchAll() as $row) {
$unreadMessages = $row["messages"] - (int) $row["read"];
if ($unreadMessages > 1) {
$read = "UNREAD";
$newMessages = sprintf(Core::getLanguage()->getItem("F_NEW_MESSAGES"), fNumber($unreadMessages));
} else {
if ($unreadMessages > 0) {
$read = "UNREAD";
$newMessages = Core::getLanguage()->getItem("F_NEW_MESSAGE");
} else {
$read = "READ";
$newMessages = "";
}
}
$label = $row["is_standard"] ? Core::getLang()->get($row["label"]) : $row["label"];
$link = "game/" . SID . "/MSG/ReadFolder/" . $row["folder_id"];
$folders[] = array("image" => Link::get("game/" . SID . "/MSG/markasread/" . $row["folder_id"], Image::getImage(strtolower($read) . ".gif", Core::getLang()->get($read))), "label" => Link::get($link, $label, Core::getLang()->get($read)), "messages" => fNumber($row["messages"]), "newMessages" => $newMessages, "size" => File::bytesToString($row["storage"]));
}
$result->closeCursor();
Core::getTPL()->addLoop("folders", $folders);
return $this;
}
示例5: infoAction
/**
* Shows all unit information.
*
* @param integer $id
* @throws Recipe_Exception_Generic
* @return Bengine_Game_Controller_Unit
*/
protected function infoAction($id)
{
// Bengine_Game_Common unit data
$select = array("c.name", "c.mode", "c.basic_metal", "c.basic_silicon", "c.basic_hydrogen", "ds.capicity", "ds.speed", "ds.consume", "ds.attack", "ds.shield");
$join = "LEFT JOIN " . PREFIX . "ship_datasheet ds ON (ds.unitid = c.buildingid)";
$result = Core::getQuery()->select("construction c", $select, $join, Core::getDB()->quoteInto("c.buildingid = ?", $id));
if ($row = $result->fetchRow()) {
$result->closeCursor();
Core::getLanguage()->load("info,UnitInfo");
Hook::event("ShowUnitInfo", array(&$row));
Core::getTPL()->assign("mode", $row["mode"]);
Core::getTPL()->assign("structure", fNumber($row["basic_metal"] + $row["basic_silicon"]));
Core::getTPL()->assign("shield", fNumber($row["shield"]));
Core::getTPL()->assign("attack", fNumber($row["attack"]));
Core::getTPL()->assign("shell", fNumber(($row["basic_metal"] + $row["basic_silicon"]) / 10));
Core::getTPL()->assign("capacity", fNumber($row["capicity"]));
Core::getTPL()->assign("speed", fNumber($row["speed"]));
Core::getTPL()->assign("consume", fNumber($row["consume"]));
Core::getTPL()->assign("name", Core::getLanguage()->getItem($row["name"]));
Core::getTPL()->assign("description", Core::getLanguage()->getItem($row["name"] . "_FULL_DESC"));
Core::getTPL()->assign("pic", Image::getImage("buildings/" . $row["name"] . ".gif", Core::getLanguage()->getItem($row["name"]), null, null, "leftImage"));
Core::getTPL()->assign("edit", Link::get("game/" . SID . "/Unit/Edit/" . $id, "[" . Core::getLanguage()->getItem("EDIT") . "]"));
// Rapidfire
$i = 0;
$rf = array();
$_result = Core::getQuery()->select("rapidfire rf", array("rf.target", "rf.value", "c.name"), "LEFT JOIN " . PREFIX . "construction c ON (c.buildingid = rf.target)", Core::getDB()->quoteInto("rf.unitid = ?", $id));
foreach ($_result->fetchAll() as $_row) {
Hook::event("ShowUnitRapidfire", array($row, &$_row));
$name = Link::get("game/" . SID . "/Unit/Info/" . $_row["target"], Core::getLanguage()->getItem($_row["name"]));
$rf[$i]["rapidfire"] = sprintf(Core::getLanguage()->getItem("RAPIDFIRE_TO"), $name);
$rf[$i]["value"] = "<span class=\"available\">" . fNumber($_row["value"]) . "</span>";
$i++;
}
$_result->closeCursor();
$_result = Core::getQuery()->select("rapidfire rf", array("rf.unitid", "rf.value", "c.name"), "LEFT JOIN " . PREFIX . "construction c ON (c.buildingid = rf.unitid)", Core::getDB()->quoteInto("rf.target = ?", $id));
foreach ($_result->fetchAll() as $_row) {
Hook::event("ShowUnitRapidfire", array($row, &$_row));
$name = Link::get("game/" . SID . "/Unit/Info/" . $_row["unitid"], Core::getLanguage()->getItem($_row["name"]));
$rf[$i]["rapidfire"] = sprintf(Core::getLanguage()->getItem("RAPIDFIRE_FROM"), $name);
$rf[$i]["value"] = "<span class=\"notavailable\">" . fNumber($_row["value"]) . "</span>";
$i++;
}
$_result->closeCursor();
Core::getTPL()->addLoop("rapidfire", $rf);
$engines = array();
$_result = Core::getQuery()->select("ship2engine s2e", array("s2e.base_speed", "s2e.base", "s2e.level", "e.engineid", "factor", "c.name"), "LEFT JOIN " . PREFIX . "engine e ON (e.engineid = s2e.engineid) " . "LEFT JOIN " . PREFIX . "construction c ON (c.buildingid = e.engineid)", Core::getDB()->quoteInto("s2e.unitid = ?", $id), "s2e.level ASC");
foreach ($_result->fetchAll() as $_row) {
$_row["name"] = Link::get("game/" . SID . "/Constructions/Info/" . $_row["engineid"], Core::getLanguage()->get($_row["name"]));
$_row["base_speed"] = fNumber($_row["base_speed"]);
$engines[] = $_row;
}
$_result->closeCursor();
Core::getTPL()->addLoop("engines", $engines);
} else {
$result->closeCursor();
throw new Recipe_Exception_Generic("Unkown unit. You'd better don't mess with the URL.");
}
return $this;
}
示例6: __construct
/**
* Creates a new user list object.
*
* @param resource $list Query result for a list
* @param int $start
* @return \Bengine_Game_User_List
*/
public function __construct($list = null, $start = 0)
{
$this->pmPic = Image::getImage("pm.gif", Core::getLanguage()->getItem("WRITE_MESSAGE"));
$this->buddyPic = Image::getImage("b.gif", Core::getLanguage()->getItem("ADD_TO_BUDDYLIST"));
$this->modPic = Image::getImage("moderator.gif", Core::getLanguage()->getItem("MODERATE"));
$this->points = Core::getUser()->get("points");
parent::__construct($list, $start);
}
示例7: testImageClearCache
public function testImageClearCache()
{
$image = new Image();
$image->setSourcePath("tests/test.jpg");
$image->getImage(128);
$this->assertEquals(true, file_exists(Image::$cache_directory));
$this->assertEquals(3, count(scandir(Image::$cache_directory)));
$image->clearCache();
$this->assertEquals(false, file_exists(Image::$cache_directory));
$this->assertEquals(false, file_exists(Image::$cache_hints_file));
}
示例8: _format
/**
* Formats the message.
*
* @param Bengine_Game_Model_Message $message
*
* @return Bengine_Game_MessageFolder_User
*/
protected function _format(Bengine_Game_Model_Message $message)
{
$sender = $message->get("sender");
if (!empty($sender)) {
$url = "game/" . SID . "/MSG/Write/" . rawurlencode($message->get("username")) . "/" . Link::urlEncode("RE: " . $message->get("subject"));
$reply = Link::get($url, Image::getImage("pm.gif", Core::getLanguage()->getItem("REPLY")));
$message->set("reply_link", $reply);
$sender = $message->get("username") . " " . getCoordLink($message->get("galaxy"), $message->get("system"), $message->get("position"));
} else {
$sender = "System";
}
$message->set("sender", $sender);
$this->replaceForeignSessionId($message);
return $this;
}
示例9: _format
/**
* Formats the message.
*
* @param Bengine_Game_Model_Message $message
*
* @return Bengine_Game_MessageFolder_Alliance
*/
protected function _format(Bengine_Game_Model_Message $message)
{
$senderName = $message->get("username");
$sender = !empty($senderName) ? Core::getLanguage()->getItem("ALLIANCE_GLOBAL_MAIL") . " (" . $senderName . ")" : Core::getLanguage()->getItem("ALLIANCE");
$message->set("sender", $sender);
$this->replaceForeignSessionId($message);
if (Core::getUser()->get("aid")) {
$subject = "RE: " . preg_replace("#((RE|FW):\\s)+#is", "\\1", $message->get("subject"));
$subject = rawurlencode($subject);
$linkUrl = "game/";
if (URL_SESSION) {
$linkUrl .= SID . "/";
}
$linkUrl .= "Alliance/GlobalMail/" . $subject;
if (!empty($senderName)) {
$replyImg = Image::getImage("pm.gif", Core::getLanguage()->getItem("REPLY_ALLIANCE_MAIL"));
$message->set("reply_link", Link::get($linkUrl, $replyImg));
}
}
return $this;
}
示例10: parseEvent
/**
* Parses an event.
*
* @param Bengine_Game_Model_Event $f
*
* @return array Parsed event data
*/
protected function parseEvent(Bengine_Game_Model_Event $f)
{
if ($f->getCode() == "game/alliedFleet" && $f->getUserid() != Core::getUser()->get("userid")) {
return false;
// Hide foreign formations
}
$event = array();
$event["time_r"] = $f->getTimeLeft();
$event["time"] = $f->getFormattedTimeLeft();
$event["eventid"] = $f->getEventid();
$event["time_finished"] = Date::timeToString(1, $f->getTime());
$event["raw_coordinates"] = $f->getDestinationCoords(false);
Core::getLanguage()->assign("rockets", $f->getData("rockets", 0));
Core::getLanguage()->assign("planet", !$f->getData("oldmode") || $f->getData("oldmode") != 9 ? $f->getPlanetname() : Core::getLanguage()->getItem("DEBRIS"));
// TODO: Old mode should be translated to code
Core::getLanguage()->assign("coords", $f->getPlanetCoords());
Core::getLanguage()->assign("target", $f->getCode() != "game/recycling" ? $f->getDestinationPlanetname() : Core::getLanguage()->getItem("DEBRIS"));
Core::getLanguage()->assign("targetcoords", $f->getDestinationCoords());
Core::getLanguage()->assign("metal", fNumber($f->getData("metal", 0)));
Core::getLanguage()->assign("silicon", fNumber($f->getData("silicon", 0)));
Core::getLanguage()->assign("hydrogen", fNumber($f->getData("hydrogen", 0)));
Core::getLanguage()->assign("username", $f->getUsername());
Core::getLanguage()->assign("message", Link::get("game/" . SID . "/MSG/Write/" . rawurlencode($f->getUsername()), Image::getImage("pm.gif", Core::getLanguage()->getItem("WRITE_MESSAGE"))));
Core::getLanguage()->assign("mission", $f->getCode() == "game/return" ? $f->getOrgModeName() : $f->getModeName());
Core::getLanguage()->assign("fleet", $f->getFleetString());
$event["class"] = $f->getCssClass();
if ($f->getCode() == "game/allianceAttack") {
if ($f->getUserid() == Core::getUser()->get("userid")) {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OWN");
} else {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OTHER");
}
$allyFleets = Game::getEH()->getFormationFleets($f->getEventid());
foreach ($allyFleets as $af) {
$coords = $af->getPlanetCoords();
$msg = Core::getLanguage()->getItem("FLEET_MESSAGE_FORMATION");
$msg = sprintf($msg, $af->getUsername(), $af->getPlanetname(), $coords, $af->getFleetString());
$event["message"] .= $msg;
}
} else {
if ($f->getCode() == "game/alliedFleet") {
$mainFleet = Game::getModel("game/event")->load($f->getParentId());
if ($mainFleet->getUsierid() == Core::getUser()->get("userid")) {
return false;
}
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OWN");
$allyFleets = Game::getEH()->getFormationFleets($mainFleet->getEventid());
$allyFleets->add($mainFleet);
foreach ($allyFleets as $af) {
if ($af->getUserid() == Core::getUser()->get("userid")) {
continue;
}
$coords = $af->getPlanetCoords();
$msg = Core::getLanguage()->getItem("FLEET_MESSAGE_FORMATION");
$msg = sprintf($msg, $af->getUsername(), $af->getPlanetname(), $coords, $af->getFleetString());
$event["message"] .= $msg;
}
} else {
if ($f->getCode() == "game/holding" && $f->getUserid() == Core::getUser()->get("userid")) {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_HOLDING_1");
} else {
if ($f->getCode() == "game/holding") {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_HOLDING_2");
} else {
if ($f->getCode() == "game/return" && $f->getUserid() == Core::getUser()->get("userid")) {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_RETURN");
} else {
if ($f->getUserid() == Core::getUser()->get("userid") && $f->getCode() == "game/missileAttack") {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_ROCKET_ATTACK");
} else {
if ($f->getCode() == "game/missileAttack") {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_ROCKET_ATTACK_FOREIGN");
} else {
if ($f->getUserid() == Core::getUser()->get("userid")) {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OWN");
} else {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OTHER");
}
}
}
}
}
}
}
}
return $event;
}
示例11: paintPie3D
/**
* paint a 3d-pie
*
* @param int $w
* @param int $h
* @param int $cx
* @param int $cy
* @param int $sx
* @param int $sy
* @param int $sz
* @param array $bg []
* @param array $values []
* @param array $colors [][]
* @param array $legend []
* @param int $legendX
* @param int $legendY
* @param int $legendFont
* @param int $legendSpace
*/
function paintPie3D($w, $h, $cx, $cy, $sx, $sy, $sz, $bg, $values, $colors, $legend = false, $legendX = 0, $legendY = 0, $legendFont = 2, $legendSpace = 14)
{
// img
$imageObject = false;
// gif
$imageObject = Image::getImage(IMG_GIF, $w, $h);
// try png if failed
if (!$imageObject) {
$imageObject = Image::getImage(IMG_PNG, $w, $h);
}
// try jpg if failed
if (!$imageObject) {
$imageObject = Image::getImage(IMG_JPG, $w, $h);
}
// bail if no object
if (!$imageObject) {
Image::paintNotSupported();
}
// background
$background = imagecolorallocate($imageObject->image, $bg['r'], $bg['g'], $bg['b']);
// convert to angles.
$valueCount = count($values);
$valueSum = array_sum($values);
for ($i = 0; $i < $valueCount; $i++) {
$angle[$i] = $values[$i] / $valueSum * 360;
$angle_sum[$i] = array_sum($angle);
}
// colors.
for ($i = 0; $i < $valueCount; $i++) {
$col_s[$i] = imagecolorallocate($imageObject->image, $colors[$i]['r'], $colors[$i]['g'], $colors[$i]['b']);
$col_d[$i] = imagecolorallocate($imageObject->image, $colors[$i]['r'] >> 1, $colors[$i]['g'] >> 1, $colors[$i]['b'] >> 1);
}
// 3D effect.
for ($z = 1; $z <= $sz; $z++) {
for ($i = 0; $i < $valueCount; $i++) {
imagefilledarc($imageObject->image, $cx, $cy + $sz - $z, $sx, $sy, $angle_sum[$i != 0 ? $i - 1 : $valueCount - 1], $angle_sum[$i], $col_d[$i], IMG_ARC_PIE);
}
}
// top pie.
for ($i = 0; $i < $valueCount; $i++) {
imagefilledarc($imageObject->image, $cx, $cy, $sx, $sy, $angle_sum[$i != 0 ? $i - 1 : $valueCount - 1], $angle_sum[$i], $col_s[$i], IMG_ARC_PIE);
}
// legend
if ($legend) {
$curY = $legendY;
for ($i = 0; $i < $valueCount; $i++) {
$textcolor = imagecolorallocate($imageObject->image, $colors[$i]['r'], $colors[$i]['g'], $colors[$i]['b']);
imagestring($imageObject->image, $legendFont, $legendX, $curY, $legend[$i], $textcolor);
$curY += $legendSpace;
}
}
// output
$imageObject->paint();
}
示例12: explode
//echo $caminho; exit;
$div1 = explode(".", $caminho);
$new = $div1[0];
for ($i = 1; $i < count($div1) - 1; $i++) {
$new .= "." . $div1[$i];
}
$nome = basename($caminho);
$nome = str_replace("." . $div1[count($div1) - 1], "", $nome);
$div2 = explode('-', $new);
$width = $div2[count($div2) - 2];
$height = $div2[count($div2) - 1];
$caminho = str_replace("size-" . $width . "-" . $height, "", $caminho);
$arq = new Arquivos(str_replace("", '', Sistema::$caminhoDiretorio) . urldecode($caminho));
header('Expires: 0');
header('Pragma: no-cache');
if (strtoupper($arq->extensao) == "JPEG" || strtoupper($arq->extensao) == "JPG" || strtoupper($arq->extensao) == "PNG" || strtoupper($arq->extensao) == "GIF" || strtoupper($arq->extensao) == "BMP") {
header("Content-type: image/" . $arq->extensao);
$img = new Image($arq);
$img->open();
if (!empty($width) && !empty($height)) {
$img->redimensionar($width, $height);
$img->saveImage(dirname(substr(str_replace("", '', Sistema::$caminhoDiretorio), 0, -1) . urldecode($caminho)), urldecode($nome));
}
$img->getImage();
} else {
header("Content-Type: application/" . $arq->extensao);
header('Content-disposition: attachment; filename="' . $arq->getNome() . '";');
$len = filesize($arq->url);
header("Content-Length: " . $len . ";\n");
echo $arq->arquivo;
}
示例13: isset
<?php
if (isset($_GET['url'])) {
$default_size = 50;
$width = isset($_GET['width']) ? $_GET['width'] : $default_size;
$height = isset($_GET['height']) ? $_GET['height'] : $default_size;
require_once 'image.php';
$image = new Image();
$image->getImage($_GET['url']);
$image->resizeImage($width, $height);
$image->displayImage();
}
示例14: indexAction
/**
* Index action.
*
* @return Bengine_Game_Controller_Galaxy
*/
protected function indexAction()
{
if ($this->isPost()) {
$this->setCoordinatesByPost($this->getParam("galaxy"), $this->getParam("system"), $this->getParam("submittype"));
}
$this->validateInputs()->subtractHydrogen();
// Star surveillance
$canMonitorActivity = false;
if (Game::getPlanet()->getBuilding("STAR_SURVEILLANCE") > 0) {
$range = pow(Game::getPlanet()->getBuilding("STAR_SURVEILLANCE"), 2) - 1;
$diff = abs(Game::getPlanet()->getData("system") - $this->system);
if ($this->galaxy == Game::getPlanet()->getData("galaxy") && $range >= $diff) {
$canMonitorActivity = true;
}
}
Core::getTPL()->assign("canMonitorActivity", $canMonitorActivity);
// Images
$rockimg = Image::getImage("rocket.gif", Core::getLanguage()->getItem("ROCKET_ATTACK"));
// Get sunsystem data
$select = array("g.planetid", "g.position", "g.destroyed", "g.metal", "g.silicon", "g.moonid", "p.picture", "p.planetname", "p.last as planetactivity", "u.username", "u.usertitle", "u.userid", "u.points", "u.last as useractivity", "u.umode", "u.level", "m.planetid AS moon", "m.picture AS moonpic", "m.planetname AS moonname", "m.diameter AS moonsize", "m.temperature", "m.last as moonactivity", "a.tag", "a.name", "a.showmember", "a.homepage", "a.showhomepage", "u2a.aid", "b.to");
$joins = "LEFT JOIN " . PREFIX . "planet p ON (p.planetid = g.planetid)";
$joins .= "LEFT JOIN " . PREFIX . "user u ON (u.userid = p.userid)";
$joins .= "LEFT JOIN " . PREFIX . "planet m ON (m.planetid = g.moonid)";
$joins .= "LEFT JOIN " . PREFIX . "user2ally u2a ON (u2a.userid = u.userid)";
$joins .= "LEFT JOIN " . PREFIX . "alliance a ON (a.aid = u2a.aid)";
$joins .= "LEFT JOIN " . PREFIX . "ban_u b ON (b.userid = u.userid AND b.to > '" . TIME . "')";
$where = Core::getDB()->quoteInto("g.galaxy = ? AND g.system = ?", array($this->galaxy, $this->system));
$result = Core::getQuery()->select("galaxy g", $select, $joins, $where);
$UserList = new Bengine_Game_User_List();
$UserList->setKey("position");
$UserList->setNewbieProtection(true);
$UserList->setFetchRank(true);
$UserList->setTagAsLink(false);
$UserList->load($result);
$sys = $UserList->getArray();
Hook::event("SolarSystemDataBefore", array($this, &$sys));
for ($i = 1; $i <= 15; $i++) {
if (isset($sys[$i]) && !$sys[$i]["destroyed"]) {
$sys[$i]["systempos"] = $i;
if ($sys[$i]["tag"] != "") {
$sys[$i]["allydesc"] = sprintf(Core::getLanguage()->getItem("GALAXY_ALLY_HEADLINE"), $sys[$i]["tag"], $sys[$i]["alliance_rank"]);
}
$sys[$i]["metal"] = fNumber($sys[$i]["metal"]);
$sys[$i]["silicon"] = fNumber($sys[$i]["silicon"]);
$sys[$i]["picture"] = Image::getImage("planets/small/s_" . $sys[$i]["picture"] . Core::getConfig()->get("PLANET_IMG_EXT"), $sys[$i]["planetname"], 30, 30);
$sys[$i]["picture"] = Link::get("game/" . SID . "/Mission/Index/" . $this->galaxy . "/" . $this->system . "/" . $i, $sys[$i]["picture"]);
$sys[$i]["planetname"] = Link::get("game/" . SID . "/Mission/Index/" . $this->galaxy . "/" . $this->system . "/" . $i, $sys[$i]["planetname"]);
$sys[$i]["moonpicture"] = $sys[$i]["moonpic"] != "" ? Image::getImage("planets/small/s_" . $sys[$i]["moonpic"] . Core::getConfig()->get("PLANET_IMG_EXT"), $sys[$i]["moonname"], 22, 22) : "";
$sys[$i]["moon"] = sprintf(Core::getLanguage()->getItem("MOON_DESC"), $sys[$i]["moonname"]);
$sys[$i]["moonsize"] = fNumber($sys[$i]["moonsize"]);
$sys[$i]["moontemp"] = fNumber($sys[$i]["temperature"]);
if ($sys[$i]["moonactivity"] > $sys[$i]["planetactivity"]) {
$activity = $sys[$i]["moonactivity"];
} else {
$activity = $sys[$i]["planetactivity"];
}
if ($activity > TIME - 900 && $sys[$i]["userid"] != Core::getUser()->get("userid")) {
$sys[$i]["activity"] = "(*)";
} else {
if ($activity > TIME - 3600 && $sys[$i]["userid"] != Core::getUser()->get("userid")) {
$sys[$i]["activity"] = "(" . floor((TIME - $activity) / 60) . " min)";
} else {
$sys[$i]["activity"] = "";
}
}
if (Game::getPlanet()->getBuilding("ROCKET_STATION") > 3 && $sys[$i]["userid"] != Core::getUser()->get("userid") && $this->inMissileRange()) {
$sys[$i]["rocketattack"] = Link::get("game/" . SID . "/RocketAttack/Index/" . $sys[$i]["planetid"], $rockimg);
$sys[$i]["moonrocket"] = "<tr><td colspan=\"3\" class=\"center\">" . Link::get("game/" . SID . "/RocketAttack/Index/" . $sys[$i]["moonid"] . "/1", Core::getLanguage()->getItem("ROCKET_ATTACK")) . "</td></tr>";
} else {
$sys[$i]["rocketattack"] = "";
$sys[$i]["moonrocket"] = "";
}
$sys[$i]["allypage"] = Str::replace("\"", "", Link::get("game/" . SID . "/Alliance/Page/" . $sys[$i]["aid"], Core::getLanguage()->getItem("ALLIANCE_PAGE"), 1));
if (($sys[$i]["showhomepage"] || $sys[$i]["aid"] == Core::getUser()->get("aid")) && $sys[$i]["homepage"] != "") {
$sys[$i]["homepage"] = "<tr><td>" . Str::replace("'", "\\'", Link::get($sys[$i]["homepage"], Core::getLanguage()->getItem("HOMEPAGE"), 2)) . "</td></tr>";
} else {
$sys[$i]["homepage"] = "";
}
if ($sys[$i]["showmember"]) {
$sys[$i]["memberlist"] = "<tr><td>" . Str::replace("\"", "", Link::get("game/" . SID . "/Alliance/Memberlist/" . $sys[$i]["aid"], Core::getLanguage()->getItem("SHOW_MEMBERLIST"), 3)) . "</td></tr>";
}
$sys[$i]["debris"] = Image::getImage("debris.jpg", "", 25, 25);
} else {
if (empty($sys[$i]["destroyed"])) {
$sys[$i] = array();
$sys[$i]["destroyed"] = false;
$sys[$i]["metal"] = 0;
$sys[$i]["silicon"] = 0;
$sys[$i]["debris"] = "";
$sys[$i]["picture"] = "";
$sys[$i]["planetname"] = "";
$sys[$i]["planetid"] = "";
} else {
$sys[$i]["metal"] = fNumber($sys[$i]["metal"]);
$sys[$i]["silicon"] = fNumber($sys[$i]["silicon"]);
//.........這裏部分代碼省略.........
示例15: showCandidatesAction
/**
* Shows the candidates and their application.
*
* @return Bengine_Game_Controller_Alliance
*/
protected function showCandidatesAction()
{
if ($this->isPost()) {
$this->manageCadidates($this->getParam("receipt"), $this->getParam("refuse"), $this->getParam("users"));
}
if ($this->getRights(array("CAN_SEE_APPLICATIONS"))) {
$apps = array();
$result = Core::getQuery()->select("allyapplication a", array("a.userid", "a.date", "a.application ", "u.username", "u.points", "g.galaxy", "g.system", "g.position"), "LEFT JOIN " . PREFIX . "user u ON (u.userid = a.userid) LEFT JOIN " . PREFIX . "galaxy g ON (g.planetid = u.hp)", Core::getDB()->quoteInto("a.aid = ?", $this->aid), "u.username ASC, a.date ASC");
foreach ($result->fetchAll() as $row) {
$apps[$row["userid"]]["date"] = Date::timeToString(1, $row["date"]);
$apps[$row["userid"]]["message"] = Link::get("game/" . SID . "/MSG/Write/" . $row["username"], Image::getImage("pm.gif", Core::getLanguage()->getItem("WRITE_MESSAGE")));
$apps[$row["userid"]]["apptext"] = nl2br($row["application"]);
$apps[$row["userid"]]["userid"] = $row["userid"];
$apps[$row["userid"]]["username"] = $row["username"];
$apps[$row["userid"]]["points"] = fNumber(floor($row["points"]));
$apps[$row["userid"]]["position"] = getCoordLink($row["galaxy"], $row["system"], $row["position"]);
}
Core::getTPL()->assign("candidates", sprintf(Core::getLanguage()->getItem("CANDIDATES"), $result->rowCount()));
$result->closeCursor();
Hook::event("ShowAllianceCandidates", array(&$apps));
Core::getTPL()->addLoop("applications", $apps);
}
return $this;
}