public function process() { $user = user::getInstance(); $db = db::getInstance(); include './models/game.class.php'; include './models/grid.class.php'; // récupérer le gameid $this->gameid = isset($_REQUEST['gameid']) ? intval($_REQUEST['gameid']) : false; if ($this->gameid === false) { trigger_error('Game not found', E_USER_ERROR); } // lecture de l'objet game $game = new game(); $game->read($this->gameid); // création d'une nouvelle grille $gridtype = GRIDTYPE_ALLWORDS; $grid = new grid(); $gridid = $grid->create($gridtype); // ajout de la grille au game $game->assign_grid($gridid); $game->start_grid($gridid); // enrichissement du retour json $res = $grid->get(); $res->gameid = $this->gameid; $res->gametype = GAMETYPE_PRACTICE_ALLWORDS; header('Content-Type: application/json'); echo json_encode($res); die; }
function index() { $this->load->library('grid'); $gridObj = new grid(); $gridColumn = array("Name", "Birthdate", "Username", "Present Address", "Phone", "Email", "Status"); $gridColumnModel = array(array("name" => "name", "index" => "name", "width" => 60, "sortable" => true, "align" => "left", "editable" => false), array("name" => "birthdate", "index" => "birthdate", "width" => 90, "sortable" => true, "align" => "left", "editable" => false), array("name" => "username", "index" => "username", "width" => 90, "sortable" => true, "align" => "left", "editable" => false), array("name" => "present_address", "index" => "present_address", "width" => 60, "sortable" => true, "align" => "left", "editable" => false), array("name" => "phone", "index" => "phone", "width" => 60, "sortable" => true, "align" => "left", "editable" => false), array("name" => "email", "index" => "email", "width" => 90, "sortable" => true, "align" => "left", "editable" => false), array("name" => "status", "index" => "status", "width" => 60, "sortable" => true, "align" => "left", "editable" => false)); $gridObj->setGridOptions("Member List", 880, 250, "id", "asc", $gridColumn, $gridColumnModel, site_url('publisher/get_publisher_list'), true); $data['grid_data'] = $gridObj->getGrid(); $data['msg'] = $this->session->flashdata('msg'); $data['upload_success_msg'] = $this->session->flashdata('upload_success_msg'); $data['dir'] = 'publisher'; $data['page'] = 'publisher_listing'; $this->load->view('main', $data); }
function index() { if (!common::is_logged_in()) { redirect('login'); } $this->load->library('grid'); $gridObj = new grid(); $gridColumn = array("ID", "User Name", "Password", "Email"); $gridColumnModel = array(array("name" => "id", "index" => "id", "width" => 90, "sortable" => true, "align" => "center", "editable" => false), array("name" => "user_id", "index" => "user_id", "width" => 150, "sortable" => true, "align" => "center", "editable" => false), array("name" => "password", "index" => "password", "width" => 150, "sortable" => true, "align" => "center", "editable" => false), array("name" => "email", "index" => "email", "width" => 200, "sortable" => true, "align" => "left", "editable" => false)); $gridObj->setGridOptions("Admin Info", 880, 250, "date", "desc", $gridColumn, $gridColumnModel, site_url('admn/load_admin'), true); $data['grid_data'] = $gridObj->getGrid(); $data['msg'] = $this->session->flashdata('msg'); $data['dir'] = 'admn'; $data['page'] = 'admn_lising'; $this->load->view('main', $data); }
public function index() { $this->theme->content = new View('game/index'); $games = ORM::factory('game')->find_all(); $game_list = '<ol>'; foreach ($games as $game) { $game_list .= '<li>' . $game->name . ' - (<a href="/admin/game/edit/' . $game->id . '">Edit</a> - <a href="/admin/game/delete/' . $game->id . '">Delete</a>)</li>'; } $game_list .= '</ol>'; $per_page = 25; $page_num = $this->input->get('page', 1); $offset = ($page_num - 1) * $per_page; $scenarios = ORM::factory('scenario')->with('game')->limit($per_page, $offset)->orderby('id'); grid::add_column(array('field' => 'id', 'align' => 'center', 'label' => 'ID')); grid::add_column(array('field' => 'name', 'align' => 'left', 'label' => 'Name')); grid::add_column(array('field' => 'game', 'align' => 'center', 'label' => 'Game')); /* $scenario_list = '<ol>'; foreach ($scenarios as $scenario) { $scenario_list .= '<li>'.$scenario->name.' - (<a href="/admin/scenario/edit/'.$scenario->id.'">Edit</a> - <a href="/admin/scenario/delete/'.$scenario->id.'">Delete</a>)</li>'; } $scenario_list .= '</ol>'; */ $this->theme->content->game_list = $game_list; $this->theme->content->scenario_list = grid::create_grid($scenarios, $per_page); $this->theme->render(TRUE); }
public function process() { $db = db::getInstance(); $user = user::getInstance(); include './models/game.class.php'; include './models/grid.class.php'; // récupérer le gameid $this->gameid = isset($_REQUEST['gameid']) ? intval($_REQUEST['gameid']) : false; if ($this->gameid === false) { trigger_error('Game not found', E_USER_ERROR); } // lecture de l'objet game $game = new game(); $game->read($this->gameid); // lire les grilles terminées pour trouver le prochain type de grille $sql = 'SELECT COUNT(gridid) AS count_gridid FROM gamesstatus WHERE gameid = ' . intval($this->gameid) . ' AND userid = ' . intval($user->id) . ' AND gridstatus = ' . intval(GRIDSTATUS_FINISHED); $result = $db->query($sql); $grid_count = ($row = $result->fetch_assoc()) ? intval($row['count_gridid']) : 0; // déterminer le prochain type de grille switch ($grid_count) { case 0: $gridtype = GRIDTYPE_ALLWORDS; break; case 1: $gridtype = GRIDTYPE_LONGEST; break; case 2: $gridtype = GRIDTYPE_CONSTRAINTS; break; } // création d'une nouvelle grille $grid = new grid(); $gridid = $grid->create($gridtype); // ajout de la grille au game $game->assign_grid($gridid); $game->start_grid($gridid); $res = $grid->get(); $res->gameid = $this->gameid; $res->gametype = GAMETYPE_PRACTICE_FULL; header('Content-Type: application/json'); echo json_encode($res); die; }
function index() { $this->load->library('grid'); $gridObj = new grid(); $gridColumn = array("Company Name", "Description", "Dead Line", "URL", "Status"); $gridColumnModel = array(array("name" => "company_name", "index" => "company_name", "width" => 90, "sortable" => true, "align" => "left", "editable" => false), array("name" => "description", "index" => "description", "width" => 60, "sortable" => true, "align" => "left", "editable" => false), array("name" => "dead_line", "index" => "dead_line", "width" => 60, "sortable" => true, "align" => "left", "editable" => false), array("name" => "url", "index" => "url", "width" => 90, "sortable" => true, "align" => "left", "editable" => false), array("name" => "status", "index" => "status", "width" => 60, "sortable" => true, "align" => "left", "editable" => false)); $gridObj->setGridOptions("Advertise List", 880, 250, "add_id", "asc", $gridColumn, $gridColumnModel, site_url('publisher/get_publisher_list_1'), true); $data['grid_data'] = $gridObj->getGrid(); //$data['a'] = $this->mod_advertise->get_my_applicants_detail(); // print_r($data['a']); // exit(); $data['msg'] = $this->session->flashdata('msg'); $data['upload_success_msg'] = $this->session->flashdata('upload_success_msg'); $data['dir'] = 'advertise'; $data['page'] = 'advertise_listing'; $this->load->view('main', $data); }
function doRead($REQUEST, $report = 0) { $grid = new grid(true); $grid->setTable("sppk"); //set tablenya //$grid->setGroupBy($REQUEST['groupBy']); $grid->addField(array("field" => "id", "name" => "id", "primary" => true)); $grid->addField(array("field" => "jenis", "name" => "jenis")); $grid->addField(array("field" => "tanggal", "name" => "tanggal")); $grid->addField(array("field" => "perihal", "name" => "perihal")); $grid->addField(array("field" => "kode", "name" => "kode")); $grid->addField(array("field" => "tahun", "name" => "tahun")); if ($report) { return $grid->doSql($REQUEST); } else { return $grid->doRead($REQUEST); } }
function index() { $data['nav_array'] = array(array('title' => 'Manage Users', 'url' => '')); $this->load->library('grid'); $gridObj = new grid(); $gridColumn = array('User Name', "Password", "Status"); $gridColumnModel = array(array("name" => "username", "index" => "username", "width" => 100, "sortable" => true, "align" => "left", "editable" => true), array("name" => "password", "index" => "password", "width" => 100, "sortable" => true, "align" => "left", "editable" => true), array("name" => "status", "index" => "status", "width" => 80, "sortable" => true, "align" => "center", "editable" => true)); if ($_POST['apply_filter']) { $gridObj->setGridOptions("Manage Users", 880, 200, "id", "asc", $gridColumn, $gridColumnModel, site_url("?c=user&m=load_users&searchField={$_POST['searchField']}&searchValue={$_POST['searchValue']}"), true); } else { $gridObj->setGridOptions("Manage Users", 880, 200, "id", "asc", $gridColumn, $gridColumnModel, site_url('user/load_users'), true); } $data['grid_data'] = $gridObj->getGrid(); $data['msg'] = $this->session->flashdata('msg'); $data['dir'] = 'user'; $data['page'] = 'index'; $data['page_title'] = 'Manage Users'; $this->load->view('main', $data); }
function getChart($REQUEST) { $grid = new grid(true); $grid->setTable("grafik"); $grid->setGroupBy("tahun"); $grid->addField(array("field" => "tahun", "name" => "tahun")); $grid->addField(array("field" => "SUM(page_view)", "name" => "page_view")); $grid->addField(array("field" => "SUM(page_visit)", "name" => "page_visit")); return $grid->doRead($REQUEST); }
function index() { if (!common::view_permit()) { common::redirect(); } $gridObj = new grid(); $gridColumn = array("Question", "Type", "Status"); $gridColumnModel = array(array("name" => "texts", "index" => "texts", "width" => 200, "sortable" => true, "align" => "left", "editable" => true), array("name" => "type", "index" => "type", "width" => 100, "sortable" => true, "align" => "center", "editable" => true), array("name" => "status", "index" => "status", "width" => 100, "sortable" => true, "align" => "center", "editable" => true)); if ($_POST['apply_filter']) { //$this->session->set_userdata('type', $_POST['searchField']); $gridObj->setGridOptions("Manage Questions", 880, 200, "id", "asc", $gridColumn, $gridColumnModel, site_url("?c=question&m=load_question&searchField={$_POST['searchField']}"), true); } else { $gridObj->setGridOptions("Manage Questions", 880, 200, "id", "desc", $gridColumn, $gridColumnModel, site_url('question/load_question'), true); } $data['grid_data'] = $gridObj->getGrid(); $data['msg'] = $this->session->flashdata('msg'); $data['dir'] = 'shorturl'; $data['page'] = 'index'; $data['page_title'] = 'Manage Questions'; $this->load->view('main', $data); }
function index() { if (!common::view_permit()) { common::redirect(); } $gridObj = new grid(); $gridColumn = array("Short Code", "Short URL", "URL", "Ga Campaign", "Ga Addgroup", "Ga Add Content", "Ga Keyword"); $gridColumnModel = array(array("name" => "shortcode", "index" => "shortcode", "width" => 100, "sortable" => true, "align" => "left", "editable" => true), array("name" => "shorturl", "index" => "shorturl", "width" => 100, "sortable" => true, "align" => "left", "editable" => true), array("name" => "url", "index" => "url", "width" => 150, "sortable" => true, "align" => "left", "editable" => true), array("name" => "ga_campaign", "index" => "ga_campaign", "width" => 100, "sortable" => true, "align" => "left", "editable" => true), array("name" => "ga_adgroup", "index" => "ga_adgroup", "width" => 80, "sortable" => true, "align" => "center", "editable" => true), array("name" => "ga_ad_content", "index" => "ga_ad_content", "width" => 100, "sortable" => true, "align" => "left", "editable" => true), array("name" => "ga_keyword", "index" => "ga_keyword", "width" => 80, "sortable" => true, "align" => "center", "editable" => true)); $this->session->unset_userdata('purchase_search'); $this->session->unset_userdata('zone'); $this->session->unset_userdata('provider_name'); $this->session->unset_userdata('stating_date'); $this->session->unset_userdata('ending_date'); if ($_POST['apply_filter']) { $condition = ''; $track = 0; if ($_POST['searchField'] == 1 && $_POST['searchValue']) { $condition .= " shortcode LIKE '%" . $_POST['searchValue'] . "%' "; $track = 1; } if ($_POST['searchField'] == 2 && $_POST['searchValue']) { $condition .= " url LIKE '%" . $_POST['searchValue'] . "%' "; $track = 1; } if ($condition != '') { $this->session->set_userdata('purchase_search', $condition); } } $gridObj->setGridOptions("Url Shorter", 880, 200, "id", "desc", $gridColumn, $gridColumnModel, site_url('shorturl/load_url'), true); $data['grid_data'] = $gridObj->getGrid(); $data['msg'] = $this->session->flashdata('msg'); $data['dir'] = 'shorturl'; $data['page'] = 'index'; $data['page_title'] = 'Url Shorter'; $this->load->view('main', $data); }
function createRoleMenuEvent($data){ $data = json_decode(stripslashes($data)); if ($data->data){ $data = $data->data; $sql = "select id from menu_event"; $this->setSQL($sql); $rs = $this->executeSQL(); $temp = Array(); while ($row = $rs->FetchNextObject()){ $insert_array = Array(); if (is_array($data)){ foreach($data as $field){ $insert_array['group_id'] = $field->group_id; $insert_array['role_id'] = $row->ID; $temp[] = $insert_array; } }else{ $insert_array['group_id'] = $data->group_id; $insert_array['role_id'] = $row->ID; $temp[] = $insert_array; } } $grid = new grid(true); $grid->setTable("role_menu_event_group"); $grid->addField( array( "field"=>"role_menu_event_id", "name"=>"role_menu_event_id", "primary"=>true ) ); $grid->addField( array( "field"=>"role_id", "name"=>"role_id" ) ); $grid->addField( array( "field"=>"group_id", "name"=>"group_id" ) ); $grid->doCreate(json_encode($temp)); } }
<?php include 'grid.php'; set_time_limit(60); $racelink = $_POST['racepath']; $factor = $_POST['factor']; $gridpath = $_POST['gridpath']; $histpath = $_POST['histpath']; $finishermode = false; if ($_POST['finisher'] == 1) { $finishermode = true; } $grid1 = new grid($gridpath, true, $histpath, true); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $racelink); curl_setopt($ch, CURLOPT_REFERER, 'http://cl.racemore.de/mpres/league/CL/'); curl_setopt($ch, CURLOPT_AUTOREFERER, true); $agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"; curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); $date = getRaceDate($output); $startersAndFinishers = explode(" of ", getFinishedRacers($output)); $starter = $startersAndFinishers[1]; $finisher = $startersAndFinishers[0]; $resultArray = getResultArray($output, $starter); $grid1->addRace($resultArray, $finisher, $factor, $date, $finishermode); $grid1->saveGrid(); echo "done"; //Holt datum aus DOM
public function move($x, $y) { global $db, $game; $this->getModules(); $this->getResources(); $this->getLocation(); $moveCost = $game['factions'][$this->data['faction']]['costs']['move']; $distance = ceil(sqrt(pow($this->location['x'] - $x, 2) + pow($this->location['y'] - $y, 2))); $moveCostData = $this->checkCost($moveCost, 'move'); if ($moveCostData['ok']) { $node = new node(); if ($node->get('id', $this->data['id']) == 'done') { $sector = grid::getSector($x, $y); if ($sector['type'] == 1) { $ok = 1; $db->query('update grid set type="1", id=floor(1+rand()*9) where x="' . $this->location['x'] . '" and y="' . $this->location['y'] . '"'); if ($db->affected_rows() == -1) { $ok = 0; } $this->location['x'] = $x; $this->location['y'] = $y; $db->query('update grid set type="2", id="' . $this->data['id'] . '" where x="' . $this->location['x'] . '" and y="' . $this->location['y'] . '"'); if ($db->affected_rows() == -1) { $ok = 0; } foreach ($moveCost as $cost) { $this->resources[$cost['resource']]['value'] -= $cost['value'] * $game['users']['cost']['move']; $db->query('update resources set value="' . $this->resources[$cost['resource']]['value'] . '" where node="' . $this->data['id'] . '" and id="' . $cost['resource'] . '"'); if ($db->affected_rows() == -1) { $ok = 0; } } if ($ok) { $status = 'done'; } else { $status = 'error'; } } else { $status = 'invalidGridSector'; } } else { $status = 'noNode'; } } else { $status = 'notEnoughResources'; } return $status; }
function sortMenu($REQUEST,$parent_id,$update=0){ $grid = new grid(true); $grid->setTable("menu"); $grid->setJoin("LEFT JOIN iconcls ON menu.iconcls = iconcls.clsname"); $grid->setManualFilter(" AND parent_id = '$parent_id'"); $grid->addField(Array('field'=>'menu.id','name'=>'id','primary'=>true)); $grid->addField(Array('field'=>'menu.title','name'=>'title')); $grid->addField(Array('field'=>'iconcls.icon','name'=>'iconcls')); $grid->addField(Array('field'=>'menu.sort_id','name'=>'sort_id')); if ($update) return $grid->doUpdate($REQUEST['data']); else return $grid->doRead($REQUEST); }
/** * Renders the ajax grid * @param ajax_grid_pager $pager */ public function render($pager = null) { $sortdir_name = $this->sortdir->client_id(); if (!$this->_isExternalBuffer) { $this->buffer->start(); } if ($this->_renderFilterTop) { echo $this->render_filters('top'); } if (!is_null($this->pager) && $this->_renderPagerTop) { echo $this->pager->render('top'); } echo parent::render(array('buffer' => $this->buffer->client_id(), 'sortdir_name' => $this->sortdir->client_id(), 'sorting_name' => $this->sorting->client_id())); if ($this->_renderFilterBottom) { echo $this->render_filters('bottom'); } if (!is_null($this->pager)) { echo $this->pager->render('bottom'); } if (!$this->_isExternalBuffer) { $this->buffer->end(); } }
<?php include_once("config_sistem.php"); include_once("class/mssql.inc.php"); include_once("class/class.grid.php"); $grid = new grid(true); $task = $_REQUEST['task']; switch($task) { case 'getIcon': $grid->setTable("iconcls"); $grid->addField( array( "field"=>"id", "name"=>"id" )); $grid->addField( array( "field"=>"title", "name"=>"title" )); $grid->addField( array( "field"=>"clsname", "name"=>"clsname" )); $grid->addField( array( "field"=>"icon", "name"=>"icon"
<?php /* * Arquivo com as configuracoes iniciais */ require_once "../../app/setup.php"; require_once "../../core/data/grid.php"; /* * Estancia a classe de conexao e abre */ $conn = new connection_factory($param_conn); $grid = new grid(); $sql = ' SELECT p.id as "Cód.", p.nome as "Nome", u.nome as "Usuário", to_char(o.dt_ingresso,\'DD/MM/YYYY\') as "Data de entrada", d.descricao as "Departamento" ' . $grid->options('p.id', 'alterar.php') . ' FROM professores o LEFT OUTER JOIN usuario u ON (u.ref_pessoa = o.ref_professor), pessoas p, departamentos d WHERE o.ref_professor = p.id AND d.id = o.ref_departamento ORDER BY to_ascii(p.nome,\'LATIN1\')'; ?> <html> <head>
<?php $blog_id = trim($_REQUEST['blog_id']); #sorting variable $sort_by = $_REQUEST['sort_by']; $sort_type = $_REQUEST['sort_type']; $order_by = $sort_by . " " . $sort_type; $condition = ""; if ($blog_id != "") { $condition = " where blog.id ='" . $blog_id . "'"; } echo $aql_blog_title = "blog {\n name\n }\n blog_article {\n title \n }"; $rs_blog = aql::select($aql_blog_title); //print_a($rs_blog); // step 2. specify which columns to add to the grid $cols = "id {}\n\t\t\t\tname {\n label: Blog;\n }\n\t\t\ttitle {\n\t\t\tlabel: Article;\n\t\t}\n\t\t\t\n\t\t\t"; // step 3. display the data grid on the page $param = array('table_class' => ''); grid::render($aql_blog_title, $col, $param);
</tr> <tr> <td align="left">Category Name</td> <td align="left"><input type="text" value="" id="name" name="name" /></td> </tr> <tr> <td align="left">Blog</td> <td align="left"><?php include 'modules/blogs_select_box/blogs.php'; ?> </td> </tr> <tr> <td> </td> <td align="left"><input type="button" value="Add Category" onclick="add_category(this.form)"></td> </tr> </table> </form> </div> <?php $aql = "blog_category{\n\t\t\t\t\t\tid as save,\n\t\t\t\t\t\tid as delete,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tblog_id,\n\t\t\t\t\t\tiorder\n\t\t\t\t\t\torder by blog_category.id\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \n \t\t\t\t}\n\t\t\tblog {\n\n\t\t\t}\n\t\t\tblog_website {\n\t\t\t\twhere website_id = {$website_id}\n\t\t\t}\n\t\t\t\t\t\t"; $cols = "id {}\n\t\t\tname {\n label: Category Name;\n }\t\t \n blog_id {\n label: Blog;\n }\n\t\t iorder {\n label: iorder;\n }\n \n\t\t save {\n\t\t script: components/blog_category/id/save.php;\n\t\t }\n\t\t delete{\n\t\t script: components/blog_category/id/delete.php;\n\t\t }\n\t\t "; $param = array('table_class' => 'listing'); grid::render($aql, $col, $param); template::inc('intranet', 'bottom');
public function process() { $db = db::getInstance(); $user = user::getInstance(); include './models/game.class.php'; include './models/grid.class.php'; // récupérer le gameid $this->gameid = isset($_REQUEST['gameid']) ? intval($_REQUEST['gameid']) : false; if ($this->gameid === false) { trigger_error('Game not found', E_USER_ERROR); } // lecture de l'objet game $game = new game(); $game->read($this->gameid); // lire les grilles terminées pour trouver le prochain type de grille $grid_counts = array(); $last_grid = 0; $sql = 'SELECT userid, COUNT(gridid) AS count_gridid FROM gamesstatus WHERE gameid = ' . intval($this->gameid) . ' AND gridstatus = ' . intval(GRIDSTATUS_FINISHED) . ' GROUP BY userid'; $result = $db->query($sql); while ($row = $result->fetch_assoc()) { $grid_counts[intval($row['userid'])] = intval($row['count_gridid']); if (intval($row['count_gridid']) > $last_grid && intval($row['userid']) != $user->id) { $last_grid = intval($row['count_gridid']); } } if (isset($grid_counts[$user->id])) { if ($grid_counts && $last_grid < intval($grid_counts[$user->id])) { trigger_error('Wait for the other!', E_USER_ERROR); } $grid_count = $grid_counts ? intval($grid_counts[$user->id]) : 0; } else { $grid_count = 0; } // déterminer le prochain type de grille $gridtype = false; switch ($grid_count) { case 0: $gridtype = GRIDTYPE_ALLWORDS; break; case 1: $gridtype = GRIDTYPE_LONGEST; break; case 2: $gridtype = GRIDTYPE_CONSTRAINTS; break; default: trigger_error('Game over!', E_USER_ERROR); break; } // vérifier si l'autre adversaire est en train de créer une grille $sql = ' SELECT * FROM gamesusers WHERE gameid = ' . intval($this->gameid); $result = $db->query($sql); $row = $result->fetch_assoc(); $request = $row['request']; // lire les grilles existantes pour ce type de grille $sql = 'SELECT * FROM gamesstatus gs, grids g WHERE gs.gameid = ' . intval($this->gameid) . ' AND gs.userid = ' . intval($user->id) . ' AND gs.gridstatus = ' . intval(GRIDSTATUS_ASSIGNED) . ' AND g.gridid = gs.gridid AND g.gridtype = ' . intval($gridtype); $result = $db->query($sql); $gridid = ($row = $result->fetch_assoc()) ? intval($row['gridid']) : false; if ($request == 1) { // lire les grilles existantes pour ce type de grille $sql = 'SELECT * FROM gamesstatus gs, grids g WHERE gs.gameid = ' . intval($this->gameid) . ' AND gs.userid = ' . intval($user->id) . ' AND gs.gridstatus = ' . intval(GRIDSTATUS_ASSIGNED) . ' AND g.gridid = gs.gridid AND g.gridtype = ' . intval($gridtype); $result = $db->query($sql); $gridid = ($row = $result->fetch_assoc()) ? intval($row['gridid']) : false; while ($gridid === false) { // lire les grilles existantes pour ce type de grille $sql = 'SELECT * FROM gamesstatus gs, grids g WHERE gs.gameid = ' . intval($this->gameid) . ' AND gs.userid = ' . intval($user->id) . ' AND gs.gridstatus = ' . intval(GRIDSTATUS_ASSIGNED) . ' AND g.gridid = gs.gridid AND g.gridtype = ' . intval($gridtype); $result = $db->query($sql); $gridid = ($row = $result->fetch_assoc()) ? intval($row['gridid']) : false; } } if ($gridid === false) { if ($request == 0) { $sql = 'UPDATE gamesusers SET request = 1 WHERE gameid = ' . intval($this->gameid); $db->query($sql); // création d'une nouvelle grille $grid = new grid(); $gridid = $grid->create($gridtype); // ajout de la grille au game $game->assign_grid($gridid); $game->start_grid($gridid); } } else { $grid = new grid(); $grid->read($gridid, $game->gamelang, $gridtype); $game->start_grid($gridid); $sql = 'UPDATE gamesusers SET request = 0 WHERE gameid = ' . intval($this->gameid); $db->query($sql); } $res = $grid->get(); $res->gameid = $this->gameid; $res->gametype = GAMETYPE_BATTLE; header('Content-Type: application/json'); echo json_encode($res); die; }
<?php include 'core/config.php'; include 'core/core.php'; $db->query('start transaction'); if (isset($_POST['x'], $_POST['y'])) { $x = misc::clean($_POST['x']); $y = misc::clean($_POST['y']); } else { $x = rand(0, 49); $y = rand(0, 49); } $grid = new grid(); $grid->get($x, $y); if (isset($status) && $status == 'error') { $db->query('rollback'); } else { $db->query('commit'); } include 'templates/' . $_SESSION[$shortTitle . 'User']['template'] . '/getGrid.php';
<?php include 'core/config.php'; include 'core/core.php'; $db->query('start transaction'); if (isset($_GET['x'], $_GET['y'])) { $x = misc::clean($_GET['x'], 'numeric'); $y = misc::clean($_GET['y'], 'numeric'); $vars = 'x=' . $x . '&y=' . $y; } $grid = new grid(); $grid->getAll(); if (isset($status) && $status == 'error') { $db->query('rollback'); } else { $db->query('commit'); } include 'templates/' . $_SESSION[$shortTitle . 'User']['template'] . '/grid.php';