function newsclient_pagesetup() { // register links -- global $profile_id; global $PAGE; global $CFG; $page_owner = $profile_id; $rss_username = user_info('username', $page_owner); if (isloggedin()) { /*if (defined("context") && context == "resources" && $page_owner == $_SESSION['userid']) { $PAGE->menu[] = array( 'name' => 'feeds', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/feeds/\" class=\"selected\" >" .__gettext("Your Resources").'</a></li>'); } else { $PAGE->menu[] = array( 'name' => 'feeds', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/feeds/\" >" .__gettext("Your Resources").'</a></li>'); }*/ } if (defined("context") && context == "resources") { if ($page_owner != -1) { $PAGE->menu_sub[] = array('name' => 'newsfeed:subscription', 'html' => a_href($CFG->wwwroot . $rss_username . "/feeds/", __gettext("Feeds"))); if (permissions_check("profile", $page_owner) && isloggedin()) { $PAGE->menu_sub[] = array('name' => 'newsfeed:subscription:publish:blog', 'html' => a_href($CFG->wwwroot . "_rss/blog.php?profile_name=" . user_info("username", $page_owner), __gettext("Publish to blog"))); } $PAGE->menu_sub[] = array('name' => 'newsclient', 'html' => a_href($CFG->wwwroot . $rss_username . "/feeds/all/", __gettext("View aggregator"))); } $PAGE->menu_sub[] = array('name' => 'feed', 'html' => a_href($CFG->wwwroot . "_rss/popular.php", __gettext("Popular Feeds"))); /* $PAGE->menu_sub[] = array( 'name' => 'feed', 'html' => a_href( $CFG->wwwroot."help/feeds_help.php", "Page help")); */ } }
function pages_pagesetup() { // backward compatibilty global $CFG, $PAGE; // menu keyword $CFG->templates->variables_substitute['pagesmenu'][] = 'pages_tplkw_menu'; $CFG->templates->variables_substitute['page'][] = 'pages_tplkw_page'; $CFG->templates->variables_substitute['sysadminemail'][] = 'pages_tplkw_sysadminemail'; if (defined('context') && context == 'pages' || defined('pages_external')) { if (pages_enabled() && permissions_check('pages::edit', page_owner())) { $page_name = optional_param('page'); $do_action = optional_param('do'); if ($do_action != 'edit') { // new page link pages_submenu_add('pages:edit', __gettext('New page'), pages_url('New_page', 'pages::edit', page_owner()), 0); // edit this page link pages_submenu_add('pages:edit', __gettext('Edit this page'), pages_url($page_name, 'pages::edit', page_owner()), 1); } } } if (!PAGES_DISABLE_USERS && isloggedin()) { pages_menu_add('pages', __gettext('Your Content'), get_url($_SESSION['userid'], 'pages::')); } if (pages_enabled()) { // not show main site pages on sidebar sidebar_add(25, 'pages_sidebar', null, true, __gettext('Your Content')); } }
function Buildings() { data::initialize(); $this->planet_id = current_planet(); $this->building_id = isset($_REQUEST['building_id']) ? (int) $_REQUEST['building_id'] : NULL; permissions_check(PERMISSION_PLANET, $this->planet_id, array('build', 'commission')); $this->data->updater->update(0, $this->planet_id); $this->quiet = false; }
function Units(&$data, &$smarty) { $this->data =& $data; $this->smarty =& $smarty; $this->sql = new SQL_Generator(); $this->planet_id = current_planet(); $this->unit_type = request_variable('unit_type', NULL, 'army'); $this->unit_id = request_variable('unit_id'); if (!in_array($this->unit_type, array('army', 'navy'))) { error(__FILE__, __LINE__, 'DATA', 'Invalid unit type.'); } if (!empty($this->unit_id)) { permissions_check(PERMISSION_PLANET, $this->planet_id, 'commission'); } $this->smarty->assign('unit_type', $this->unit_type); $this->smarty->assign('unit_id', $this->unit_id); $this->data->updater->update(0, $this->planet_id); }
function file_folder_edit_links($folder) { global $page_owner, $CFG; $foldermenu = ""; if (permissions_check("files:edit", $folder->owner) || permissions_check("files:edit", $folder->files_owner)) { $delete = __gettext("Delete"); // gettext variable $edit = __gettext("Edit"); // gettext variable $foldermenu = <<<END [<a href="{$CFG->wwwroot}mod/file/edit_folder.php?edit_folder_id={$folder->ident}&owner={$page_owner}&return_type=parent">{$edit}</a>] [<a href="{$CFG->wwwroot}mod/file/action_redirection.php?action=delete_folder&delete_folder_id={$folder->ident}">{$delete}</a>] END; } return $foldermenu; }
function upgrade() { $planet_id = $this->planet_id; if (isset($_POST['mode']) && $_POST['mode'] == 'js') { $output_mode = 'javascript'; } else { $output_mode = ''; } permissions_check(PERMISSION_PLANET, $planet_id, 'research'); $designs['main'] = array(0 => 'army', 1 => 'navy', 2 => 'weapon'); foreach ($designs['main'] as $key => $value) { if (!empty($_POST[$value . 'design_id'])) { $design_id = (int) $_POST[$value . 'design_id']; $design_name = $value; $type = $key; break; } } $attribute = $_POST['attribute']; if (empty($design_name) || empty($attribute)) { $status[] = 'No upgrade selected.'; if ($output_mode == 'javascript') { echo 'alert(\'' . implode("\n", $status) . '\'); varUpgrading = false; varError = true;'; exit; } $this->smarty->append('status', $status); $this->overview(); exit; } if ($attribute != mysql_real_escape_string($attribute)) { error(__FILE__, __LINE__, 'DATA_INVALID', 'Invalid attribute selected'); } $db_query = "\n\t\t\t\tSELECT \n\t\t\t\t\t`time`, \n\t\t\t\t\t`workers`, \n\t\t\t\t\t`energy`, \n\t\t\t\t\t`minerals`, \n\t\t\t\t\t`mineralspread`, \n\t\t\t\t\t`techlevel_current`, \n\t\t\t\t\t`techlevel_max`, \n\t\t\t\t\t`" . $attribute . "_base`, \n\t\t\t\t\t`" . $attribute . "_max`, \n\t\t\t\t\t`" . $attribute . "_inc`, \n\t\t\t\t\t`" . $attribute . "_per`, \n\t\t\t\t\t`" . $attribute . "_size`, \n\t\t\t\t\t`" . $attribute . "_sizeinc`, \n\t\t\t\t\t`size_base`, \n\t\t\t\t\t`size_max` \n\t\t\t\tFROM \n\t\t\t\t\t`" . $design_name . "designs` \n\t\t\t\tWHERE \n\t\t\t\t\t`kingdom_id` = '" . $_SESSION['kingdom_id'] . "' AND \n\t\t\t\t\t`" . $design_name . "design_id` = '" . $design_id . "' \n\t\t\t\tLIMIT 1"; $db_result = mysql_query($db_query); if (mysql_num_rows($db_result) == 0) { error(__FILE__, __LINE__, 'DATA_INVALID', 'Invalid design selected'); } $design = mysql_fetch_array($db_result, MYSQL_ASSOC); $design['mineralspread'] = unserialize($design['mineralspread']); if ($design['techlevel_current'] >= $design['techlevel_max']) { $status[] = 'The tech level has been maxed out.'; } if ($design[$attribute . '_base'] == $design[$attribute . '_max']) { $status[] = 'That attribute has been maxed out.'; } if (!empty($status)) { if ($output_mode == 'javascript') { echo 'alert(\'' . implode("\n", $status) . '\'); varUpgrading = false; varError = true;'; exit; } $this->smarty->append('status', $status); $this->overview(); exit; } $db_query = "SELECT `planet_id` FROM `tasks` WHERE `kingdom_id` = '" . $_SESSION['kingdom_id'] . "' AND `type` IN ('2', '3') AND (`planet_id` = '" . $planet_id . "' OR `design_id` = '" . $design_id . "') LIMIT 2"; $db_result = mysql_query($db_query); while ($db_row = mysql_fetch_array($db_result, MYSQL_ASSOC)) { if ($db_row['planet_id'] == $planet_id) { $status[] = 'That planet is already researching something.'; } else { $status[] = 'That design is already being researched elsewhere'; } } if (!empty($status)) { if ($output_mode == 'javascript') { echo 'alert(\'' . implode("\n", $status) . '\'); varUpgrading = false; varError = true;'; exit; } $this->smarty->append('status', $status); $this->overview(); exit; } $db_query = "SELECT `player_id`, `workers`, `energy`, `minerals`, `researchbonus` FROM `planets` WHERE `planet_id` = '" . $planet_id . "' LIMIT 1"; $db_result = mysql_query($db_query); $planet = mysql_fetch_array($db_result, MYSQL_ASSOC); $planet['minerals'] = unserialize($planet['minerals']); $resources = array('workers', 'energy'); foreach ($resources as $value) { $planet[$value] -= $design[$value]; if ($planet[$value] < 0) { $status[] = 'Not enough ' . $value . '.'; } } if (!empty($design['mineralspread'])) { $mineralnames = array(0 => 'fe', 1 => 'o', 2 => 'si', 3 => 'mg', 4 => 'ni', 5 => 's', 6 => 'he', 7 => 'h'); foreach ($design['mineralspread'] as $key => $value) { $mineral = $value / 100 * $design['minerals']; $planet['minerals'][$key] -= $mineral; if ($planet['minerals'][$key] < 0) { $status[] = 'Not enough ' . $mineralnames[$key] . '.'; } } } if (!empty($status)) { if ($output_mode == 'javascript') { echo 'alert(\'' . implode("\n", $status) . '\'); varUpgrading = false; varError = true;'; exit; } $this->smarty->append('status', $status); $this->overview(); exit; } $completion = $design['time'] * $_SESSION['round_speed'] * ((100 - $planet['researchbonus']) / 100); $warptime = request_variable('warptime'); if (!is_null($warptime)) { data::initialize(); $data_planet =& $this->data->planet($planet_id); if ($data_planet['warptime_research'] > $completion) { $data_planet['warptime_research'] -= $completion; $completion = 0; } else { $completion -= $data_planet['warptime_research']; $data_planet['warptime_research'] = 0; } $this->data->save(); } $insert_design = array('round_id' => $_SESSION['round_id'], 'kingdom_id' => $_SESSION['kingdom_id'], 'planet_id' => $planet_id, 'type' => 3, 'design_id' => $design_id, 'attribute' => $attribute, 'number' => $type, 'start' => microfloat(), 'completion' => microfloat() + $completion); $db_result = $this->sql->execute('tasks', $insert_design); $this->sql->set(array(array('planets', 'researching', 1), array('planets', 'workers', $planet['workers']), array('planets', 'energy', $planet['energy']), array('planets', 'minerals', serialize($planet['minerals'])))); $this->sql->where(array('planets', 'planet_id', $planet_id)); $this->sql->limit(1); $db_result = $this->sql->execute(); if ($output_mode == 'javascript') { echo 'varUpgrading = true; varError = false;'; exit; } $_SESSION['status'][] = 'Upgrade successfully started.'; redirect('designs.php'); }
* @author Developer: James Ellis <*****@*****.**> * @copyright Copyright 2010 Queen's University. All Rights Reserved. * */ if (!defined("PARENT_INCLUDED") || !defined("IN_CLERKSHIP") || !defined("IN_ELECTIVES")) { exit; } elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) { header("Location: " . ENTRADA_URL); exit; } elseif (!isset($_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"]) || $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"] != "staff" && $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"] != "medtech" && $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"] != "faculty") { $ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/admin/" . $MODULE . "\\'', 15000)"; $ERROR++; $ERRORSTR[] = "Your account does not have the permissions required to use this feature of this module.<br /><br />If you believe you are receiving this message in error please contact <a href=\"mailto:" . html_encode($AGENT_CONTACTS["administrator"]["email"]) . "\">" . html_encode($AGENT_CONTACTS["administrator"]["name"]) . "</a> for assistance."; echo display_error(); application_log("error", "Group [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"] . "] and role [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["role"] . "] do not have access to this module [" . $MODULE . "]"); } elseif (!permissions_check(array("medtech" => "admin", "faculty" => "admin", "staff" => "admin"))) { $ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/admin/" . $MODULE . "\\'', 15000)"; $ERROR++; $ERRORSTR[] = "Your account does not have the permissions required to use this feature of this module.<br /><br />If you believe you are receiving this message in error please contact <a href=\"mailto:" . html_encode($AGENT_CONTACTS["administrator"]["email"]) . "\">" . html_encode($AGENT_CONTACTS["administrator"]["name"]) . "</a> for assistance."; echo display_error(); application_log("error", "Group [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"] . "] and role [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["role"] . "] does not have access to this module [" . $MODULE . "]"); } else { $BREADCRUMB[] = array("url" => ENTRADA_URL . "/admin/clerkship/electives?" . replace_query(array("section" => "add")), "title" => "Discipline Breakdown"); /** * Add PlotKit to the beginning of the $HEAD array. */ array_unshift($HEAD, "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/MochiKit/MochiKit.js\"></script>", "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/PlotKit/excanvas.js\"></script>", "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/PlotKit/Base.js\"></script>", "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/PlotKit/Layout.js\"></script>", "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/PlotKit/Canvas.js\"></script>", "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/PlotKit/SweetCanvas.js\"></script>"); $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/clerkship_disciplines.js\"></script>"; // Display Content switch ($STEP) { case 2:
<?php define('IK_AUTHORIZED', true); require_once dirname(__FILE__) . '/includes/init.php'; // ############################################### // Prisoner filter prisoner_filter($_SESSION['player_id']); // ############################################### // Validate Function $valid_functions = array('default' => 'planet_extraction', 'planet_extraction_set', 'planet_permissions', 'planet_permissions_set', 'planet_settings', 'planet_settings_set', 'planet_massmanage', 'planet_massmanage_set'); $fn = validate_fn($valid_functions, __FILE__, __LINE__); if (!in_array($fn, array('planet_massmanage', 'planet_massmanage_set'))) { $planet_id = current_planet(); permissions_check(PERMISSION_PLANET, $planet_id, 'owner'); } $updater->update(0, 0, $_SESSION['player_id']); $fn(); function planet_massmanage() { global $smarty, $sql, $data; // get all planets owned by this player // picture, name, food storage & rate, worker storage & rate, energy storage & rate, mineral storage & rate, // [ ] The Past 1.2K +8 1.1K +40 872 +48 0 0 Derrick 1h, 38m $available_planning = $available_cranes = 0; // Retrieve all of the player's planets $player = $data->player($_SESSION['player_id']); $planet_ids = $player['planets']; $planet_ids = array_keys($planet_ids); $planets = $data->planet($planet_ids); if (!empty($planets)) { $db_query = "\n\t\t\t\tSELECT \n\t\t\t\t\tt.`planet_id`, \n\t\t\t\t\tb.`name`, \n\t\t\t\t\tMIN(t.`completion`) as 'completion' \n\t\t\t\tFROM \n\t\t\t\t\t`tasks` t, \n\t\t\t\t\t`buildings` b \n\t\t\t\tWHERE \n\t\t\t\t\tt.`planet_id` IN ('" . implode("', '", array_keys($planets)) . "') AND \n\t\t\t\t\tb.`building_id` = t.`building_id` \n\t\t\t\tGROUP BY t.`planet_id` \n\t\t\t\tLIMIT " . count($planets);
function pages_edit_page($page_name, $owner = -1) { global $CFG, $PAGE; $PAGE->pages->editing = true; if (pages_enabled() && !empty($page_name) && permissions_check('pages::edit', $owner)) { if ($owner == -1 && pages_is_frontpage($page_name)) { $is_frontpage = true; } else { $is_frontpage = false; } if (!($page = get_record('pages', 'uri', $page_name, 'owner', $owner))) { // try to edit legacy content if ($owner == -1) { $page = pages_get_legacy($page_name); } } else { pages_current_page($page); } $page = pages_input_override($page, $owner, false); if (isset($page->ident)) { $page->ident = intval($page->ident); } //if frontpage force some value if ($is_frontpage) { $page->name = $page_name; $page->parent = -1; //hidden $page->access = 'PUBLIC'; //force public } $title_enc = htmlspecialchars($page->title, ENT_QUOTES, 'utf-8'); //$page->content = htmlspecialchars(stripslashes($page->content), ENT_COMPAT, 'utf-8'); $page->content = trim($page->content); $page->name = htmlspecialchars($page->name, ENT_QUOTES, 'utf-8'); $input_title = pages_html_wrap('label', __gettext('Title:'), array('for' => 'page-title')); $input_title .= pages_html_input('text', array('id' => 'page-title', 'name' => 'page-title', 'value' => $title_enc, 'maxlength' => 127, 'style' => 'width:100%;')); $input_content = pages_html_wrap('label', __gettext('Content:'), array('for' => 'page-content')); $input_content .= pages_html_wrap('textarea', htmlspecialchars($page->content, ENT_NOQUOTES, 'utf-8'), array('id' => 'page-content', 'name' => 'page-content', 'rows' => 20, 'cols' => '79', 'style' => 'width:100%;')); if ($is_frontpage) { $input_menu = pages_html_input('hidden', array('name' => 'page-name', 'value' => stripslashes($page->name))); $input_default = null; $input_parent = pages_html_input('hidden', array('name' => 'menu-parent', 'value' => -1)); $input_weight = null; $input_access = pages_html_input('hidden', array('name' => 'page-access', 'value' => 'PUBLIC')); } else { $input_menu = pages_html_wrap('label', __gettext('Menu title:'), array('for' => 'page-name')); $input_menu .= pages_html_input('text', array('id' => 'page-name', 'name' => 'page-name', 'value' => stripslashes($page->name), 'maxlength' => 127)); if (!isset($page->ident) && $page_name == __gettext('Main')) { $page_default = 'checked'; } else { $page_default = pages_is_default(isset($page->ident) ? $page->ident : 0, $owner) ? 'checked' : 'dummy'; } if ($page_default == 'dummy') { $input_default = pages_html_wrap('label', __gettext('Make default:'), array('for' => 'page-default')); $input_default .= pages_html_input('checkbox', array('id' => 'page-default', 'name' => 'page-default', $page_default => $page_default)); } else { // hidden checked input $input_default = pages_html_input('hidden', array('name' => 'page-default', 'value' => true)); } $input_parent = pages_html_wrap('label', __gettext('Parent element:'), array('for' => 'menu-parent')); if (isset($page->ident)) { $menu_parents = get_records_select('pages', 'parent=? AND ident<>? AND owner=?', array(0, $page->ident, $owner)); } else { $menu_parents = get_records_select('pages', 'parent=? AND owner=?', array(0, $owner)); } $menu_parents_opts = array(); $menu_parents_opts[] = (object) array('label' => __gettext('Top menu'), 'value' => 0); if (is_array($menu_parents)) { foreach ($menu_parents as $m) { $opt = new StdClass(); $opt->value = $m->ident; $opt->label = '- ' . $m->name; if ($m->ident == $page->parent) { $opt->selected = true; } $menu_parents_opts[] = $opt; } } $input_parent .= pages_html_select('menu-parent', $menu_parents_opts, array('id' => 'menu-parent')); $input_weight = pages_html_wrap('label', __gettext('Weight:'), array('for' => 'menu-weight')); $weights = array(); for ($i = -10; $i <= 10; $i++) { $w = (object) array('label' => " {$i}", 'value' => $i); if ($page->weight == $i) { $w->selected = true; } $weights[] = $w; } $input_weight .= pages_html_select('menu-weight', $weights, array('id' => 'menu-weight')); // access level $input_access = pages_html_wrap('label', __gettext('Access:'), array('for' => 'page-access')); $input_access .= run('display:access_level_select', array('page-access', $page->access)); } // help $form_help = __gettext('You can use {{page}} keyword to link to others pages.'); $form_help .= '<br />» '; $form_help .= __gettext('<em>{{page:About_me}}</em> will link to your page with menu title "About me". e.g. {{page:Main}}'); $form_help .= '<br />» '; $form_help .= __gettext('<em>{{page:user:Title}}</em> will link to user\'s page "Title". e.g. {{page:news:Main}}'); $form_help .= '<br />» '; $form_help .= __gettext('<em>{{page:content:Title}}</em> will link to site main pages "Title". e.g. {{page:content:About}}'); $form_help = pages_html_wrap('p', $form_help); $input_buttons = pages_html_input('submit', array('id' => 'page-save', 'name' => 'submit', 'value' => __gettext('Save page'))); $input_buttons .= pages_html_input('submit', array('id' => 'page-preview', 'name' => 'submit', 'value' => __gettext('Preview'))); if ($page->name != 'New page' && !$is_frontpage) { $input_buttons .= pages_html_input('submit', array('id' => 'page-delete', 'name' => 'submit', 'value' => __gettext('Delete'), 'onclick' => 'return confirm_delete()')); $confirm_delete = __gettext('Are you sure that you want to delete this page?'); $input_buttons .= pages_html_wrap('script', "\n <!--\n function confirm_delete() {\n return confirm('{$confirm_delete}');\n }\n -->\n ", array('type' => 'text/javascript')); } // hidden action $input_buttons .= pages_html_input('hidden', array('name' => 'action', 'value' => 'pages:edit')); $content = pages_html_wrap('div', $input_title, array('class' => 'form-item')); $content .= pages_html_wrap('div', $input_content, array('class' => 'form-item')); $content .= pages_html_wrap('div', $form_help, array('class' => 'form-item')); $content .= pages_html_wrap('div', $input_menu . $input_default, array('class' => 'form-item')); $content .= pages_html_wrap('div', $input_parent . $input_weight, array('class' => 'form-item')); $content .= pages_html_wrap('div', $input_access, array('class' => 'form-item')); $content .= pages_html_wrap('div', $input_buttons, array('class' => 'form-item form-button')); $content = pages_html_wrap('form', $content, array('id' => 'page-form', 'method' => 'post', 'action' => $_SERVER['REQUEST_URI'])); // check for preview action if (optional_param('submit') == __gettext('Preview')) { $content = pages_preview_page($page) . $content; } // override content $page->content = $content; } else { $page = pages_page_denied(); } if (empty($page)) { $page = pages_page_not_found(); } return $page; }
function modify_targets() { if (empty($_POST['weapons'])) { error(__FILE__, __LINE__, 'INVALID_INPUT', 'Invalid input.'); } permissions_check(constant('PERMISSION_' . strtoupper($this->group_type)), $this->group_id, 'military'); $group =& $this->data->group($this->group_type, $this->group_id); foreach ($_POST['weapons'] as $key => $value) { $key = (int) $key; if (!empty($key)) { if (empty($value)) { unset($group['targets'][$key]); } else { $group['targets'][$key] = $value; } } } $this->data->save(); redirect('groups.php?fn=groups_view&group_id=' . $this->group_id . '&group_type=' . $this->group_type . '&group_view=' . $this->group_view); }
function planet() { // If requesting a specific / relative planet if (isset($_REQUEST['planet_id'])) { $planet_id = $_REQUEST['planet_id']; // Let's duplicate our effort for sake of simplicity. We can always refactor later. if (in_array($planet_id, array('previous', 'next'))) { $planetList = 'own'; $action = $planet_id; $player =& $this->data->player($_SESSION['player_id']); $planets = $player['planets']; $planet_current = $player['planet_current']; $planet_id = $this->get_adjacent_planet($planets, $planet_current, $action); $this->set_current_planet($player, $planet_id, $planetList); } else { if (in_array($planet_id, array('previous_permissions', 'next_permissions'))) { $planetList = 'permission'; if ($planet_id == 'previous_permissions') { $action = 'previous'; } else { $action = 'next'; } permissions_update_planets($_SESSION['player_id']); $player =& $this->data->player($_SESSION['player_id']); $planets = $player['planets_permissions']; $planet_current = $player['planet_permission_current']; if (empty($planets)) { $this->smarty->append('status', 'You do not have permission to access any other planets'); $this->smarty->display('error.tpl'); exit; } $planet_id = $this->get_adjacent_planet($planets, $planet_current, $action); $this->set_current_planet($player, $planet_id, $planetList); } else { $planet_id = abs((int) $planet_id); } } $_SESSION['planet_id'] = $planet_id; } else { $player =& $this->data->player($_SESSION['player_id']); $planet_id = $player['planet_current']; } $this->data->updater->update(0, $planet_id); $permissions = permissions_check(PERMISSION_PLANET, $planet_id); $round = $this->data->round(); $planet = $this->data->planet($planet_id); if (!empty($planet['player_id'])) { $player = $this->data->player($planet['player_id']); $planet['player_name'] = strshort($player['name'], 15); if ($player['npc'] == 1) { $planet['npc_player'] = true; } } if (!empty($planet['kingdom_id'])) { $kingdom = $this->data->kingdom($planet['kingdom_id']); $planet['kingdom_name'] = strshort($kingdom['name'], 15); } $planet['permissions'] = $permissions; if ($planet['player_id'] == $_SESSION['player_id']) { $_SESSION['planet_id'] = $planet['planet_id']; } $planet['score'] = format_number($planet['score']); $planet['score_peak'] = format_number($planet['score_peak']); if ($permissions['grant']) { if (!empty($planet['minerals'])) { $planet['minerals'] = array_sum($planet['minerals']); } else { $planet['minerals'] = 0; } $resource_deficiency = 0; foreach (array('food', 'workers', 'energy', 'minerals') as $resource) { if ($resource_deficiency != 0) { $planet[$resource . 'deficiency'] = $planet[$resource . 'rate']; } $planet[$resource . 'rate'] += $resource_deficiency; if ($planet[$resource . 'rate'] < 0 && $planet[$resource] < abs($planet[$resource . 'rate'])) { $resource_deficiency = $planet[$resource . 'rate'] + $planet[$resource]; } $planet[$resource] = format_number($planet[$resource], true); $planet[$resource . 'rate'] = format_number($planet[$resource . 'rate'], true, true); } if ($permissions['build']) { $types[] = 1; } if ($permissions['research']) { $types[] = 2; $types[] = 3; } if ($permissions['commission']) { $types[] = 4; } unset($planet['researching'], $planet['building'], $planet['army'], $planet['navy']); // Get tasks currently running on the planet $db_query = "SELECT DISTINCT `task_id`, `attribute`, `number`, `type` FROM `tasks` WHERE `round_id` = '" . $_SESSION['round_id'] . "' AND `planet_id` = '" . $planet_id . "' AND `type` IN ('" . implode("', '", $types) . "') ORDER BY `completion` DESC"; $db_result_tasks = mysql_query($db_query); while ($tasks = mysql_fetch_array($db_result_tasks, MYSQL_ASSOC)) { $this->sql->select(array('tasks', 'completion')); $this->sql->where(array(array('tasks', 'round_id', $_SESSION['round_id']), array('tasks', 'task_id', $tasks['task_id']))); $this->sql->limit(1); switch ($tasks['type']) { case 1: $this->sql->select(array('buildings', 'name')); $this->sql->where(array('buildings', 'building_id', array('tasks', 'building_id'))); $db_result = $this->sql->execute(); $db_row = mysql_fetch_array($db_result, MYSQL_ASSOC); $planet['building']['name'] = strshort($db_row['name'], 15); $planet['building']['time'] = format_time(timeparser($db_row['completion'] - microfloat())); break; case 2: $this->sql->select(array('concepts', 'name')); $this->sql->where(array('concepts', 'concept_id', array('tasks', 'concept_id'))); $db_result = $this->sql->execute(); $db_row = mysql_fetch_array($db_result, MYSQL_ASSOC); $planet['researching']['name'] = strshort($db_row['name'], 15); $planet['researching']['time'] = format_time(timeparser($db_row['completion'] - microfloat())); break; case 3: $designs = array('army', 'navy', 'weapon'); $this->sql->select(array($designs[$tasks['number']] . 'designs', 'name')); $this->sql->where(array($designs[$tasks['number']] . 'designs', $designs[$tasks['number']] . 'design_id', array('tasks', 'design_id'))); $db_result = $this->sql->execute(); $db_row = mysql_fetch_array($db_result, MYSQL_ASSOC); $planet['researching']['name'] = strshort($db_row['name'], 15); $planet['researching']['time'] = format_time(timeparser($db_row['completion'] - microfloat())); break; case 4: $this->sql->select(array($tasks['attribute'] . 'blueprints', 'name')); $this->sql->where(array($tasks['attribute'] . 'blueprints', $tasks['attribute'] . 'blueprint_id', array('tasks', 'unit_id'))); $db_result = $this->sql->execute(); $db_row = mysql_fetch_array($db_result, MYSQL_ASSOC); $planet[$tasks['attribute']]['name'] = strshort($db_row['name'], 15); $planet[$tasks['attribute']]['time'] = format_time(timeparser($db_row['completion'] - microfloat())); break; } } $planet['nextupdate'] = format_time($round['resourcetick'] - (microfloat() - $planet['lastupdated'])); } $this->smarty->assign('planet', $planet); $this->smarty->display('info_planet.tpl'); }
<?php global $CFG; global $folder; global $page_owner; $file_id = optional_param('edit_file_id', 0, PARAM_INT); if (!empty($file_id)) { $file = get_record_sql('SELECT f.*,u.username FROM ' . $CFG->prefix . 'files f JOIN ' . $CFG->prefix . 'users u ON u.ident = f.owner WHERE f.ident = ?', array($file_id)); if (!empty($file) && (permissions_check("files:edit", $file->owner) || permissions_check("files:edit", $file->files_owner))) { $page_owner = $file->files_owner; $description = stripslashes($file->description); $title = htmlspecialchars(stripslashes($file->title), ENT_COMPAT, 'utf-8'); $fileLabel = __gettext("File title:"); // gettext variable $body = <<<END <form action="{$CFG->wwwroot}mod/file/action_redirection.php" method="post"> <div id="edit_files"> <table width="80%"> <tr> <td width="30%"> <h4><label for="edit_file_title">{$fileLabel}</label></h4> </td> <td width="70%"> END; $body .= display_input_field(array("edit_file_title", $title, "text")); $fileDesc = __gettext("File description:"); // gettext variable $body .= <<<END </td>
$folder_object->handler = "elgg"; } if ($folder_object->ident != -1) { $parent = (int) $folder_object->parent; if ($parent != -1) { $parent_details = get_record('file_folders', 'ident', $parent, 'files_owner', $owner); $display_parent = $parent; } else { //$parent_details->name = __gettext("Root Folder"); $parent_details->ident = -1; $display_parent = ""; } $run_result .= "<p><a href=\"" . url . user_info("username", $owner) . "/files/{$display_parent}\">"; $run_result .= "" . __gettext("Return to") . " " . stripslashes($parent_details->name); $run_result .= "</a></p>"; } // If we're in the root or an accessible folder, view it if ($accessible) { if (!isset($folder_object->handler) || !isset($CFG->folders->handler[$folder_object->handler])) { $run_result .= run("files:folder:view", $folder); } else { if (is_callable($CFG->folders->handler[$folder_object->handler]['view'])) { $run_result .= $CFG->folders->handler[$folder_object->handler]['view']($folder_object); } } } // If this is the user's own file repository, allow him or her to edit it if (permissions_check("files", $page_owner)) { $run_result .= run("files:folder:edit", $folder); //$run_result .= run("files:file:upload",$folder); }
function research() { // FIXME $concept_id = $this->concept_id; $planet_id = $this->planet_id; if (isset($_POST['mode']) && $_POST['mode'] == 'js') { $output_mode = 'javascript'; } else { $output_mode = ''; } $this->output_mode = $output_mode; $status = array(); permissions_check(PERMISSION_PLANET, $planet_id, 'research'); $kingdom =& $this->data->kingdom($_SESSION['kingdom_id']); if (!isset($kingdom['concepts'][$concept_id])) { $status[] = 'The concept you selected does not exist, has already been researched, or is outside of your grasp.'; $this->research_checkerror($status); } $db_query = "SELECT `planet_id` FROM `tasks` WHERE `kingdom_id` = '" . $_SESSION['kingdom_id'] . "' AND `type` IN ('" . TASK_RESEARCH . "', '" . TASK_UPGRADE . "') AND (`planet_id` = '" . $planet_id . "' OR `concept_id` = '" . $concept_id . "') LIMIT 2"; $db_result = mysql_query($db_query); while ($db_row = mysql_fetch_array($db_result, MYSQL_ASSOC)) { if ($db_row['planet_id'] == $planet_id) { $status[] = 'That planet is already researching something.'; } else { $status[] = 'That concept is already being researched elsewhere'; } } $this->research_checkerror($status); $planet =& $this->data->planet($planet_id); $concept = $this->data->concept($concept_id); $score = 0; $resources = array('workers' => SCORE_WORKERS, 'energy' => SCORE_ENERGY); foreach ($resources as $key => $value) { $score += $concept[$key] * $value; $planet[$key] -= $concept[$key]; $kingdom[$key] -= $concept[$key]; if ($planet[$key] < 0) { $status[] = 'Not enough ' . $key . '.'; } } if (!empty($concept['mineralspread'])) { $mineralnames = array(0 => 'fe', 1 => 'o', 2 => 'si', 3 => 'mg', 4 => 'ni', 5 => 's', 6 => 'he', 7 => 'h'); foreach ($concept['mineralspread'] as $key => $value) { $mineral = $value / 100 * $concept['minerals']; $score += $mineral * SCORE_MINERALS; $planet['minerals'][$key] -= $mineral; if ($planet['minerals'][$key] < 0) { $status[] = 'Not enough ' . $mineralnames[$key] . '.'; } } $kingdom['minerals'] -= $concept['minerals']; } $this->research_checkerror($status); $player =& $this->data->player($planet['player_id']); $research_bonus = $planet['researchbonus'] < 85 ? $planet['researchbonus'] : 85; $completion = $concept['time'] * $_SESSION['round_speed'] * ((100 - $research_bonus) / 100); $planet['researching']++; $planet['score'] -= $score; $player['score'] -= $score; $warptime = request_variable('warptime'); if (!is_null($warptime)) { if ($planet['warptime_research'] > $completion) { $planet['warptime_research'] -= $completion; $completion = 0; } else { $completion -= $planet['warptime_research']; $planet['warptime_research'] = 0; } } $now = microfloat(); $task_insert = array('round_id' => $_SESSION['round_id'], 'kingdom_id' => $_SESSION['kingdom_id'], 'player_id' => $planet['player_id'], 'planet_id' => $planet['planet_id'], 'type' => TASK_RESEARCH, 'concept_id' => $this->concept_id, 'completion' => $now + $completion, 'start' => $now); $this->sql->execute('tasks', $task_insert); $this->data->save(); if ($output_mode == 'javascript') { echo 'varResearching = true; varError = false;'; exit; } if ($completion == 0) { $_SESSION['status'][] = 'Research successfully completed.'; } else { $_SESSION['status'][] = 'Research successfully started.'; } redirect('research.php'); }
<?php global $CFG; global $folder; global $page_owner; global $folder_name; // global $folder is current working directory // global $folder_name is current working directory name, but only // automatically set when viewed $folder_name = htmlspecialchars($folder_name, ENT_COMPAT, 'utf-8'); $this_folder = optional_param('edit_folder_id', 0, PARAM_INT); if ($this_folder != 0) { $folder_details = get_record('file_folders', 'ident', $this_folder); if (!empty($folder) && (permissions_check("files:edit", $folder_details->owner) || permissions_check("files:edit", $folder_details->files_owner))) { // $edit = __gettext("Edit this folder"); // gettext variable $run_result .= <<<END <form action="" method="post"> END; $labelValue = __gettext("Folder name:"); // gettext variable $parentFolder = __gettext("Parent folder:"); // gettext variable $folderType = __gettext("Folder type:"); // gettext variable $folderTypePicker = file_folder_type_switcher($folder_details, "edit_folder_type"); $body = <<<END <table width="100%"> <tr> <td width="30%"> <p><label for="new_folder_name"> {$labelValue}