/** * Run the database seeds. * * @return void */ public function run() { DB::table('mods')->delete(); $testmod = Mod::create(array('pretty_name' => 'TestMod', 'name' => 'testmod', 'description' => 'This is a test mod for Solder', 'author' => 'Technic', 'link' => 'http://solder.io')); DB::table('modversions')->delete(); $testmodversion = Modversion::create(array('mod_id' => $testmod->id, 'version' => '0.1', 'md5' => 'fb6582e4d9c9bc208181907ecc108eb1')); }
public function testModDeletePost() { $modpack = Mod::where('name', '=', 'testmod2')->firstOrFail(); $this->call('POST', '/mod/delete/' . $modpack->id); $this->assertRedirectedTo('/mod/list'); $this->assertSessionHas('success'); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('mods')->delete(); $testmod = Mod::create(array('pretty_name' => 'TestMod', 'name' => 'testmod', 'description' => 'This is a test mod for Solder', 'author' => 'Technic', 'link' => 'http://solder.io')); DB::table('modversions')->delete(); $testmodversion = Modversion::create(array('mod_id' => $testmod->id, 'version' => '1.0', 'md5' => 'bdbc6c6cc48c7b037e4aef64b58258a3', 'filesize' => '295')); }
public function __construct($id = 0) { // Apela al método constructor del padre. parent::__construct($id, 'usuarios'); // Modifica propiedades de la relación. $this->setOrder('usuario'); }
public function run() { $faker = Faker\Factory::create(); foreach (range(1, 200) as $index) { $name = $faker->bs; Mod::create(['name' => $name, 'deck' => $faker->sentence(12), 'website' => $faker->url, 'download_link' => $faker->url, 'donate_link' => $faker->url, 'wiki_link' => $faker->url, 'description' => $faker->paragraph(5), 'slug' => Str::slug($name), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); } }
public function run() { $faker = Faker\Factory::create(); $modIds = Mod::lists('id'); $authorsId = Author::lists('id'); foreach (range(1, 50) as $index) { DB::table('author_mod')->insert(['author_id' => $faker->randomElement($authorsId), 'mod_id' => $faker->randomElement($modIds), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); } }
public function run() { $faker = Faker\Factory::create(); $modIds = Mod::lists('id'); $minecraftVersionIds = MinecraftVersion::lists('id'); foreach (range(1, 50) as $index) { DB::table('minecraft_version_mod')->insert(['minecraft_version_id' => $faker->randomElement($minecraftVersionIds), 'mod_id' => $faker->randomElement($modIds), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); } }
public function getSitemapMods() { $mods = Mod::orderBy('created_at', 'desc')->get(); //index $this->sitemap->add(URL::to('mods')); foreach ($this->minecraft_version_array as $version) { $this->sitemap->add(URL::to('mods/' . $version)); } foreach ($mods as $mod) { $this->sitemap->add(URL::to('mod/' . $mod->slug), $mod->updated_at); } return $this->sitemap->render('xml'); }
/** * System Constructor. * Initializing the system, check the config file * * @author Puguh Wijayanto (www.metalgenix.com) * @since 0.0.1 */ public function __construct() { self::config('config'); new Db(); new Hooks(); self::lang(Options::get('system_lang')); new Site(); Vendor::autoload(); Token::create(); Mod::loader(); Theme::loader(); Hooks::run('init'); }
function rank_chart() { $this->data['subtitle'] = "Rank New Chart"; if (intval($this->input->post('step')) == 1) { if ($this->form_validation->run('parser') == FALSE) { if (isset($_GET['suggested_id'])) { $chart = Suggested_chart::find(intval($_GET['suggested_id'])); $this->data['chart'] = $chart->raw_file; } $this->content_view = "mod/rank_chart"; $this->data['error'] = true; } else { // Validation good, second form! $this->_process_everything(); $this->data['packs'] = Pack::all(array('order' => 'name asc')); $this->content_view = "mod/rank_chart_confirm"; } } elseif (intval($this->input->post('step')) == 2) { if ($this->form_validation->run('rank_chart') == FALSE) { $this->data['packs'] = Pack::all(array('order' => 'name asc')); $this->data['error'] = true; $this->content_view = "mod/rank_chart_confirm"; } else { // Validation good, save the file! $attributes = array('pack_id' => $this->input->post('pack_id'), 'stamina_file' => $this->input->post('stamina_file'), 'file_type' => $this->input->post('file_type'), 'auto_type' => $this->input->post('auto_type'), 'date_ranked' => $this->input->post('date_ranked'), 'rate' => $this->input->post('rate'), 'title' => $this->input->post('title'), 'subtitle' => $this->input->post('subtitle'), 'artist' => $this->input->post('artist'), 'length' => $this->input->post('length'), 'dance_points' => $this->input->post('dance_points'), 'notes' => $this->input->post('notes'), 'taps' => $this->input->post('taps'), 'jumps' => $this->input->post('jumps'), 'hands' => $this->input->post('hands'), 'quads' => $this->input->post('quads'), 'holds' => $this->input->post('holds'), 'mines' => $this->input->post('mines'), 'peak_nps' => $this->input->post('peak_nps'), 'avg_nps' => $this->input->post('avg_nps'), 'avg_weighted_nps' => $this->input->post('avg_weighted_nps'), 'difficulty_score' => $this->input->post('difficulty_score'), 'raw_file' => $this->input->post('raw_file')); $new_file = new Ranked_file($attributes); $new_file->save(); $rate = $this->input->post('rate'); $log_string = $this->session->userdata('username') . " (" . $this->session->userdata('display_name') . ") ranked new file: " . number_format($rate, 1) . "x " . $this->input->post('title') . " - " . $this->input->post('difficulty_score'); write_to_mod_log($log_string); $this->data['rank_success'] = true; Mod::edit_chart($new_file->id); } } else { if (isset($_GET['suggested_id'])) { $chart = Suggested_chart::find(intval($_GET['suggested_id'])); $this->data['chart'] = $chart; } if (isset($_GET['suggested_rate'])) { $this->data['rate'] = doubleval($_GET['suggested_rate']); } $this->content_view = "mod/rank_chart"; } }
public static function getList() { $result = array(); if (is_dir(MODS_DIR) && $dh = opendir(MODS_DIR)) { while (($file = readdir($dh)) !== false) { if ( $file == '.' || $file == '..' || !is_dir(MODS_DIR . DIRECTORY_SEPARATOR . $file) ) continue; $result[] = Mod::create()->setName($file); } closedir($dh); } sort($result); return $result; }
public function getContact() { $correction_type = false; $correction_id = false; $correction_object = false; $input = Input::only('modpack', 'mod'); if ($input['modpack']) { $correction_type = 'Modpack'; $correction_id = $input['modpack']; $correction_object = Modpack::find($correction_id); } if ($input['mod']) { $correction_type = 'Mod'; $correction_id = $input['mod']; $correction_object = Mod::find($correction_id); } $title = 'Contact Us - ' . $this->site_name; $meta_description = 'Contact us if something is incorrect, if you have a question, or for anything else.'; return View::make('pages.contact', ['title' => $title, 'meta_description' => $meta_description, 'correction_type' => $correction_type, 'correction_id' => $correction_id, 'correction_object' => $correction_object]); }
public function getMod($mod = null, $version = null) { if (empty($mod)) { return Response::json(array("error" => "No mod requested")); } if (Cache::has('mod.' . $mod)) { $mod = Cache::get('mod.' . $mod); } else { $modname = $mod; $mod = Mod::where('name', '=', $mod)->first(); Cache::put('mod.' . $modname, $mod, 5); } if (empty($mod)) { return Response::json(array('error' => 'Mod does not exist')); } if (empty($version)) { return Response::json($this->fetchMod($mod)); } return Response::json($this->fetchModversion($mod, $version)); }
$alertred[] = NOFILE_UPLOADED; } if (!isset($alertred)) { //Mod::activate($_GET['modules']); $path = "/inc/mod/"; $allowed = array('zip'); $mod = Upload::go('module', $path, $allowed); //print_r($mod); $zip = new ZipArchive(); if ($zip->open($mod['filepath']) === TRUE) { $zip->extractTo(GX_MOD); $zip->close(); Hooks::run('module_install_action', $mod); $data['alertgreen'][] = MSG_MOD_INSTALLED; } else { $data['alertred'][] = MSG_MOD_CANT_EXTRACT; } unlink($mod['filepath']); } else { $data['alertred'] = $alertred; } if (isset($_POST['token'])) { Token::remove($_POST['token']); } } $data['mods'] = Mod::modList(); Theme::admin('header', $data); System::inc('modules', $data); Theme::admin('footer'); /* End of file mods.control.php */ /* Location: ./inc/lib/Control/Backend/mods.control.php */
public function testModVersion() { $mod = Mod::find(1); $modversion = $mod->versions->first(); $response = $this->call('GET', 'api/mod/' . $mod->name . '/' . $modversion->version); $this->assertResponseOk(); $this->assertTrue(is_a($response, 'Illuminate\\Http\\JsonResponse')); $json = $response->getData(true); $this->assertTrue(array_key_exists('md5', $json)); $this->assertTrue(array_key_exists('url', $json)); }
private function fetchMods() { if (Cache::has('mods') && empty($this->client) && empty($this->key)) { $mods = Cache::get('mods'); } else { $mods = Mod::all(); if (empty($this->client) && empty($this->key)) { Cache::put('mods', $mods, 10); } } $response = array(); $response['mods'] = array(); $lol = 0; foreach ($mods as $mod) { $response['mods'][$lol] = array(); $response['mods'][$lol]['name'] = $mod->name; $response['mods'][$lol]['link'] = $mod->link; $response['mods'][$lol]['pretty_name'] = $mod->pretty_name; $response['mods'][$lol]['description'] = $mod->description; $response['mods'][$lol]['author'] = $mod->author; $response['mods'][$lol]['versions'] = array(); foreach ($mod->versions as $version) { array_push($response['mods'][$lol]['versions'], $version->version); } $lol++; } $response['mirror_url'] = Config::get('solder.mirror_url'); return $response; }
public function getMod($mod = null, $version = null) { if (empty($mod)) { if (Cache::has('modlist') && empty($this->client) && empty($this->key)) { $response['mods'] = Cache::get('modlist'); } else { foreach (Mod::all() as $mod) { $response['mods'][$mod->name] = $mod->pretty_name; } //usort($response['mod'], function($a, $b){return strcasecmp($a['name'], $b['name']);}); Cache::put('modlist', $response['mods'], 5); } return Response::json($response); } else { if (Cache::has('mod.' . $mod)) { $mod = Cache::get('mod.' . $mod); } else { $modname = $mod; $mod = Mod::where('name', '=', $mod)->first(); Cache::put('mod.' . $modname, $mod, 5); } if (empty($mod)) { return Response::json(array('error' => 'Mod does not exist')); } if (empty($version)) { return Response::json($this->fetchMod($mod)); } return Response::json($this->fetchModversion($mod, $version)); } }
/** * AJAX Methods for Modpack Manager **/ public function anyModify($action = null) { if (!Request::ajax()) { return Response::view('errors.missing', array(), 404); } if (empty($action)) { return Response::view('errors.500', array(), 500); } switch ($action) { case "version": $version_id = Input::get('version'); $modversion_id = Input::get('modversion_id'); $affected = DB::table('build_modversion')->where('build_id', '=', Input::get('build_id'))->where('modversion_id', '=', $modversion_id)->update(array('modversion_id' => $version_id)); if ($affected == 0) { if ($modversion_id != $version_id) { $status = 'failed'; } else { $status = 'aborted'; } } else { $status = 'success'; } return Response::json(array('status' => $status, 'reason' => 'Rows Affected: ' . $affected)); break; case "delete": $affected = DB::table('build_modversion')->where('build_id', '=', Input::get('build_id'))->where('modversion_id', '=', Input::get('modversion_id'))->delete(); $status = 'success'; if ($affected == 0) { $status = 'failed'; } return Response::json(array('status' => $status, 'reason' => 'Rows Affected: ' . $affected)); break; case "add": $build = Build::find(Input::get('build')); $mod = Mod::where('name', '=', Input::get('mod-name'))->first(); $ver = Modversion::where('mod_id', '=', $mod->id)->where('version', '=', Input::get('mod-version'))->first(); $affected = DB::table('build_modversion')->where('build_id', '=', $build->id)->where('modversion_id', '=', $ver->id)->get(); $duplicate = !empty($affected); if ($duplicate) { return Response::json(array('status' => 'failed', 'reason' => 'Duplicate Modversion found')); } else { $build->modversions()->attach($ver->id); return Response::json(array('status' => 'success', 'pretty_name' => $mod->pretty_name, 'version' => $ver->version)); } break; case "recommended": $modpack = Modpack::find(Input::get('modpack')); $new_version = Input::get('recommended'); $modpack->recommended = $new_version; $modpack->save(); Cache::forget('modpack.' . $modpack->slug); return Response::json(array("success" => "Updated " . $modpack->name . "'s recommended build to " . $new_version, "version" => $new_version)); break; case "latest": $modpack = Modpack::find(Input::get('modpack')); $new_version = Input::get('latest'); $modpack->latest = $new_version; $modpack->save(); Cache::forget('modpack.' . $modpack->slug); return Response::json(array("success" => "Updated " . $modpack->name . "'s latest build to " . $new_version, "version" => $new_version)); break; case "published": $build = Build::find(Input::get('build')); $published = Input::get('published'); $build->is_published = $published ? true : false; $build->save(); return Response::json(array("success" => "Updated build " . $build->version . "'s published status.")); case "private": $build = Build::find(Input::get('build')); $private = Input::get('private'); $build->private = $private ? true : false; $build->save(); return Response::json(array("success" => "Updated build " . $build->version . "'s private status.")); } }
</a></li> <li> <a href="index.php?page=settings" <?php echo isset($_GET['page']) && $_GET['page'] == 'settings' ? "class=\"active\"" : ""; ?> > <i class="fa fa-wrench"></i> <?php echo SETTINGS; ?> </a></li> <?php echo Theme::thmMenu(); ?> <?php echo Mod::ModMenu(); ?> <li> <a href="logout.php"> <i class="fa fa-power-off"></i> <?php echo LOGOUT; ?> </a> </li> </ul> </div> </div> <?php } else { }
function installMods($mods) { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; $res = $db->sql_query( 'SELECT style_name FROM ' . $table_prefix . 'styles WHERE style_id = ' . $config['default_style'] ); $this->style = $db->sql_fetchfield('style_name'); $build = Build::create(); foreach ($mods as $modName) $build->addMod(Mod::create()->setName($modName)); try { $deps = $build->getDependences('style'); } catch (Exception $e) { return null; } if ($deps && !in_array($this->style, $deps)) { return $build; } else { try { InstallAction::me()->setBuild($build)->run(); file_put_contents( USER_DIR . DIRECTORY_SEPARATOR . '.htaccess', str_replace( $this->build->getHash(), $build->getHash(), file_get_contents( USER_DIR . DIRECTORY_SEPARATOR . '.htaccess' ) ) ); file_put_contents( USER_DIR . DIRECTORY_SEPARATOR . 'nginx.rewrite', str_replace( $this->build->getHash(), $build->getHash(), file_get_contents( USER_DIR . DIRECTORY_SEPARATOR . 'nginx.rewrite' ) ) ); } catch (Exception $e) { trigger_error($e->getMessage(),E_USER_WARNING); } } return $this; }
/** * AJAX Methods for Modpack Manager **/ public function action_modify($action = null) { if (empty($action)) { return Response::error('500'); } switch ($action) { case "version": $affected = DB::table('build_modversion')->where('id', '=', Input::get('pivot_id'))->update(array('modversion_id' => Input::get('version'))); return Response::json(array('success' => 'Rows Affected: ' . $affected)); break; case "delete": $affected = DB::table('build_modversion')->where('id', '=', Input::get('pivot_id'))->delete(); return Response::json(array('success' => 'Rows Affected: ' . $affected)); break; case "add": $build = Build::find(Input::get('build')); $mod = Mod::where('name', '=', Input::get('mod-name'))->first(); $ver = ModVersion::where('mod_id', '=', $mod->id)->where('version', '=', Input::get('mod-version'))->first(); $build->modversions()->attach($ver->id); return Response::json(array('pretty_name' => $mod->pretty_name, 'version' => $ver->version)); break; case "recommended": $modpack = Modpack::find(Input::get('modpack')); $new_version = Input::get('recommended'); $modpack->recommended = $new_version; $modpack->save(); return Response::json(array("success" => "Updated " . $modpack->name . "'s recommended build to " . $new_version, "version" => $new_version)); break; case "latest": $modpack = Modpack::find(Input::get('modpack')); $new_version = Input::get('latest'); $modpack->latest = $new_version; $modpack->save(); return Response::json(array("success" => "Updated " . $modpack->name . "'s latest build to " . $new_version, "version" => $new_version)); break; case "published": $build = Build::find(Input::get('build')); $published = Input::get('published'); $build->is_published = $published ? true : false; $build->save(); return Response::json(array("success" => "Updated build " . $build->version . "'s published status.")); } }
public function postEdit($id) { $selected_versions = []; $selected_authors = []; $selected_maintainers = []; $minecraft_versions = MinecraftVersion::all(); $title = 'Edit A Mod - ' . $this->site_name; $can_edit_maintainers = false; $mod = Mod::find($id); if (Auth::check()) { $maintainer = $mod->maintainers()->where('user_id', Auth::id())->first(); if (!$maintainer) { if ($this->checkRoute()) { $can_edit_maintainers = true; } else { return Redirect::route('index'); } } } else { return Redirect::route('index'); } $authors = $mod->authors; $versions = $mod->versions; $maintainers = $mod->maintainers; $input = Input::only('name', 'selected_versions', 'selected_authors', 'selected_maintainers', 'deck', 'website', 'download_link', 'donate_link', 'wiki_link', 'description', 'slug', 'mod_list_hide'); $messages = ['unique' => 'This mod already exists in the database. If it requires an update let us know!', 'url' => 'The :attribute field is not a valid URL.']; $validator = Validator::make($input, ['name' => 'required|unique:mods,name,' . $mod->id, 'selected_authors' => 'required', 'selected_versions' => 'required', 'deck' => 'required', 'website' => 'url', 'download_url' => 'url', 'wiki_url' => 'url', 'donate_link' => 'url'], $messages); if ($validator->fails()) { return Redirect::action('ModController@getEdit', [$mod->id])->withErrors($validator)->withInput(); } $mod->name = $input['name']; $mod->deck = $input['deck']; $mod->website = $input['website']; $mod->download_link = $input['download_link']; $mod->donate_link = $input['donate_link']; $mod->wiki_link = $input['wiki_link']; $mod->description = $input['description']; if ($can_edit_maintainers) { if ($input['slug'] == '' || $input['slug'] == $mod->slug) { $slug = Str::slug($input['name']); } else { $slug = $input['slug']; } $mod->slug = $slug; if ($input['mod_list_hide'] == 1) { $mod->mod_list_hide = 1; } else { $mod->mod_list_hide = 0; } } $mod->last_ip = Request::getClientIp(); $success = $mod->save(); if ($success) { foreach ($authors as $a) { $mod->authors()->detach($a->id); } $mod->authors()->attach($input['selected_authors']); foreach ($versions as $v) { $mod->versions()->detach($v->id); } $mod->versions()->attach($input['selected_versions']); if ($can_edit_maintainers) { foreach ($maintainers as $m) { $mod->maintainers()->detach($m->id); } if ($input['selected_maintainers']) { $mod->maintainers()->attach($input['selected_maintainers']); } } $updated_mod = Mod::find($mod->id); foreach ($updated_mod->versions as $v) { $selected_versions[] = $v->name; } foreach ($updated_mod->authors as $a) { $selected_authors[] = $a->id; } foreach ($updated_mod->maintainers as $m) { $selected_maintainers[] = $m->id; } Cache::tags('mods')->flush(); Queue::push('BuildCache'); return View::make('mods.edit', ['title' => $title, 'mod' => $mod, 'chosen' => true, 'success' => true, 'selected_versions' => $selected_versions, 'selected_authors' => $selected_authors, 'selected_maintainers' => $selected_maintainers, 'versions' => $minecraft_versions, 'can_edit_maintainers' => $can_edit_maintainers]); } return Redirect::action('ModController@getEdit', [$mod->id])->withErrors(['message' => 'Unable to edit mod.'])->withInput(); }
public static function loader() { $data = ""; if (isset($_GET['page']) && $_GET['page'] == "modules") { if (isset($_GET['act'])) { if ($_GET['act'] == ACTIVATE) { if (!Token::isExist($_GET['token'])) { $alertred[] = TOKEN_NOT_EXIST; } if (!isset($alertred)) { self::activate($_GET['modules']); $GLOBALS['alertgreen'] = MODULES_ACTIVATED; } else { $GLOBALS['alertred'] = $alertred; } } elseif ($_GET['act'] == DEACTIVATE) { if (!Token::isExist($_GET['token'])) { $alertred[] = TOKEN_NOT_EXIST; } if (!isset($alertred)) { self::deactivate($_GET['modules']); $GLOBALS['alertgreen'] = MODULES_DEACTIVATED; } else { $GLOBALS['alertred'] = $alertred; } } elseif ($_GET['act'] == 'remove') { if (!Token::isExist($_GET['token'])) { $alertred[] = TOKEN_NOT_EXIST; } if (Mod::isActive($_GET['modules'])) { $alertred[] = "Module is Active. Please deactivate first."; } if (!isset($alertred)) { self::deactivate($_GET['modules']); Files::delTree(GX_MOD . "/" . $_GET['modules']); $GLOBALS['alertgreen'] = MODULES_DELETED; } else { $GLOBALS['alertred'] = $alertred; } } } } $json = Options::get('modules'); $mods = json_decode($json, true); if (!is_array($mods) || $mods == "") { $mods = array(); } foreach ($mods as $m) { if (self::exist($m)) { self::load($m); } } return $data; }
public function action_addversion() { $mod_id = Input::get('mod-id'); $version = Input::get('add-version'); if (empty($mod_id) || empty($version)) { return Response::json(array('status' => 'error', 'reason' => 'Missing Post Data')); } $mod = Mod::find($mod_id); if (empty($mod)) { return Response::json(array('status' => 'error', 'reason' => 'Could not pull mod from database')); } $ver = new ModVersion(); $ver->mod_id = $mod->id; $ver->version = $version; if ($md5 = $this->mod_md5($mod, $version)) { $ver->md5 = $md5; $ver->save(); return Response::json(array('status' => 'success', 'version' => $ver->version, 'md5' => $ver->md5)); } else { return Response::json(array('status' => 'error', 'reason' => 'Could not get MD5. URL Incorrect?')); } }
public function mods() { return Mod::all(); }
public function actionPushLogin() { $student_username = Yii::app()->request->getPost("student_username", NULL); $student_password = Yii::app()->request->getPost("student_password", NULL); $student = Student::model()->find('student_username=:student_username', array(':student_username' => $student_username)); if ($student) { if ($student->student_password == hash('sha512', $student_password . Yii::app()->params['salt'])) { $current = Current::model()->find('student_id=:student_id', array('student_id' => $student->student_id)); $mod = Mod::model()->find('mod_id=:mod_id', array('mod_id' => $current->mod_id)); $response = array('student_id' => $student->student_id, 'student_username' => $student->student_username, 'student_name' => $student->student_name, 'student_surname' => $student->student_surname, 'mod_name' => $mod->mod_name); $this->renderJSON($response); } else { $this->renderJSON(array('status' => 0, 'message' => 'either username or password is not correct!')); } } else { $this->renderJSON(array('status' => 0, 'message' => 'there is no such a user registered!')); } }
/** * POST /api/$version/mod-comment/$id. * * @api * * @return json */ public function postModComment($id) { $user = $this->user(); if (!$user) { return $this->error('access-denied', 'beatmaps.modding'); } $type = strtolower(Input::get('type')); if ($type and in_array($type, $this->types)) { // restrict nominations if ($type == 'nomination' and !$user->canNominate()) { return $this->error('access-denied', 'beatmaps.modding'); } // dont let silenced users post mods if ($user->isSilenced()) { return $this->error('silenced', 'beatmaps.modding'); } // let the insertion method deal with validation return Mod::insert($id, $type); } else { return $this->error('type', 'beatmaps.modding'); } }
public function anyAddVersion() { if (Request::ajax()) { $mod_id = Input::get('mod-id'); $md5 = Input::get('add-md5'); $version = Input::get('add-version'); if (empty($mod_id) || empty($version)) { return Response::json(array('status' => 'error', 'reason' => 'Missing Post Data')); } $mod = Mod::find($mod_id); if (empty($mod)) { return Response::json(array('status' => 'error', 'reason' => 'Could not pull mod from database')); } if (empty($md5)) { $file_md5 = $this->mod_md5($mod, $version); if ($file_md5['success']) { $md5 = $file_md5['md5']; } } else { $file_md5 = $this->mod_md5($mod, $version); $pfile_md5 = !$file_md5['success'] ? "Null" : $file_md5['md5']; } $ver = new Modversion(); $ver->mod_id = $mod->id; $ver->version = $version; if ($file_md5['success'] && !empty($md5)) { if ($md5 == $file_md5['md5']) { $ver->filesize = $file_md5['filesize']; $ver->md5 = $md5; $ver->save(); return Response::json(array('status' => 'success', 'version' => $ver->version, 'md5' => $ver->md5, 'filesize' => $ver->humanFilesize("MB"))); } else { $ver->filesize = $file_md5['filesize']; $ver->md5 = $md5; $ver->save(); return Response::json(array('status' => 'warning', 'version' => $ver->version, 'md5' => $ver->md5, 'filesize' => $ver->humanFilesize("MB"), 'reason' => 'MD5 provided does not match file MD5: ' . $pfile_md5)); } } else { return Response::json(array('status' => 'error', 'reason' => 'Remote MD5 failed. ' . $file_md5['message'])); } } return Response::view('errors.missing', array(), 404); }
public function getMod($id) { $modpacks = []; $raw_mod = Mod::find($id); if (!$raw_mod) { return Response::json(['error' => 'No mod with that ID found.']); } $raw_modpacks = $raw_mod->modpacks; foreach ($raw_modpacks as $modpack) { $modpacks[] = ['id' => $modpack->id, 'name' => $modpack->name, 'short_description' => $modpack->deck, 'website' => $modpack->website, 'download_link' => $modpack->download_link, 'donate_link' => $modpack->website, 'wiki_link' => $modpack->wiki_link, 'descriptions' => $modpack->descriptions, 'slug' => $modpack->slug, 'created_at' => $modpack->created_at, 'updated_at' => $modpack->updated_at]; } $result = ['id' => $raw_mod->id, 'name' => $raw_mod->name, 'short_description' => $raw_mod->deck, 'website' => $raw_mod->website, 'download_link' => $raw_mod->download_link, 'donate_link' => $raw_mod->website, 'wiki_link' => $raw_mod->wiki_link, 'descriptions' => $raw_mod->descriptions, 'modpacks' => $modpacks, 'slug' => $raw_mod->slug, 'created_at' => $raw_mod->created_at, 'updated_at' => $raw_mod->updated_at]; return Response::json($result); }
public function __construct($id = 0) { parent::__construct($id, 'contenidos'); }