本文整理汇总了PHP中Server::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::save方法的具体用法?PHP Server::save怎么用?PHP Server::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionTambah
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'ubah' page.
*/
public function actionTambah()
{
$model = new Server();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Server'])) {
$model->attributes = $_POST['Server'];
if ($model->save()) {
$this->redirect(array('ubah', 'id' => $model->id));
}
}
$this->render('tambah', array('model' => $model));
}
示例2: editServer
public function editServer()
{
$id = intval(Input::get('id'));
$server = null;
if ($id) {
$server = Server::find($id);
}
if ($server && !Auth::user()->pj_is_mine($server->project_id)) {
App::abort(403, 'Not your project');
}
$project_id = intval(Input::get("project_id"));
//权限
if (!Auth::user()->pj_is_mine($project_id)) {
$project_id = 0;
}
$error = '';
if (Request::isMethod('post')) {
$title = trim(Input::get('title'));
$ip = trim(Input::get('ip'));
$rsync_name = trim(Input::get('rsync_name'));
$comment = trim(Input::get('comment'));
if (!$title || !$ip || !$rsync_name || !$project_id) {
$error = "填写信息不完整";
}
if (!$error) {
if (!$server) {
$server = new Server();
$server->last_pub_time = '0000-00-00 00:00:00';
}
$server->title = $title;
$server->project_id = $project_id;
$server->ip = $ip;
$server->rsync_name = $rsync_name;
$server->current_version = '';
$server->comment = $comment;
$server->save();
return Redirect::action('ProjectsController@publish', array('id' => $project_id));
}
}
//当前用户拥有的所有项目
$projects = Project::whereIn('id', Auth::user()->pj_ids())->get();
$prj_list = array();
foreach ($projects as $value) {
$prj_list[$value->id] = $value->title;
}
return View::make('servers/edit', array('server' => $server, 'error' => $error, 'project_id' => $project_id, 'projects' => $prj_list));
}
示例3: Server
}
}
}
}
$server = new Server();
switch ($server->get_action) {
case 'login':
$server->login();
$loginPage = new HtmlEntities();
echo $loginPage->getLoginPage();
break;
case 'logout':
$server->logout();
break;
case 'save':
$server->save();
break;
case 'isloggedin':
$server->isLoggedIn();
break;
case 'duplicate':
$server->duplicate();
break;
case 'mkdir':
$server->mkdir();
break;
case 'create':
$server->create();
break;
default:
$errorPage = new HtmlEntities();
示例4: postAdd
public function postAdd()
{
$logged_in = false;
if (Auth::check()) {
$logged_in = true;
}
$versions = MinecraftVersion::all();
$title = 'Add Server - ' . $this->site_name;
$countries = Server::countryList();
$permissions = [1 => 'Whitelist', 2 => 'Greylist', 3 => 'Open'];
$input = Input::only('name', 'modpack', 'email', 'deck', 'website', 'application_url', 'description', 'slug', 'server_address_hide', 'player_list_hide', 'motd_hide', 'server_address', 'tags', 'country', 'permissions', 'last_world_reset', 'next_world_reset', 'active', 'email_alerts', 'g-recaptcha-response');
$modpack = Modpack::find($input['modpack']);
$modpack_version = $modpack->version->name;
if (preg_match('/:/', $input['server_address'])) {
$exploded_hostname = explode(':', $input['server_address']);
$server_host = $exploded_hostname[0];
$server_port = $exploded_hostname[1];
} else {
$server_host = $input['server_address'];
$server_port = 25565;
}
$input['server_host'] = $server_host;
$server_info = Server::check($server_host, $server_port, $modpack_version);
$validator_messages = ['name.unique' => 'A server with this name already exists in the database.', 'server_host.unique' => 'A server with this address already exists in the database.', 'country.not_in' => 'The country field is required.', 'deck.required' => 'The short description field is required.', 'deck.max' => 'The short description may not be greater than 255 characters.', 'url' => 'The :attribute field is not a valid URL.', 'g-recaptcha-response.required' => 'reCAPTCHA verification is required.'];
$validator_rules = ['name' => 'required|unique:servers,name', 'server_host' => 'required|unique:servers,ip_host,NULL,id,port,' . $server_port, 'deck' => 'required|max:255', 'website' => 'url', 'application_url' => 'url', 'tags' => 'required', 'country' => 'required|not_in:choose,separator1,separator2', 'permissions' => 'required', 'last_world_reset' => 'date_format:Y-m-d', 'next_world_reset' => 'date_format:Y-m-d'];
if (!$logged_in) {
$validator_rules['email'] = 'required|email';
$validator_rules['g-recaptcha-response'] = 'required|recaptcha';
}
$validator = Validator::make($input, $validator_rules, $validator_messages);
if (!$server_info) {
$validator->fails();
//manually fail the validator since we can't reach the server
$validator->getMessageBag()->add('server_address', 'Unable to reach server.');
return Redirect::action('ServerController@getAdd')->withErrors($validator)->withInput();
} elseif ($validator->fails()) {
return Redirect::action('ServerController@getAdd')->withErrors($validator)->withInput();
}
$server = new Server();
$server->modpack_id = $modpack->id;
$server->minecraft_version_id = $modpack->minecraft_version_id;
$server->name = $input['name'];
$server->ip_host = $server_host;
$server->port = $server_port;
$server->deck = $input['deck'];
$server->country = $input['country'];
$server->permissions = $input['permissions'];
$server->website = $input['website'];
$server->application_url = $input['application_url'];
$server->description = $input['description'];
$server->last_world_reset = $input['last_world_reset'];
$server->next_world_reset = $input['next_world_reset'];
$server->last_check = Carbon\Carbon::now()->toDateTimeString();
if ($logged_in) {
if ($input['active'] == 1) {
$server->active = 1;
}
$server->user_id = Auth::id();
} else {
$server->user_id = 0;
}
if ($input['email_alerts'] == 1) {
$server->email_alerts = 1;
}
if ($input['server_address_hide'] == 1) {
$server->server_address_hide = 1;
}
if ($input['player_list_hide'] == 1) {
$server->player_list_hide = 1;
}
if ($input['motd_hide'] == 1) {
$server->motd_hide = 1;
}
if ($input['slug'] == '') {
$slug = Str::slug($input['name']);
} else {
$slug = $input['slug'];
}
$server->slug = $slug;
$server->last_ip = Request::getClientIp();
$success = $server->save();
if ($success) {
foreach ($input['tags'] as $tag) {
$server->tags()->attach($tag);
}
$server_status = new ServerStatus();
$server_status->server_id = $server->id;
if (isset($server_info['players']['online'])) {
$server_status->current_players = $server_info['players']['online'];
} elseif (isset($server_info['Players'])) {
$server_status->current_players = $server_info['Players'];
}
if (isset($server_info['players']['max'])) {
$server_status->max_players = $server_info['players']['max'];
} elseif (isset($server_info['MaxPlayers'])) {
$server_status->max_players = $server_info['MaxPlayers'];
}
$server_status->last_success = Carbon\Carbon::now()->toDateTimeString();
if (isset($server_info['modinfo'])) {
$server_status->mods = json_encode($server_info['modinfo']);
//.........这里部分代码省略.........