Example #1
0
 public static function create()
 {
     if (!Input::has('name')) {
         App::abort(400);
     }
     $user = Auth::user();
     $map = new Map();
     $map->width = 512;
     $map->height = 512;
     $map->name = Input::get('name');
     $map->description = Input::has('description') ? Input::get('description') : '';
     $map->version = 960;
     $map->save();
     $ownership = new Permission();
     $ownership->mapid = $map->id;
     $ownership->userid = $user->id;
     $ownership->owner = true;
     $ownership->edit = true;
     $ownership->view = true;
     $ownership = $map->permissions()->save($ownership);
     $minimap = new Minimap();
     $minimap->mapid = $map->id;
     $minimap->updated_at = new \DateTime();
     $minimap = $map->minimap()->save($minimap);
     \OTWorlds\MinimapPainter::$filename = $minimap->path;
     \OTWorlds\MinimapPainter::create(512, 512);
     \OTWorlds\MinimapPainter::save();
     return $map->id;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $rules = array('name' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         // Get the inputs, with some exceptions
         $inputs = Input::except('csrf_token');
         $this->map->name = $inputs['name'];
         $this->map->save();
         // Save permissions
         $this->role->perms()->sync($this->permission->preparePermissionsForSave($inputs['permissions']));
         // Was the map created?
         if ($this->map->id) {
             return Api::to(array('success', Lang::get('admin/maps/messages.create.success'))) ?: Redirect::to('admin/maps/' . $this->map->id . '/edit')->with('success', Lang::get('admin/maps/messages.create.success'));
         } else {
             return Api::to(array('error', Lang::get('admin/maps/messages.create.error'))) ?: Redirect::to('admin/maps/create')->withInput()->with('error', Lang::get('admin/maps/messages.create.error'));
         }
     } else {
         return Api::to(array('error', Lang::get('admin/maps/messages.create.error'))) ?: Redirect::to('admin/maps/create')->withInput()->withErrors($validator);
     }
 }
Example #3
0
 /**
  * Initilizes the Rcon instance.
  *
  * @return void
  */
 public function initRcon()
 {
     try {
         $rcon = new Rcon($this->map->match->server->ip, $this->map->match->server->port, $this->map->match->server->rcon);
         Logger::log("connecting to rcon {$this->map->match->server->ip}:{$this->map->match->server->port}", Logger::LEVEL_DEBUG);
         $rcon->connect();
     } catch (RconConnectException $e) {
         Logger::log("Could not connect to the CS:GO server. {$e->getMessage()}", Logger::LEVEL_ERROR);
         $this->map->status = 0;
         $this->map->save();
         return;
     } catch (RconAuthException $e) {
         Logger::log("Could not authenticate with the CS:GO server. {$e->getMessage()}", Logger::LEVEL_ERROR);
         $this->map->status = 0;
         $this->map->save();
         return;
     }
     Logger::log('successfully connected to rcon', Logger::LEVEL_DEBUG);
     $this->rcon = $rcon;
     $this->chat = new DefaultChat($this->rcon);
     // temp
 }
Example #4
0
<?php

// Lib
include 'lib/tmhOAuth/tmhOAuth.php';
include 'lib/tmhOAuth/tmhUtilities.php';
include 'class/city.php';
include 'class/map.php';
// Config
include 'config.php';
// Auth
$tmhOAuth = new tmhOAuth(array('consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'user_token' => $user_token, 'user_secret' => $user_secret));
// Path
if (!is_dir('exports') && !mkdir('exports')) {
    exit;
}
$pathinfo = pathinfo($path = 'exports/' . time() . '.jpg');
$name = $pathinfo['basename'];
// Map
$map = new Map();
if (!$map->save($path) || !($path = realpath($path))) {
    exit;
}
// Params
$image = array("@{$path}", 'type=image/jpeg', "filename={$name}");
$params = array('image' => implode(';', $image), 'use' => 'true');
// Request
$code = $tmhOAuth->request('POST', $tmhOAuth->url('1/account/update_profile_background_image'), $params, true, true);
// Response
echo $code;
/**
 * Google Maps Draw Module
 * @package drawonmaps
 * 
 * Class: SiteConf
 * File: functions.php
 * Description: General functions of the tool
 */
function save_map($post_list)
{
    $vars_tmp = array();
    $map_id = $post_list['map_id'];
    if ($map_id > 0) {
        try {
            $map = new Map($map_id);
        } catch (Exception $e) {
            $vars_tmp['error_msg'] = $e->getMessage();
        }
    } else {
        $map = new Map();
    }
    $map->title = trim($post_list['map_title']);
    $map->description = trim($post_list['map_description']);
    $map->center_lat = $post_list['map_center_lat'];
    $map->center_lng = $post_list['map_center_lng'];
    $map->zoom = intval($post_list['map_zoom']);
    $map->typeid = trim($post_list['map_typeid']);
    $map->user_id = 0;
    $result = $map->save();
    if ($result) {
        //load the new created map
        $map = new Map($result);
        $vars_tmp['map'] = $map;
        $vars_tmp['error_msg'] = '';
        if ($map_id > 0) {
            // delete map objects only for existing maps
            $map->deleteMapObjects();
        }
        if ($post_list['marker_title']) {
            foreach ($post_list['marker_title'] as $key => $n) {
                // new map marker record created
                $get_object_id = $map->updateMapObject($n, $post_list['marker_coords'][$key], 1, null, $post_list['marker_icon'][$key]);
                if (!$get_object_id[0]) {
                    $vars_tmp['error_msg'] .= $get_object_id[1];
                }
            }
        }
        if ($post_list['line_title']) {
            foreach ($post_list['line_title'] as $key => $n) {
                // new map polyline record created
                $get_object_id = $map->updateMapObject($n, $post_list['line_coords'][$key], 2);
                if (!$get_object_id[0]) {
                    $vars_tmp['error_msg'] .= $get_object_id[1];
                }
            }
        }
        if ($post_list['poly_title']) {
            foreach ($post_list['poly_title'] as $key => $n) {
                // new map polygon record created
                $get_object_id = $map->updateMapObject($n, $post_list['poly_coords'][$key], 3);
                if (!$get_object_id[0]) {
                    $vars_tmp['error_msg'] .= $get_object_id[1];
                }
            }
        }
        if ($post_list['rect_title']) {
            foreach ($post_list['rect_title'] as $key => $n) {
                // new map rectagle record created
                $get_object_id = $map->updateMapObject($n, $post_list['rect_coords'][$key], 4);
                if (!$get_object_id[0]) {
                    $vars_tmp['error_msg'] .= $get_object_id[1];
                }
            }
        }
        if ($post_list['circle_title']) {
            foreach ($post_list['circle_title'] as $key => $n) {
                // new map circle record created
                $get_object_id = $map->updateMapObject($n, $post_list['circle_coords'][$key], 5);
                if (!$get_object_id[0]) {
                    $vars_tmp['error_msg'] .= $get_object_id[1];
                }
            }
        }
    }
    $vars_tmp['success_msg'] = 'The map <strong>' . $map->title . '</strong> saved successfully';
    $vars_load = load_map($map->id);
    if (is_array($vars_load)) {
        $vars_tmp = array_merge($vars_tmp, $vars_load);
    }
    return $vars_tmp;
}