function OptimizeTable($Token, $Table = null) { $total = 0; if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($Token)) > 0 && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_ADMIN, 0, AUTH_CREATE)) { if (is_null($Table)) { $tables = $this->db->query('show tables'); $t = 'Tables_in_' . DB_DATABASE; do { set_time_limit(60 * 60); $this->db->query('optimize table "' . $tables->{$t} . '"'); $total++; } while ($tables->next()); } else { if (is_array($Table) && count($Table > 0)) { foreach ($Table as $k => $t) { set_time_limit(60 * 60); $this->db->query('optimize table "' . $t . '"'); $total++; } } } return Success($total); } return NoAuthorization(); }
public function CreateGame($request) { if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0) { switch ($request['Type']) { case 'flag-capture': return Success($this->create_flag_capture($request['Name'], $mundane_id, $request['Configuration'])); break; default: return Success($this->create_game($request['Name'], 'custom', $mundane_id, $request['Configuration'], array())); break; } } else { return NoAuthorization(); } }
public function RemoveAttendance($request) { logtrace("Attendance->RemoveAttendance()", $request); if ($this->AttendanceAuthority($request) === false) { return NoAuthorization(); } $this->attendance->clear(); $this->attendance->attendance_id = $request['AttendanceId']; if (!valid_id($request['AttendanceId']) || !$this->attendance->find()) { return InvalidParameter(); } $this->attendance->delete(); return Success($this->attendance->attendance_id); }
private function post_single_elim_matches($bracket_id, $matches) { if (!$this->check_auth($request)) { return NoAuthorization(); } }
public function RemoveAward($request) { if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0 && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_ADMIN, 0, AUTH_EDIT)) { $this->log->Write('Award', $mundane_id, LOG_REMOVE, $request); $this->award->award_id = $request['AwardId']; if ($this->award->find()) { $this->award->delete(); } return Success(); } return NoAuthorization(); }
public function add_authorization($requester_id, $request) { logtrace('add_authorization', $request); $response = []; switch ($request['Role']) { case AUTH_CREATE: break; case AUTH_EDIT: break; case AUTH_ADMIN: break; default: $response = InvalidParameter(null, 'Unrecognized Role: $request[Role].'); return $response; } if ($this->HasAuthority($requester_id, $request['Type'], $request['Id'], AUTH_CREATE)) { $this->log->Write('Authorization', $requester_id, LOG_ADD, $request); $response = $this->add_auth_h($request); return $response; } else { if (AUTH_UNIT == $request['Type']) { $mundane = Ork3::$Lib->player->player_info($requester_id); if ($this->HasAuthority($requester_id, AUTH_KINGDOM, $mundane['KingdomId'], AUTH_EDIT)) { $this->log->Write('Authorization:KPM Unit Bypass', $requester_id, LOG_ADD, $request); $response = $this->add_auth_h($request); return $response; } } else { $response = NoAuthorization(); } } return $response; }
public function RemoveAward($request) { logtrace("RemoveAward()", $request); $mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token']); $awards = new yapo($this->db, DB_PREFIX . 'awards'); $awards->clear(); $awards->awards_id = $request['AwardsId']; if (valid_id($request['AwardsId']) && $awards->find()) { $mundane = $this->player_info($awards->mundane_id); if (valid_id($mundane_id) && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_PARK, $mundane['ParkId'], AUTH_EDIT)) { $awards->delete(); } else { return NoAuthorization(); } } else { return InvalidParameter(); } }
public function SetUnit($request) { logtrace("SetUnit()", $request); if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0 && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_UNIT, $request['UnitId'], AUTH_CREATE)) { logtrace("SetUnit() :Secure", null); $this->unit->clear(); $this->unit->unit_id = $request['UnitId']; $this->unit->find(); $this->unit->name = $request['Name']; $this->unit->description = strip_tags($request['Description'], "<p><br><ul><li><b><i>"); $this->unit->history = strip_tags($request['History'], "<p><br><ul><li><b><i>"); $this->unit->url = $request['Url']; $this->unit->save(); if (strlen($request['Heraldry'])) { logtrace("SetUnit() :SetUnitHeraldry()", null); Ork3::$Lib->heraldry->SetUnitHeraldry($request); } return Success(); } return NoAuthorization(); }
public function record_transaction($trn, $splits, $trx_date = null) { logtrace('record_transaction', array($trn, $splits, $trx_date)); $trx_date = is_null($trx_date) ? date('Y-m-d') : date('Y-m-d', strtotime($trx_date)); $authority = false; foreach ($splits as $s => $split) { $authority |= $this->has_account_authority($trn['RecordedBy'], $split['AccountId']); $this->account->clear(); $this->account->account_id = $split['AccountId']; if (!$this->account->find()) { return InvalidParameter(print_r(array($split['AccountId'], true))); } else { $splits[$s]['AccountType'] = $this->account->type; } } if (!$authority) { return NoAuthorization(print_r(array($trn['RecordedBy'], $split['AccountId']), true)); } $this->transaction->clear(); $this->transaction->recorded_by = $trn['RecordedBy']; $this->transaction->date_created = date("Y-m-d H:i:s"); $this->transaction->description = $trn['Description']; $this->transaction->memo = $trn['Memo']; $this->transaction->transaction_date = $trx_date; $this->transaction->save(); $debit = 0.0; $credit = 0.0; foreach ($splits as $s => $split) { $this->split->clear(); $this->split->transaction_id = $this->transaction->transaction_id; $this->split->account_id = $split['AccountId']; $this->split->is_dues = $split['IsDues']; $this->split->src_mundane_id = $split['SrcMundaneId']; $this->split->dues_through = strlen($split['DuesThrough']) > 0 ? $split['DuesThrough'] : null; $this->split->amount = round($split['DrCr'] == $this->dr_cr_sign_convention($split['AccountType'], $split['Amount']) ? $split['Amount'] : -$split['Amount'], 3); $this->split->save(); if ($this->dr_cr_sign_convention($split['AccountType'], $split['Amount']) == TreasuryDrCr::Dr) { $debit += $this->split->amount; } else { $credit += $this->split->amount; } } if (abs($debit - $credit) > 0.005) { $this->account->clear(); $this->account->account_id = $this->split->account_id; $this->account->find(); $k = $this->account->kingdom_id; $idt = $this->DetermineAuthType() . '_id'; $id = $this->account->{$idt}; $this->account->clear(); $this->account->kingdom_id = $k; $this->account->{$idt} = $id; $this->account->type = TreasuryAccountType::Imbalance; if ($this->account->find()) { $this->split->clear(); $this->split->transaction_id = $this->transaction->transaction_id; $this->split->account_id = $split['AccountId']; $this->split->is_dues = 0; $this->split->src_mundane_id = $split['SrcMundaneId']; $this->split->amount = $credit - $debit; $this->split->save(); } else { // crap return InvalidParameter('Canno record split.'); } } }
public function WaffleKingdom($request, $waffle) { $response = []; if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0 && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_ADMIN, 0, AUTH_EDIT)) { $this->log->Write('Kingdom', $mundane_id, 'Active' == $waffle ? LOG_RESTORE : LOG_RETIRE, $request); $this->kingdom->clear(); $this->kingdom->kingdom_id = $request['KingdomId']; if ($this->kingdom->find()) { $this->kingdom->active = $waffle; $this->kingdom->save(); $response = Success(); } else { $response = InvalidParameter(NULL, 'Problem processing request.'); } } else { $response = NoAuthorization(); } return $response; }
public function SetEvent($request) { $mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token']); if (valid_id($mundane_id) && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_EVENT, $request['EventId'], AUTH_EDIT)) { $this->event->clear(); $this->event->event_id = $request['EventId']; $response = array(); if (valid_id($request['EventId']) && $this->event->find()) { if (is_numeric($request['KingdomId'])) { $this->event->kingdom_id = $request['KingdomId']; } if (is_numeric($request['ParkId'])) { $this->event->park_id = $request['ParkId']; $p = Ork3::$Lib->park->GetParkShortInfo(array('ParkId' => $request['ParkId'])); if ($p['Status']['Status'] != 0) { return $p['Status']; } else { $this->event->kingdom_id = $p['KingdomId']; } } if (is_numeric($request['MundaneId'])) { $this->event->mundane_id = $request['MundaneId']; } if (is_numeric($request['UnitId'])) { $this->event->unit_id = $request['UnitId']; } if (trimlen($request['Name'])) { $this->event->name = $request['Name']; } $this->event->save(); Ork3::$Lib->heraldry->SetEventHeraldry($request); logtrace("SetEvent", array($request, $this->event)); return Success(); } else { return InvalidParameter('Event Id is not a valid id.'); } } else { return NoAuthorization(); } }
public function SetEventHeraldry($request) { if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0 && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_EVENT, $request['EventId'], AUTH_EDIT)) { $this->event->clear(); $this->event->event_id = $request['EventId']; if ($this->event->find()) { $request = $this->fetch_url_heraldry($request); $this->store_heraldry($request, DIR_EVENT_HERALDRY, 5, 'event'); $this->event->save(); return Success(); } else { return InvalidParameter(); } } else { return NoAuthorization(); } }